aboutsummaryrefslogtreecommitdiffstats
path: root/fs/file_table.c
diff options
context:
space:
mode:
authorAmir Goldstein <[email protected]>2025-02-03 22:32:05 +0000
committerChristian Brauner <[email protected]>2025-02-07 09:27:27 +0000
commit711f9b8fbe4f4936302804e246e206f0829f628f (patch)
tree4165f46d751a5b48750797a84b4dae85d1130706 /fs/file_table.c
parentfsnotify: disable notification by default for all pseudo files (diff)
downloadkernel-711f9b8fbe4f4936302804e246e206f0829f628f.tar.gz
kernel-711f9b8fbe4f4936302804e246e206f0829f628f.zip
fsnotify: disable pre-content and permission events by default
After introducing pre-content events, we had a regression related to disabling huge faults on files that should never have pre-content events enabled. This happened because the default f_mode of allocated files (0) does not disable pre-content events. Pre-content events are disabled in file_set_fsnotify_mode_by_watchers() but internal files may not get to call this helper. Initialize f_mode to disable permission and pre-content events for all files and if needed they will be enabled for the callers of file_set_fsnotify_mode_by_watchers(). Fixes: 20bf82a898b6 ("mm: don't allow huge faults for files with pre content watches") Reported-by: Alex Williamson <[email protected]> Closes: https://lore.kernel.org/linux-fsdevel/[email protected]/ Tested-by: Alex Williamson <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'fs/file_table.c')
-rw-r--r--fs/file_table.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/file_table.c b/fs/file_table.c
index 35b93da6c5cb..5c00dc38558d 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -194,6 +194,11 @@ static int init_file(struct file *f, int flags, const struct cred *cred)
* refcount bumps we should reinitialize the reused file first.
*/
file_ref_init(&f->f_ref, 1);
+ /*
+ * Disable permission and pre-content events for all files by default.
+ * They may be enabled later by file_set_fsnotify_mode_from_watchers().
+ */
+ file_set_fsnotify_mode(f, FMODE_NONOTIFY_PERM);
return 0;
}