Skip to content

Commit 573e638

Browse files
authored
Fix Process::read_into_uninit_slice Unsoundness (#128)
The lifetime was not properly tied to the buffer passed in, which could lead to use after free if the returned slice outlived the buffer.
1 parent 8518eb1 commit 573e638

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/runtime/process.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ impl Process {
339339
/// of a specific type. The buffer does not need to be initialized. After
340340
/// the slice successfully got filled, the initialized slice is returned.
341341
#[inline]
342-
pub fn read_into_uninit_slice<T: CheckedBitPattern>(
342+
pub fn read_into_uninit_slice<'buf, T: CheckedBitPattern>(
343343
&self,
344344
address: impl Into<Address>,
345-
slice: &mut [MaybeUninit<T>],
346-
) -> Result<&mut [T], Error> {
345+
slice: &'buf mut [MaybeUninit<T>],
346+
) -> Result<&'buf mut [T], Error> {
347347
// SAFETY: The process handle is guaranteed to be valid. We provide a
348348
// valid pointer and length to the buffer. We also do proper error
349349
// handling afterwards. The buffer is guaranteed to be initialized

0 commit comments

Comments
 (0)