-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEq1nRK9aeMoq1VSgcnJ2qBz9kQNkFAmUyw0wACgkQnJ2qBz9k
 QNknFgf/TMbqrnLyro0JUY6w4b9mgXTGFqqnaSuopOGK31vlpfiNR6mYw+vGv82E
 FcN4CSQFBIK8v7DU4pgCzbD1OxGIdJuWz7tjnI4ntr/jMM+3pqqKYhu+VkKInrBB
 HEIMe/WjM0/LbX/wid6xdT3Bcz6lbAySXJFVtxU45umkuv8RGODCAr6Gf1jX3q7m
 LsIv8ESCmau5hyesp1Te4N8bv7dK8x3FPpaX12BB8DkuRlaqmzwHXc0ExpMRhII8
 LBllG2rUIu2GNx8AqWULw9LyBsNaZSeAF2iUl5taXaDXw8Js8eQzH/Y+wS5KaJNa
 M7kszLlAByav/MSuUWWJHOqwgMhhDQ==
 =bOXL
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2023-10-20 14:00:05 -07:00
commit 0e97fd2910

View file

@ -1585,16 +1585,25 @@ static int fanotify_test_fsid(struct dentry *dentry, __kernel_fsid_t *fsid)
}
/* Check if filesystem can encode a unique fid */
static int fanotify_test_fid(struct dentry *dentry)
static int fanotify_test_fid(struct dentry *dentry, unsigned int flags)
{
unsigned int mark_type = flags & FANOTIFY_MARK_TYPE_BITS;
const struct export_operations *nop = dentry->d_sb->s_export_op;
/*
* We need to make sure that the file system supports at least
* encoding a file handle so user can use name_to_handle_at() to
* compare fid returned with event to the file handle of watched
* objects. However, even the relaxed AT_HANDLE_FID flag requires
* at least empty export_operations for ecoding unique file ids.
* We need to make sure that the filesystem supports encoding of
* file handles so user can use name_to_handle_at() to compare fids
* reported with events to the file handle of watched objects.
*/
if (!dentry->d_sb->s_export_op)
if (!nop)
return -EOPNOTSUPP;
/*
* For sb/mount mark, we also need to make sure that the filesystem
* supports decoding file handles, so user has a way to map back the
* reported fids to filesystem objects.
*/
if (mark_type != FAN_MARK_INODE && !nop->fh_to_dentry)
return -EOPNOTSUPP;
return 0;
@ -1812,7 +1821,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
if (ret)
goto path_put_and_out;
ret = fanotify_test_fid(path.dentry);
ret = fanotify_test_fid(path.dentry, flags);
if (ret)
goto path_put_and_out;