Skip to content

Commit 69562eb

Browse files
amir73iljankara
authored andcommitted
fanotify: disallow mount/sb marks on kernel internal pseudo fs
Hopefully, nobody is trying to abuse mount/sb marks for watching all anonymous pipes/inodes. I cannot think of a good reason to allow this - it looks like an oversight that dated back to the original fanotify API. Link: https://lore.kernel.org/linux-fsdevel/20230628101132.kvchg544mczxv2pm@quack3/ Fixes: 0ff21db ("fanotify: hooks the fanotify_mark syscall to the vfsmount code") Signed-off-by: Amir Goldstein <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent a901a35 commit 69562eb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/notify/fanotify/fanotify_user.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,20 @@ static int fanotify_events_supported(struct fsnotify_group *group,
16221622
path->mnt->mnt_sb->s_type->fs_flags & FS_DISALLOW_NOTIFY_PERM)
16231623
return -EINVAL;
16241624

1625+
/*
1626+
* mount and sb marks are not allowed on kernel internal pseudo fs,
1627+
* like pipe_mnt, because that would subscribe to events on all the
1628+
* anonynous pipes in the system.
1629+
*
1630+
* SB_NOUSER covers all of the internal pseudo fs whose objects are not
1631+
* exposed to user's mount namespace, but there are other SB_KERNMOUNT
1632+
* fs, like nsfs, debugfs, for which the value of allowing sb and mount
1633+
* mark is questionable. For now we leave them alone.
1634+
*/
1635+
if (mark_type != FAN_MARK_INODE &&
1636+
path->mnt->mnt_sb->s_flags & SB_NOUSER)
1637+
return -EINVAL;
1638+
16251639
/*
16261640
* We shouldn't have allowed setting dirent events and the directory
16271641
* flags FAN_ONDIR and FAN_EVENT_ON_CHILD in mask of non-dir inode,

0 commit comments

Comments
 (0)