-
Notifications
You must be signed in to change notification settings - Fork 48
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
Review safety of all functions #8
Comments
We haven't done any formal proofs or fuzzing, but other than possible implementation bugs, I'm not aware of anything in WASI which could cause unsafety in the Rust sense. |
I have this question because |
It's a good question. Yes, you can It justifies documentation, in any case :-). |
I don't know. :) @RalfJung |
That's kind of an arbitrary call that the ecosystem as a whole has to agree on -- both options work, as long as they are done consistently. But judging from things like rust-lang/rust#39575, Rust seems to be on the side of "messing with other people's file descriptors is unsafe". |
It doesn't cause UB on its own, but if other code relies on privacy of its file descriptors, that could then in combination lead to UB. So the question is if we allow other code to assume that its file descriptors are private. And I think we do, with the issue mentioned above (and unsafe |
That's a good point. And if we let code assume file descriptors are private, one could argue that even non-mutating functions, like That's inconvenient, but ideally, we shouldn't have lots of people using the |
@sunfishcode If you want, I can add these changes to #5. |
Yes, that'd be great. Looking forward, clock and random APIs at least will likely move to requiring file descriptors, but until they do, it's fine to leave them safe. It's interesting that access to ambient authorities is aligning with |
Related: https://users.rust-lang.org/t/when-should-we-mark-our-functions-unsafe/11834/3 |
BTW I think it should be fine to remove |
Even read access can still be abstraction-breaking, and abstraction is what we use to tame unsafe in Rust. We require unsafe code to read from private |
In v0.8 all functions are now safe, is it intentional? Even if we'll leave FD stuff out, signatures like this are definitely smell trouble in my opinion. |
Following @RalfJung's comment here: #8 (comment) as long as the functions are still taking integer file descriptor arguments, we should mark the APIs here `unsafe`. This is particularly interesting in the context of WASI, as it aligns with the OCap security model -- Rust's `std::fs::File` is an unforgeable handle in safe Rust. So while there are still integer file descriptors at the wasm level for now, programs compiled from safe Rust still have fine-grained isolation (with the caveat that until reference types are possible, this property isn't encoded in wasm in a verifiable way).
@newpavlov Thanks for spotting that -- I've now opened #24 to reintroduce the |
Following @RalfJung's comment here: #8 (comment) as long as the functions are still taking integer file descriptor arguments, we should mark the APIs here `unsafe`. This is particularly interesting in the context of WASI, as it aligns with the OCap security model -- Rust's `std::fs::File` is an unforgeable handle in safe Rust. So while there are still integer file descriptors at the wasm level for now, programs compiled from safe Rust still have fine-grained isolation (with the caveat that until reference types are possible, this property isn't encoded in wasm in a verifiable way).
Are we sure what all Core API functions can be wrapped in a safe interface?
The text was updated successfully, but these errors were encountered: