-
Notifications
You must be signed in to change notification settings - Fork 24
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
Falling back to syscall on EACCES #68
Comments
@bchalios, you contributed |
Hi @XanClic and sorry for the delayed response.
So, the answer to your question
is yes :) If your process gets an
IMHO this seems like a misconfigured system. The default value of |
Thanks for the reply! I’m the admin of my system, and it’s plausible that I “misconfigured” my system some time (i.e. years) ago so I could use/test postcopy migration with qemu, finding that setting unprivileged_userfaultfd to 1 made it work. In fact, given that Linux 6.1 was only released in December 2022, I assume I actually didn’t misconfigure my system then, but simply set unprivileged_userfaultfd at a time when /dev/userfaultfd wasn’t available yet, and just let it stay this way since then. So regarding “[my] system administrator doesn't want it to open it”, I do want it to open it. My configuration is just old. I understand that you find this configuration doesn’t make much sense, and I do agree. I should update /dev/userfaultfd’s permissions. However, it is a possible configuration, and nothing stopped me from enacting it, so I still wouldn’t dismiss it. It clearly does exist in practice, specifically on my system. In any case, I couldn’t gather from your reply why it would be wrong to attempt to call the syscall after opening the device file returned What I’m a bit afraid of is that we enable postcopy migration in virtiofsd (via the vhost-user-backend crate, which uses the userfaultfd crate to do so) and then users that have the same configuration as I do (which I don’t find too implausible, honestly) find that postcopy migration works with qemu alone, but not when using virtio-fs. |
Hi,
I wonder why
UffdBuilder::open_file_descriptor()
falls back to the syscall only if opening the device file failed withENOENT
. On both of the main systems I use for work, /dev/userfaultfd is not accessible by users other than root (moderw-------
, ownerroot:root
), and I can’t remember having it explicitly configured this way, so I assume this is the default. Opening /dev/userfaultfd thus returnsEPERM
, which leads toopen_file_descriptor()
just failing instead of trying the syscall as well. One of my systems has 1 in /proc/sys/vm/unprivileged_userfaultfd, so the syscall would work if we were to use it—but we never do, because the device file is there, just not accessible.Is there a reason why
open_file_descriptor()
only falls back to the syscall onENOENT
, and not when encountering other errors?Background: We’re planning to add postcopy migration support to virtiofsd, which is a VM device emulation for filesystem passthrough between host and guest. To do that, we want to use the support that the rust-vmm vhost crates provide, which rely on userfaultfd-rs to do so.
virtiofsd can sandbox itself, which, as a side effect, will hide /dev/userfaultfd. Consequently, on the system where unprivileged userfaultfd is allowed (but the device file is not accessible by non-root users), a sandboxed virtiofsd can successfully create a userfaultfd with this crate (because opening the device file returns
ENOENT
, so the syscall is used), but a non-sandboxed virtiofsd cannot (because it returnsEACCESS
, failing immediately).I’d be happy to send a PR, but the code is very explicit about only falling back on
ENOENT
(including the comment above), which is why I’m hesitant. Clearly there’s a reason, but I can’t see it from the code or the commit log.The text was updated successfully, but these errors were encountered: