Re: [PATCH] fanotify: refine the validation checks on non-dir inode mask
From: Jan Kara <jack@suse.cz>
Date: 2022-06-29 10:09:29
Also in:
linux-fsdevel
On Tue 28-06-22 20:22:28, Amir Goldstein wrote:
On Tue, Jun 28, 2022 at 12:27 PM Jan Kara [off-list ref] wrote:quoted
On Mon 27-06-22 20:47:19, Amir Goldstein wrote:quoted
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@quack3.lan/ (local) Signed-off-by: Amir Goldstein <amir73il@gmail.com>Thanks! I've taken the patch to my tree. HonzaMathew 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.
Looks good to me. Thanks! Honza -- Jan Kara [off-list ref] SUSE Labs, CR