]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/memfd: fix memfd_map() seal test 28423/head
authorDavid Rheinsberg <david@readahead.eu>
Mon, 17 Jul 2023 10:17:56 +0000 (12:17 +0200)
committerDavid Rheinsberg <david@readahead.eu>
Tue, 1 Aug 2023 08:14:50 +0000 (10:14 +0200)
commit69688410566aa9e2a00530abd91e7dfef0212c83
treecd1d8fec394befb433e326a07ac248969a5a7086
parent4d903003715b160acf7bf4baeffee7829ff99f85
basic/memfd: fix memfd_map() seal test

Private mappings are required when F_SEAL_WRITE is set on a memfd,
because otherwise you could end up with writable mappings through
mprotect() and other calls. This is a limitation of the kernel
implementation, and might be lifted by future extensions.

Regardless, the current code tests for the full `is_sealed()` before
using MAP_PRIVATE. This might end up using MAP_SHARED for write-sealed
memfds, which will be refused by the kernel.

Fix this and make memfd_map() check for exactly `F_SEAL_WRITE`.
src/basic/memfd-util.c