-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Missing wraparound checks in DroplessArena allocation #72624
Copy link
Copy link
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
DroplessArena::alloc_raw does not check for wraparound when computing the end of the allocation, pointer arithmetic using
self.ptrandbytes:rust/src/libarena/lib.rs
Lines 382 to 391 in aeca4d6
This can be used to make the pointer wrap around, and "allocate", bumping the pointer, without growing the underlying allocation.
Callers
allocandalloc_slicecan possibly be argued to be safe due to practical size limits on values and slices, but at leastalloc_from_itercan be used to trigger this bug and write out of bounds of an allocation.Fixes to make
(Suggested) cleanups to make
<*mut T>::wrapping_add, and the method should be preferred.alloc_rawshould return something else than&mut [u8], because the contents of the slice are uninit. For example a raw slice or a slice ofMaybeUninit.This came up in discussion in PR #72417