All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fanotify: do not allow setting FAN_RENAME on non-dir
@ 2022-05-06  1:46 Amir Goldstein
  2022-05-06  3:49 ` Matthew Bobrowski
  2022-05-06  9:12 ` Jan Kara
  0 siblings, 2 replies; 6+ messages in thread
From: Amir Goldstein @ 2022-05-06  1:46 UTC (permalink / raw)
  To: Jan Kara; +Cc: Matthew Bobrowski, linux-fsdevel

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")
Link: https://lore.kernel.org/linux-fsdevel/20220505133057.zm5t6vumc4xdcnsg@quack3.lan/
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/notify/fanotify/fanotify_user.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index edad67d674dc..ae0c27fac651 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-09  9:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-06  1:46 [PATCH] fanotify: do not allow setting FAN_RENAME on non-dir Amir Goldstein
2022-05-06  3:49 ` Matthew Bobrowski
2022-05-06  9:12 ` Jan Kara
2022-05-07  5:57   ` Amir Goldstein
2022-05-07  7:55     ` Amir Goldstein
2022-05-09  9:44     ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.