Fix IAR warning about volatile access#10045
Conversation
There was a problem hiding this comment.
Pull request overview
Updates RSA unpadding and ticket decryption error masking to satisfy IAR’s stricter rules around volatile access by first reading volatile values into local copies and using those in subsequent expressions.
Changes:
- Refactored constant-time RSA unpadding checks to use local copies of volatile variables in expressions.
- Updated ticket encryption callback RSA path to use a local copy of a volatile mask when composing
lastErr.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| wolfcrypt/src/rsa.c | Reads volatile masking state into local temporaries before combining/deriving masks to avoid IAR volatile-use warnings. |
| src/internal.c | Uses a local copy of lenErrMask when building args->lastErr to avoid volatile access in compound expressions. |
Comments suppressed due to low confidence (2)
src/internal.c:1
- Since
lenErrMaskCopyis the value actually used in subsequent expressions, computing directly into the non-volatile local (and only keepingvolatileif it’s required for the toolchain workaround) would reduce noise and avoid an extra volatile write+read pair. For example, compute the mask intolenErrMaskCopyand use that consistently.
src/internal.c:1 - Since
lenErrMaskCopyis the value actually used in subsequent expressions, computing directly into the non-volatile local (and only keepingvolatileif it’s required for the toolchain workaround) would reduce noise and avoid an extra volatile write+read pair. For example, compute the mask intolenErrMaskCopyand use that consistently.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Jenkins retest this please |
dgarske
left a comment
There was a problem hiding this comment.
These changes feel "hacky". Perhaps they need "volatile" added? I liked the original code better. Can we have IAR ignore that specific warning?
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10045
Scan targets checked: src, src-bugs, src-compliance, wolfcrypt-bugs, wolfcrypt-src
No new issues found in the changed files. ✅
The issue is about multiple volatile statements on one line, and the warning is valid. |
Description
Read the volatile once into a local copy, then use the copy in expressions — satisfying IAR's stricter volatile access rules. "undefined behavior: the order of volatile accesses is undefined in this statement"
Fixes zd21385
Testing
Customer confirmed clean build with IAR tools
Checklist