-
Notifications
You must be signed in to change notification settings - Fork 41
patina_internal_collections: Fix UB memory read in Node fields #1152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
492ef76 to
7a57e63
Compare
f0178c1 to
b1385f8
Compare
ae5dcec to
7fcea9b
Compare
|
Hi @garybeihl , I noticed you've been keeping this PR up to date, but not working on it (which is completely fine). I just wanted to make sure you were not waiting on additional information from any of us that have commented on this PR (i.e. make sure we are not blocking you in any way)! |
|
No - not blocked - I uploaded a version of the changes that uses MaybeUninit and D: Default - just waiting for further comments or change requests. If you could have a look when you get a chance, that would be great - thanks! |
a3c3321 to
490f0cf
Compare
490f0cf to
82593c8
Compare
f6e8da6 to
84636f4
Compare
…ment Replace Default trait requirement with MaybeUninit wrapper for Node data field. Only initialize data when nodes move from available to in-use list. Fixes UB where Cell::set() was reading uninitialized memory.
84636f4 to
e2a9857
Compare
Add safety documentation to all unsafe blocks in production code. Add allow(clippy::undocumented_unsafe_blocks) to test modules to avoid redundant safety comments for test assertions.
Description
Fixes an undefined behavior issue where
Cell::set()reads uninitialized memory during linked list creation inStorage::resize().Root Cause
Cell::set()internally usesmem::replace(), which reads the old value before writing the new one.Storage::resize()allocates new nodes and callsbuild_linked_list(), the Cell fields contain uninitialized memory.Impact
Fix
ptr::write()beforebuild_linked_list()addr_of_mut!()to read field pointers without creating references to uninitialized dataIntroduced by
AtomicPtr::store()writes without reading the old value, butCell::set()usesmem::replace()which reads before writingRelated to #560
How This Was Tested
cargo +nightly-2025-09-19 miri test -p patina_dxe_core.Integration Instructions
N/A