]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ceph: use the mount idmap for the owner checks in the SET_LAYOUT ioctls
authorZhan Xusheng <zhanxusheng@xiaomi.com>
Mon, 27 Jul 2026 01:47:44 +0000 (09:47 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 12 Aug 2026 19:21:41 +0000 (21:21 +0200)
ceph_ioctl_set_layout() and ceph_ioctl_set_layout_policy() call
inode_owner_or_capable() with &nop_mnt_idmap instead of the idmap of the
mount the ioctl was issued on.

CephFS supports idmapped mounts (FS_ALLOW_IDMAP), so on such a mount this
compares the caller's fsuid against the unmapped on-disk owner rather than
the mapped owner: the actual owner can be wrongly denied with -EACCES and
an unrelated caller wrongly allowed.  Both functions already have the
struct file, so use file_mnt_idmap(file) instead.

Cc: stable@vger.kernel.org
Fixes: cee38bbf5556 ("ceph: add owner/capability checks for CEPH_IOC_SET_LAYOUT*")
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Reviewed-by: Xiubo Li <xiubo.li@clyso.com>
Reviewed-by: Alex Markuze <amarkuze@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/ioctl.c

index de07f19b0caa3baa668899d6f6d6725f46d35ff5..12cb50e0a1665dec866eee405b081f970e89351a 100644 (file)
@@ -72,7 +72,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
        struct ceph_ioctl_layout nl;
        int err;
 
-       if (!inode_owner_or_capable(&nop_mnt_idmap, inode))
+       if (!inode_owner_or_capable(file_mnt_idmap(file), inode))
                return -EACCES;
 
        if (copy_from_user(&l, arg, sizeof(l)))
@@ -145,7 +145,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
        int err;
        struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(inode->i_sb)->mdsc;
 
-       if (!inode_owner_or_capable(&nop_mnt_idmap, inode))
+       if (!inode_owner_or_capable(file_mnt_idmap(file), inode))
                return -EACCES;
 
        /* copy and validate */