From: Christian Brauner Date: Tue, 27 Jul 2021 10:48:56 +0000 (+0200) Subject: btrfs: allow idmapped SUBVOL_SETFLAGS ioctl X-Git-Tag: Ubuntu-5.15.0-12.12~1981^2~9 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=39e1674ff0351f6a47d3105e51bb1f9c72b3f20e;p=mirror_ubuntu-jammy-kernel.git btrfs: allow idmapped SUBVOL_SETFLAGS ioctl Setting flags on subvolumes or snapshots are core features of btrfs. The SUBVOL_SETFLAGS ioctl is especially important as it allows to make subvolumes and snapshots read-only or read-write. Allow setting flags on btrfs subvolumes and snapshots on idmapped mounts. This is a fairly straightforward operation since all the permission checking helpers are already capable of handling idmapped mounts. So we just need to pass down the mount's userns. Reviewed-by: Josef Bacik Signed-off-by: Christian Brauner Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index aa60a9578747..9d54149bad6e 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1988,7 +1988,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file, u64 flags; int ret = 0; - if (!inode_owner_or_capable(&init_user_ns, inode)) + if (!inode_owner_or_capable(file_mnt_user_ns(file), inode)) return -EPERM; ret = mnt_want_write_file(file);