Fix Process::read_into_uninit_slice Unsoundness#128
Conversation
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.
|
To be fair, the original signature for the function was already sound. You have a function that accepts one reference (other than This PR just expresses the lifetime explicitly |
|
If there's multiple input lifetimes on a function you usually need to explicitly specify it, with the one exception being if it's a method, then elision rules assume the borrow is from self by default. And that's the problem here, the borrow is not from self, so it's unsound. Usually the compiler detects this, but here we construct the slice from a raw pointer, so it loses the ability to reason about it. If you want, I can construct a use after free on the Rust playground to demonstrate it. |
|
No need, I checked it by myself and you're right👍 |
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.