-
Notifications
You must be signed in to change notification settings - Fork 708
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
Add support for Redox #901
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
@briansmith Any news on this? |
@jackpot51 Does redox provide an API that's more like |
At the moment, no. Why are file handles considered dangerous? |
POSIX requires something along the lines of "The file descriptor returned by a successful call [to open] will be the lowest-numbered file descriptor not currently open for the process." I'm guessing Redox has a similar constraint. The main problem I'm aware of is when somebody accidentally closes the file descriptor that the crypto library is assuming to be valid for This issue comes up in almost every crypto library. See https://bugs.python.org/issue21207 for example. Thus I recommend every operating system provide a syscall like |
Redox is a microkernel. By design most things go through file handles. |
I understand the appeal of the design that's been chosen so far. However, I do want to emphasize this is a significant downside. Zircon is a microkernel-based OS too, and provides a Going back to ring, I am hoping to soon deprecate and/or remove the fallback to the file-based approach on other operating systems because I see this as too much of a hazard based on the real-world failures I have seen. Obviously, programs/libraries who close the file descriptors they shouldn't close are severely broken. However, it's really unfortunate when a library like ring, that is otherwise able to protect itself very well, has no defense against this. So I hope a new syscall interface for Redox is considered. That said, I'm not going to use this PR as a means of forcing the issue. When I loop back around to adding support for new targets I will merge this as-is is there is no better alternatives. |
A bigger issue that is likely to slow this down: I don't want to merge support new targets for which we do not have CI/CD coverage. So first I will need to learn how to set up a CI/CD environment that runs on a Linux host. IDK when I will get around to that. It would be very nice if somebody could add Redox to |
On Twitter, @dcarosone suggested that some operating systems might provide a "do not close" |
I'll think about kernel randomness, and a syscall for getrandom. There are other good uses for kernel randomness, and there is probably a reasonable way to have a kernel random source get fed entropy from userspace drivers. As for CI, it is pretty simple with the redoxer tool. The readme describes its use. To test this PR, for example, use the following:
Redoxer currently uses a nightly rustc that may not compile ring with warnings forbidden. This is due to use of inline assembly in Redox projects for hardware access, such as drivers and the kernel. Hopefully this is fixed soon with the new asm! macro. |
After allowing warnings in build.rs and src/lib.rs, I was able to run the tests with Redoxer successfully |
Great!
Excellent! |
This should go in mk/install-build-tools.sh when the target is redox:
Change mk/cargo.sh to do something like this for redox:
Update .github/workflows/ci.yml to add the redox target. aarch64-linux-musl is probably a good example to follow. This PR is old and uses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've unfortunately kind of given up on the idea of having CI/CD for every supported target. Similarly, I've also relaxed my stance on "/dev/urandom" and similar.
Consequently, if this gets rebased on top of main and the minor issues I commented on are fixed, I'll merge it.
I'll file an issue against Redox suggesting Redox adopt an API more like Fuchsia's.
@@ -183,7 +183,8 @@ use self::sysrand_or_urandom::fill as fill_impl; | |||
target_os = "freebsd", | |||
target_os = "netbsd", | |||
target_os = "openbsd", | |||
target_os = "solaris" | |||
target_os = "solaris", | |||
target_os = "redox" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the list alphabetized.
@@ -357,7 +358,8 @@ mod sysrand_or_urandom { | |||
target_os = "freebsd", | |||
target_os = "netbsd", | |||
target_os = "openbsd", | |||
target_os = "solaris" | |||
target_os = "solaris", | |||
target_os = "redox" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
An issue of that sort was already filed in the issue tracker. I added a comment to it: https://gitlab.redox-os.org/redox-os/redox/-/issues/816#note_22234 |
Thanks for the PR. I'm planning to switch the implementation to use the getrandom crate as part of the goal of encapsulating/minimizing operating-system-specific code in ring; see draft PR #1531. I'm closing this in favor of that approach. |
#1341 fixed this already. Good to hear you will be using getrandom. |
Add redox to the urandom for src/rand.rs. Use the
rand:
URI on Redox rather than/dev/urandom
.cc @jackpot51