-
Notifications
You must be signed in to change notification settings - Fork 12
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
Use memfd instead of temporary files #14
Comments
Is there an already existing rust wrapper around memfd, or would that mean handling the syscall manually in |
I don't see anything on crates.io, but there seems to be https://github.com/sdroege/memfd-rs (which looks like it presents a reasonable safe abstraction around memfd in general). Maybe ask the author if there's anything blocking a published release. |
Okay, I've been thinking a little about this, and there are some things that concerns me:
|
The memfd syscall is Linux-only. Wayland is Linux-first but should fundamentally be implementable on any OS, and I'm happy to see FreeBSD support moving along. From a cursory look, it seems that the FreeBSD equivalent of memfd is the FreeBSD-specific For simple usage, it may be easiest to just use Compositors are in the position of needing to support the sloppiest-implemented client users will want to run; most will support tempfile-backed shm as well as a million other features (e.g. X11 compatibility), but the beauty of the Wayland protocol is that it doesn't require all that complexity, and use-case-specific compositors can be much stricter and simpler than the DEs that most users run on their desktops. Clients can be made simpler and more robust by avoiding dependence on the filesystem (even Of course this isn't a high-priority bug, since user-facing functionality shouldn't change noticeably, but it would be a nice change that reduces the total number of moving parts in the stack as a whole. |
Yep, What does sealing mean? |
Published the tiny memfd/SHM_ANON wrapper crate! https://github.com/myfreeweb/shmemfdrs |
@myfreeweb that's an interesting crate, thanks for notifying! Just to make sure is the returned If so, would it make sense to integrate this casting in your API, making it usable with a safe interface? |
It was extracted from Servo's |
@myfreeweb, sealing is well-described at https://dvdhrm.wordpress.com/tag/memfd/. For Wayland IPC the main use-case is SEAL_SHRINK to prevent clients from causing bus errors in the server when operating on mmap'd regions that the client shrinks out from under the server. |
Temporary files are essentially a hack. For the purposes of shm, there's no need to have any filesystem entry, and it's possible for the tmp directory to be disk-backed or otherwise persistent. Linux (which is the only platform supporting Wayland properly at present) provides memfd which is generally agreed upon to be the right way to get an fd referencing a memory region. Memfd is also useful for compositors to ensure they can use mapped memory without worrying about the mapping being shrunk out from under them by buggy or hostile applications; see https://lwn.net/Articles/591108/.
Avoiding the tempfile crate will also shrink the transitive dependency graph significantly.
The text was updated successfully, but these errors were encountered: