Allowing passing a null pointer to getrandom() when length is 0#884
Allowing passing a null pointer to getrandom() when length is 0#884bors merged 3 commits intorust-lang:masterfrom
Conversation
|
We already handle NULL pointers just fine when the length is 0. The I think you ran into the same getrandom bug that I also just ran into. See rust-random/getrandom#73. (Also, did you test that your patch fixes this? Because it doesn't look like it should. I got ICEs in |
|
FWIW, even with this PR, getrandom still fails here. (You can do |
|
@RalfJung: Wow - I opened a duplicate PR within a few minutes of yours: rust-random/getrandom#74 However, applying either of our PRs is not sufficient to make that call to Line 86 in ed30152 We unconditionally try to use that pointer. I think we should add a flag to skip doing anything when the length is 0. We can enable that behavior for |
Talk about race conditions. ;)
Ah, good catch. I find it likely that all users of |
|
☔ The latest upstream changes (presumably #883) made this pull request unmergeable. Please resolve the merge conflicts. |
This preserves compatibility with programs that pass a null pointer and a length of zero to getrandom(), or their platform's equivalent.
8f4989c to
0505868
Compare
|
@RalfJung: I've made the change you requested |
Co-Authored-By: Ralf Jung <post@ralfj.de>
6f00c21 to
4d3398f
Compare
|
@RalfJung Updated |
|
Thanks! @bors r+ |
|
📌 Commit 4d3398f has been approved by |
Allowing passing a null pointer to getrandom() when length is 0 The Linux kernel will handle a null pointer passed to 'getrandom' without error, as long as the length is also 0. The `getrandom` crate relies on this behavior: https://github.com/rust-random/getrandom/blob/ab44edf3c7af721a00e22648b6c811ccb559ba81/src/linux_android.rs#L26 Since it works fine on the actual kernel (and should continue to, due to the kernel's backwards-compatibility guarantees), Miri should support it as well.
|
☀️ Test successful - checks-travis, status-appveyor |
test-cargo-miri: cargo update With both rust-random/getrandom#74 and #884 having landed, this should work now.
The Linux kernel will handle a null pointer passed to 'getrandom'
without error, as long as the length is also 0. The
getrandomcraterelies on this behavior: https://github.com/rust-random/getrandom/blob/ab44edf3c7af721a00e22648b6c811ccb559ba81/src/linux_android.rs#L26
Since it works fine on the actual kernel (and should continue to, due to
the kernel's backwards-compatibility guarantees), Miri should support it
as well.