Null reference as insta-UB
Null reference as insta-UB
Posted Aug 21, 2024 20:38 UTC (Wed) by riking (subscriber, #95706)In reply to: Null reference as insta-UB by farnz
Parent article: Standards for use of unsafe Rust in the kernel
Note: "references must point to a valid instance of the object" is actually the safety invariant. The validity invariant is "initialized, non-null, aligned to the alignment of the object".
(What does that mean? It means that unsafe code can temporarily hold references that don't point to valid objects as long as it's careful what it does with them (doesn't try to read) and doesn't let the reference escape into safe code not controlled by the author of the unsafe code.)
