Secure Coding in C and C++ - Volatility Ahead
summary
Explains that volatile applies to lvalue accesses, not inherently to objects, so C23 changes standard wording to say "access through a volatile-qualified lvalue". Shows concrete failures: setjmp/longjmp optimization bug and a Chromium CVE (CVE-1234) where shared-memory races caused a buffer overflow fixed by copying size to the stack. Details: volatile prevents caching but does not provide atomicity, ordering, or prevent tearing; compound and ambiguous assignments are deprecated ambiguous volatile assignments (C++20) and should be avoided.
AI-written summary · about
chapters (23)
- 0:00Introduction
- 1:36Agenda
- 2:02Use Case
- 3:05Volatile Qualification
- 3:59Volatile
- 5:41Static Volatile
- 7:29Const Volatile
- 8:48Uses of Volatile
- 14:02Volatile Objects
- 17:02Data Race
- 20:19Use Cases
- 21:53Implementation Defined Behavior
- 25:39Compound Assignments
- 27:45PrePost Increment and Decrement
- 28:46Chromium Example
- 29:45Command Decoder Example
- 33:25Volatile Atomic
- 35:21Example
- 38:22LValues
- 41:32Data is volatile
- 42:06C23 language
- 43:37Summary
- 45:46References
related talks
42mMaking sense of Volatile
01h 02mWhat Volatile Means (and Doesn’t Mean) in C++ Programming
01h 01mDeprecating volatile
01h 26mVulnerable C++
01h 02mModern C++ Safety and Security At 20
51mSecure Programming Practices in C++
14mEmbedded C and C++: A Security Perspective
01h 06mSecurity Beyond Memory Safety - Using Modern C++ to Avoid Vulnerabilities by Design
