-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowing passing a null pointer to getrandom() when length is 0 #884
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 <[email protected]>
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
getrandom
craterelies 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.