Summary: | File sealing | ||
---|---|---|---|
Product: | Base System | Reporter: | Simon Ser <contact> |
Component: | kern | Assignee: | freebsd-bugs (Nobody) <bugs> |
Status: | Closed Not A Bug | ||
Severity: | Affects Only Me | CC: | cem, crest, crest, debdrup, emaste |
Priority: | --- | ||
Version: | CURRENT | ||
Hardware: | Any | ||
OS: | Any |
Description
Simon Ser
2018-11-01 07:41:04 UTC
If I remeber correctly OpenBSD has a clean solution to this. They added a flag to mmap (MAP_ZERO) that causes reads to the truncated part of the memory mapping to return zeros. I don't know what they do with writes. Indeed you're right. OpenBSD has __MAP_NOFAULT, which is an extension flag for mmap. Would you be interested in implementing something like this? Some more information on the flag from Mark Kettenis:
> The flag is called __MAP_NOFAULT. It is somewhat deliberately
> undocumented as we didn't want to encourage people too much to use it.
>
> The flag gets translated into UVM_ET_NOFAULT in OpenBSD's vm
> subsystem. The idea is that if the pages backing the mapping are not
> available (i.e. if a file got truncated) it will be replaced with
> anonymous zero-filled memory. In other words, if the mapped data for
> a specific memory page isn't available it would behave as if the page
> was mapped with the MAP_ANON flag.
May I recommend looking at base r 362769 and the commit log [1] ? [1]: https://freshbsd.org/search?q=seal*&project%5B%5D=freebsd&repository%5B%5D=src&branches%5B%5D=head&sort=commit_date Is this functionality exposed through the FreeBSD syscall ABI or is it locked away behind the Linux ABI? It is exposed via FreeBSD syscall ABI. The native ABI is shm_open() / shm_open2(). memfd_create(2) is available in FreeBSD ABI as an alias. Linux is considering implementing something similar to OpenBSD's __MAP_NOFAULT: https://lore.kernel.org/linux-mm/1622792602-40459-1-git-send-email-mlin@kernel.org/ I don't believe file sealing is a good way forward. __MAP_NOFAULT is a better solution. |