On Tue, Jun 28, 2022 at 12:27 PM Jan Kara <jack@xxxxxxx> wrote: > > On Mon 27-06-22 20:47:19, Amir Goldstein wrote: > > Commit ceaf69f8eadc ("fanotify: do not allow setting dirent events in > > mask of non-dir") added restrictions about setting dirent events in the > > mask of a non-dir inode mark, which does not make any sense. > > > > For backward compatibility, these restictions were added only to new > > (v5.17+) APIs. > > > > It also does not make any sense to set the flags FAN_EVENT_ON_CHILD or > > FAN_ONDIR in the mask of a non-dir inode. Add these flags to the > > dir-only restriction of the new APIs as well. > > > > Move the check of the dir-only flags for new APIs into the helper > > fanotify_events_supported(), which is only called for FAN_MARK_ADD, > > because there is no need to error on an attempt to remove the dir-only > > flags from non-dir inode. > > > > Fixes: ceaf69f8eadc ("fanotify: do not allow setting dirent events in mask of non-dir") > > Link: https://lore.kernel.org/linux-fsdevel/20220627113224.kr2725conevh53u4@xxxxxxxxxx/ > > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> > > Thanks! I've taken the patch to my tree. > > Honza > > > [1] https://github.com/amir73il/ltp/commits/fan_enotdir > > [2] https://github.com/amir73il/man-pages/commits/fanotify_target_fid Mathew and Jan, Please let me know if I can keep your RVB on the man page patch for FAN_REPORT_TARGET_FID linked above. The only change is an update to the ENOTDIR section which ends up like this: ENOTDIR flags contains FAN_MARK_ONLYDIR, and dirfd and pathname do not specify a directory. ENOTDIR mask contains FAN_RENAME, and dirfd and pathname do not specify a directory. ENOTDIR flags contains FAN_MARK_IGNORE, or the fanotify group was initialized with flag FAN_REPORT_TARGET_FID, and mask contains directory entry modification events (e.g., FAN_CREATE, FAN_DELETE), or directory event flags (e.g., FAN_ONDIR, FAN_EVENT_ON_CHILD), and dirfd and pathname do not specify a directory. Thanks, Amir.