3 ms·
Why jump through hoops with this special systemd fd when you can just create a regular file somewhere and mmap that?
by gavinray 3y ago
Why jump through hoops with this special systemd fd when you can just create a regular file somewhere and mmap that?
- MereInterest 3y agoI can’t say I understand that, either. If the goal is to prevent the mmap’ed file from persisting on disk, using tmpfs handles that. If the goal is to prevent other processes from accessing the mmap’ed file, the systemd fd store would have the same issue.
- astrange 3y agoYeah, I really don't see it. I think it's just because systems don't come with tmpfs. Of course tmpfs storage does get written to disk via swap.
- kelnos 3y agoI guess they don't want something that's visible through the file system. This method gives you anonymous storage that is presumably only accessible to something launched via the same systemd service unit.
- yencabulator 3y agoDeleted files are not visible through the file system either. Deleted files in tmpfs are not stored on disk. The biggest reason to use memfd_create is that you can seal the memfd so it cannot be resized, and then it's safe to mmap on another side of a trust boundary; if you mmap an arbitrary attacker-controlled FD, the attacker(/poorly written client) can make you segfault. Wayland uses sealed memfds to pass framebuffers.
- tomalbrc 3y agoIt's the "fancy new thing" and rust people having to reinvent the wheel a few dozen times.