fanotify: do not allow setting FAN_RENAME on non-dir
Subsystems (3)
Amir Goldstein
reviewerPATCH 1/1 fanotify: do not allow setting FAN_RENAME on non-dir
The desired sematics of this action are not clear, so for now deny this action. We may relax it when we decide on the semantics and implement them.
--- fs/notify/fanotify/fanotify_user.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/notify/fanotify/fanotify_user.c +5 -0
@@ -1695,6 +1695,11 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,else mnt = path.mnt; +/* FAN_RENAME is not allowed on non-dir (for now) */ + ret = -EINVAL ; +if (inode && (mask &FAN_RENAME ) && !S_ISDIR (inode->i_mode)) + goto path_put_and_out; +/* Mask out FAN_EVENT_ON_CHILD flag for sb/mount/non-dir marks */ if (mnt || !S_ISDIR (inode->i_mode)) { mask &= ~FAN_EVENT_ON_CHILD ;
Signature · 1 line
2.25.1
Quoted 7 lines · Amir Goldstein
The desired sematics of this action are not clear, so for now deny this action. We may relax it when we decide on the semantics and implement them.
Fixes 8cc3b1ccd930 ("fanotify: wire up FAN_RENAME event")Signed-off-by Amir Goldstein <[email protected]>
Thanks for sending this patch through Amir, LGTM.
Feel free to add:
Quoted 22 lines
--- fs/notify/fanotify/fanotify_user.c | 5 +++++ 1 file changed, 5 insertions(+)fs/notify/fanotify/fanotify_user.c +5
-0@@ -1695,6 +1695,11 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,else mnt = path.mnt; +/* FAN_RENAME is not allowed on non-dir (for now) */ + ret = -EINVAL ; +if (inode && (mask &FAN_RENAME ) && !S_ISDIR (inode->i_mode)) + goto path_put_and_out; +/* Mask out FAN_EVENT_ON_CHILD flag for sb/mount/non-dir marks */ if (mnt || !S_ISDIR (inode->i_mode)) { mask &= ~FAN_EVENT_ON_CHILD ;Signature · 1 line
2.25.1
/M
Jan Kara
maintainerQuoted 7 lines · Amir Goldstein
The desired sematics of this action are not clear, so for now deny this action. We may relax it when we decide on the semantics and implement them.
Fixes 8cc3b1ccd930 ("fanotify: wire up FAN_RENAME event")Signed-off-by Amir Goldstein <[email protected]>
Thanks guys. I've merged the fix to my tree (fast_track branch) and will push it to Linus on Monday once it gets at least some exposure to auto-testers.
Honza
Quoted 23 lines
--- fs/notify/fanotify/fanotify_user.c | 5 +++++ 1 file changed, 5 insertions(+)fs/notify/fanotify/fanotify_user.c +5
-0@@ -1695,6 +1695,11 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,else mnt = path.mnt; +/* FAN_RENAME is not allowed on non-dir (for now) */ + ret = -EINVAL ; +if (inode && (mask &FAN_RENAME ) && !S_ISDIR (inode->i_mode)) + goto path_put_and_out; +/* Mask out FAN_EVENT_ON_CHILD flag for sb/mount/non-dir marks */ if (mnt || !S_ISDIR (inode->i_mode)) { mask &= ~FAN_EVENT_ON_CHILD ;Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Amir Goldstein
reviewerQuoted 6 lines · Jan Kara
Quoted 4 lines · Amir Goldstein
The desired sematics of this action are not clear, so for now deny this action. We may relax it when we decide on the semantics and implement them.
Quoted 7 lines
Quoted 3 lines
Fixes 8cc3b1ccd930 ("fanotify: wire up FAN_RENAME event")Signed-off-by Amir Goldstein <[email protected]>Thanks guys. I've merged the fix to my tree (
fast_trackbranch) and will push it to Linus on Monday once it gets at least some exposure to auto-testers.
Actually, I made a mistake.
It should not return -EINVAL, it should return -ENOTDIR, because the error is the object not the syscall argument values.
Going forward, when Matthew implements FAN_RENAME on non-dir, the error should be changed to -EPERM (for unpriv caller). This will allow better documentation of behavior in kernel 5.17 and newer kernels.
Can you please fix that before sending to Linus?
Thanks,
Amir.
Amir Goldstein
reviewerQuoted 20 lines · Amir Goldstein
Quoted 6 lines · Jan Kara
Quoted 4 lines · Amir Goldstein
The desired sematics of this action are not clear, so for now deny this action. We may relax it when we decide on the semantics and implement them.
Quoted 7 lines
Quoted 3 lines
Fixes 8cc3b1ccd930 ("fanotify: wire up FAN_RENAME event")Signed-off-by Amir Goldstein <[email protected]>Thanks guys. I've merged the fix to my tree (
fast_trackbranch) and will push it to Linus on Monday once it gets at least some exposure to auto-testers.Actually, I made a mistake.
It should not return-EINVAL, it should return-ENOTDIR, because the error is the object not the syscall argument values.
Quoted 7 lines
Going forward, when Matthew implements
FAN_RENAMEon non-dir, the error should be changed to-EPERM(for unpriv caller). This will allow better documentation of behavior in kernel 5.17 and newer kernels.Can you please fix that before sending to Linus?
Actually, nevermind, I have thought of another issue so posting v2. I think we should deny all dirent events on non-dir with FAN_REPORT_TARGET_FID.
This is what happens when posting patches from airports :-P
Thanks,
Amir.
Jan Kara
maintainerQuoted 11 lines · Amir Goldstein
Quoted 10 lines · Jan Kara
Quoted 7 lines · Amir Goldstein
The desired sematics of this action are not clear, so for now deny this action. We may relax it when we decide on the semantics and implement them.
Fixes 8cc3b1ccd930 ("fanotify: wire up FAN_RENAME event")Signed-off-by Amir Goldstein <[email protected]>
Quoted 7 lines
Quoted 3 lines
Thanks guys. I've merged the fix to my tree (
fast_trackbranch) and will push it to Linus on Monday once it gets at least some exposure to auto-testers.Actually, I made a mistake.
It should not return-EINVAL, it should return-ENOTDIR, because the error is the object not the syscall argument values.
Yeah, makes sense.
Quoted 6 lines
Going forward, when Matthew implements
FAN_RENAMEon non-dir, the error should be changed to-EPERM(for unpriv caller). This will allow better documentation of behavior in kernel 5.17 and newer kernels.Can you please fix that before sending to Linus?
Yup, I'll update that.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR