Commit e4fed17a authored by Christian Brauner's avatar Christian Brauner Committed by David Sterba

btrfs: allow idmapped SET_RECEIVED_SUBVOL ioctls

The SET_RECEIVED_SUBVOL ioctls are used to set information about
a received subvolume. Make it possible to set information about a
received subvolume 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: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent aabb34e7
...@@ -4448,6 +4448,7 @@ static long btrfs_ioctl_quota_rescan_wait(struct btrfs_fs_info *fs_info, ...@@ -4448,6 +4448,7 @@ static long btrfs_ioctl_quota_rescan_wait(struct btrfs_fs_info *fs_info,
} }
static long _btrfs_ioctl_set_received_subvol(struct file *file, static long _btrfs_ioctl_set_received_subvol(struct file *file,
struct user_namespace *mnt_userns,
struct btrfs_ioctl_received_subvol_args *sa) struct btrfs_ioctl_received_subvol_args *sa)
{ {
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
...@@ -4459,7 +4460,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file, ...@@ -4459,7 +4460,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
int ret = 0; int ret = 0;
int received_uuid_changed; int received_uuid_changed;
if (!inode_owner_or_capable(&init_user_ns, inode)) if (!inode_owner_or_capable(mnt_userns, inode))
return -EPERM; return -EPERM;
ret = mnt_want_write_file(file); ret = mnt_want_write_file(file);
...@@ -4564,7 +4565,7 @@ static long btrfs_ioctl_set_received_subvol_32(struct file *file, ...@@ -4564,7 +4565,7 @@ static long btrfs_ioctl_set_received_subvol_32(struct file *file,
args64->rtime.nsec = args32->rtime.nsec; args64->rtime.nsec = args32->rtime.nsec;
args64->flags = args32->flags; args64->flags = args32->flags;
ret = _btrfs_ioctl_set_received_subvol(file, args64); ret = _btrfs_ioctl_set_received_subvol(file, file_mnt_user_ns(file), args64);
if (ret) if (ret)
goto out; goto out;
...@@ -4598,7 +4599,7 @@ static long btrfs_ioctl_set_received_subvol(struct file *file, ...@@ -4598,7 +4599,7 @@ static long btrfs_ioctl_set_received_subvol(struct file *file,
if (IS_ERR(sa)) if (IS_ERR(sa))
return PTR_ERR(sa); return PTR_ERR(sa);
ret = _btrfs_ioctl_set_received_subvol(file, sa); ret = _btrfs_ioctl_set_received_subvol(file, file_mnt_user_ns(file), sa);
if (ret) if (ret)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment