[PATCH v4 11/19] mm/shmem_luo: Require permission to preserve a file
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Nov 11 16:31:18 PST 2026
> Require the file to be opened for reading and the caller to have
> permission to write to it in order to preserve it. Also let the owner
> preserve a file that is immutable or on a read-only superblock, and
> reject append-only files.
>
> While a file is preserved, its size is frozen for all of its users:
> truncating it, fallocate() and writes past its end fail with -EPERM.
> Today any process with an fd for a memfd can do that, even one that was
> only given a read-only fd. Requiring write permission limits this to
> callers that could truncate the file themselves. A file descriptor
> opened for writing isn't required, since that would rule out preserving
> a running binary, which can't be opened for writing. Only the permission
> of the inode is checked, so the mount doesn't need to be writable
> either. The size of an immutable file or of a file on a read-only
> superblock can't change anyway, so its owner may also preserve it.
> Append-only files are rejected, since their writers can only append to
> them, and freezing the size would stop all writes.
>
> The retrieved file can be read, so also require the file to be opened
> for reading. Otherwise a caller with a write-only fd could preserve the
> file to read its contents.
>
> Document the frozen size and the permission requirements.
>
> Signed-off-by: David Matlack <dmatlack at google.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111002358.1842967-1-dmatlack@google.com?part=11
More information about the kexec
mailing list