Skip to content

Commit 711f9b8

Browse files
amir73ilbrauner
authored andcommitted
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: 20bf82a ("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]>
1 parent 2a42754 commit 711f9b8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: fs/file_table.c

+5
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ static int init_file(struct file *f, int flags, const struct cred *cred)
194194
* refcount bumps we should reinitialize the reused file first.
195195
*/
196196
file_ref_init(&f->f_ref, 1);
197+
/*
198+
* Disable permission and pre-content events for all files by default.
199+
* They may be enabled later by file_set_fsnotify_mode_from_watchers().
200+
*/
201+
file_set_fsnotify_mode(f, FMODE_NONOTIFY_PERM);
197202
return 0;
198203
}
199204

0 commit comments

Comments
 (0)