fsnotify: introduce pre-content permission events
authorAmir Goldstein <amir73il@gmail.com>
Fri, 15 Nov 2024 15:30:20 +0000 (10:30 -0500)
committerJan Kara <jack@suse.cz>
Tue, 10 Dec 2024 11:03:17 +0000 (12:03 +0100)
commitf156524e5d72c81792eee81f828784dc8a37a7f2
tree3d9c670511c063777307a56b5a3da5d27c4df2b5
parent0a076036b631f086a6bce93a45eaa216f234f121
fsnotify: introduce pre-content permission events

The new FS_PRE_ACCESS permission event is similar to FS_ACCESS_PERM,
but it meant for a different use case of filling file content before
access to a file range, so it has slightly different semantics.

Generate FS_PRE_ACCESS/FS_ACCESS_PERM as two seperate events, so content
scanners could inspect the content filled by pre-content event handler.

Unlike FS_ACCESS_PERM, FS_PRE_ACCESS is also called before a file is
modified by syscalls as write() and fallocate().

FS_ACCESS_PERM is reported also on blockdev and pipes, but the new
pre-content events are only reported for regular files and dirs.

The pre-content events are meant to be used by hierarchical storage
managers that want to fill the content of files on first access.

There are some specific requirements from filesystems that could
be used with pre-content events, so add a flag for fs to opt-in
for pre-content events explicitly before they can be used.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/b934c5e3af205abc4e0e4709f6486815937ddfdf.1731684329.git.josef@toxicpanda.com
fs/notify/fsnotify.c
include/linux/fs.h
include/linux/fsnotify.h
include/linux/fsnotify_backend.h
security/selinux/hooks.c