Skip to content

Commit 0e97fd2

Browse files
committed
Merge tag 'fsnotify_for_v6.6-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull fanotify fix from Jan Kara: "Disable superblock / mount marks for filesystems that can encode file handles but not open them (currently only overlayfs). It is not clear the functionality is useful in any way so let's better disable it before someone comes up with some creative misuse" * tag 'fsnotify_for_v6.6-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: fanotify: limit reporting of event with non-decodeable file handles
2 parents f20f29c + 97ac489 commit 0e97fd2

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

fs/notify/fanotify/fanotify_user.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,16 +1585,25 @@ static int fanotify_test_fsid(struct dentry *dentry, __kernel_fsid_t *fsid)
15851585
}
15861586

15871587
/* Check if filesystem can encode a unique fid */
1588-
static int fanotify_test_fid(struct dentry *dentry)
1588+
static int fanotify_test_fid(struct dentry *dentry, unsigned int flags)
15891589
{
1590+
unsigned int mark_type = flags & FANOTIFY_MARK_TYPE_BITS;
1591+
const struct export_operations *nop = dentry->d_sb->s_export_op;
1592+
1593+
/*
1594+
* We need to make sure that the filesystem supports encoding of
1595+
* file handles so user can use name_to_handle_at() to compare fids
1596+
* reported with events to the file handle of watched objects.
1597+
*/
1598+
if (!nop)
1599+
return -EOPNOTSUPP;
1600+
15901601
/*
1591-
* We need to make sure that the file system supports at least
1592-
* encoding a file handle so user can use name_to_handle_at() to
1593-
* compare fid returned with event to the file handle of watched
1594-
* objects. However, even the relaxed AT_HANDLE_FID flag requires
1595-
* at least empty export_operations for ecoding unique file ids.
1602+
* For sb/mount mark, we also need to make sure that the filesystem
1603+
* supports decoding file handles, so user has a way to map back the
1604+
* reported fids to filesystem objects.
15961605
*/
1597-
if (!dentry->d_sb->s_export_op)
1606+
if (mark_type != FAN_MARK_INODE && !nop->fh_to_dentry)
15981607
return -EOPNOTSUPP;
15991608

16001609
return 0;
@@ -1812,7 +1821,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
18121821
if (ret)
18131822
goto path_put_and_out;
18141823

1815-
ret = fanotify_test_fid(path.dentry);
1824+
ret = fanotify_test_fid(path.dentry, flags);
18161825
if (ret)
18171826
goto path_put_and_out;
18181827

0 commit comments

Comments
 (0)