On Wed, Feb 5, 2025 at 5:59 PM Jan Kara <jack@xxxxxxx> wrote: > > On Mon 03-02-25 23:32:05, Amir Goldstein wrote: > > 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 <alex.williamson@xxxxxxxxxx> > > Closes: https://lore.kernel.org/linux-fsdevel/20250131121703.1e4d00a7.alex.williamson@xxxxxxxxxx/ > > Tested-by: Alex Williamson <alex.williamson@xxxxxxxxxx> > > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> > > Looks good. Feel free to add: > > Reviewed-by: Jan Kara <jack@xxxxxxx> > > What makes me somewhat uneasy is that this relies on the fact that > file_set_fsnotify_mode_from_watchers() will override the > FMODE_NONOTIFY_PERM (but it does not override FMODE_NONOTIFY). > This seems a bit subtle and I was looking into if we could somehow simplify the fsnotify > fmode initialization. But I didn't find anything that would be really > simpler so let's keep what we have for now. > Yeh, I noticed that too. I did not have a better idea :/ Thanks, Amir.