-
Notifications
You must be signed in to change notification settings - Fork 272
Description
These lines in unsafe fn do_resolve convert a &mut [u8; _] to a &mut SYMBOL_INFOW:
backtrace-rs/src/symbolize/dbghelp.rs
Lines 226 to 227 in b65ab93
| let mut data = Aligned8([0u8; SIZE]); | |
| let info = unsafe { &mut *data.0.as_mut_ptr().cast::<SYMBOL_INFOW>() }; |
The SYMBOL_INFOW type has inter-field padding, which means that this &mut SYMBOL_INFOW could be used to write uninit bytes which would be exposed by the underlying [u8; _].
Note that the &mut SYMBOL_INFOW is passed to an external function:
backtrace-rs/src/symbolize/dbghelp.rs
Line 234 in b65ab93
| if sym_from_addr(info) != TRUE { |
sym_from_addr is an argument to this function:
backtrace-rs/src/symbolize/dbghelp.rs
Line 221 in b65ab93
| sym_from_addr: impl FnOnce(*mut SYMBOL_INFOW) -> BOOL, |
Any call to do_resolve which passes a sym_from_addr argument which writes to these padding locations would cause undefined behavior.
I would recommend modifying SYMBOL_INFOW with explicit padding fields to mitigate this problem.