]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ceph: add owner/capability checks for CEPH_IOC_SET_LAYOUT*
authorMax Kellermann <max.kellermann@ionos.com>
Tue, 21 Jul 2026 06:20:46 +0000 (08:20 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 23 Jul 2026 18:29:42 +0000 (20:29 +0200)
These permission checks were already missing in the initial
impementation of these ioctls.  This Ceph allows any user who owns a
file descriptor to manipulate the layout of any file, even if they
don't have write permissions.

It might be a good idea to guard other ioctls with permission checks
as well or even disallow regular users (even if they own the file) to
manipulate layout settings completely, as this may be abused to DoS
the Ceph servers, but right now, I find it most urgent to have setter
checks at all.

Cc: stable@vger.kernel.org
Fixes: 8f4e91dee2a2 ("ceph: ioctls")
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Reviewed-by: Xiubo Li <xiubo.li@clyso.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/ioctl.c

index 15cde055f3da13e2daf682d6f8e189700b303500..de07f19b0caa3baa668899d6f6d6725f46d35ff5 100644 (file)
@@ -72,6 +72,9 @@ 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))
+               return -EACCES;
+
        if (copy_from_user(&l, arg, sizeof(l)))
                return -EFAULT;
 
@@ -142,6 +145,9 @@ 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))
+               return -EACCES;
+
        /* copy and validate */
        if (copy_from_user(&l, arg, sizeof(l)))
                return -EFAULT;