[3/3] btrfs: use ioctl args support mask for device delete
diff mbox series

Message ID 35813380382186dcd381e759e665f59f77c1f287.1582289899.git.dsterba@suse.com
State New
Headers show
Series
  • Clean up supported flags for ioctls
Related show

Commit Message

David Sterba Feb. 21, 2020, 1:02 p.m. UTC
When the device remove v2 ioctl was added, the full support mask was
added to sanity check the flags. However this would allow to let the
subvolume related flags to be accepted. This is not supposed to happen.

Use the correct support mask, which means that now any of
BTRFS_SUBVOL_CREATE_ASYNC, BTRFS_SUBVOL_RDONLY or
BTRFS_SUBVOL_QGROUP_INHERIT will be rejected as ENOTSUPP. Though this is
a user-visible change, specifying subvolume flags for device deletion
does not make sense and there are hopefully no applications doing that.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ioctl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Marcos Paulo de Souza Feb. 21, 2020, 1:22 p.m. UTC | #1
On Fri, 2020-02-21 at 14:02 +0100, David Sterba wrote:
> When the device remove v2 ioctl was added, the full support mask was
> added to sanity check the flags. However this would allow to let the
> subvolume related flags to be accepted. This is not supposed to
> happen.
> 
> Use the correct support mask, which means that now any of
> BTRFS_SUBVOL_CREATE_ASYNC, BTRFS_SUBVOL_RDONLY or
> BTRFS_SUBVOL_QGROUP_INHERIT will be rejected as ENOTSUPP. Though this
> is
> a user-visible change, specifying subvolume flags for device deletion
> does not make sense and there are hopefully no applications doing
> that.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  fs/btrfs/ioctl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index a7872cacd0aa..cd2d11dcd477 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3075,8 +3075,7 @@ static long btrfs_ioctl_rm_dev_v2(struct file
> *file, void __user *arg)
>  		goto err_drop;
>  	}
>  
> -	/* Check for compatibility reject unknown flags */
> -	if (vol_args->flags & ~BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED) {
> +	if (vol_args->flags & ~BTRFS_DEVICE_REMOVE_ARGS_MASK) {
>  		ret = -EOPNOTSUPP;
>  		goto out;
>  	}

Looks good to me,
Reviewed-by: Marcos Paulo de Souza <mpdesouza@suse.com>

Patch
diff mbox series

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a7872cacd0aa..cd2d11dcd477 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3075,8 +3075,7 @@  static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg)
 		goto err_drop;
 	}
 
-	/* Check for compatibility reject unknown flags */
-	if (vol_args->flags & ~BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED) {
+	if (vol_args->flags & ~BTRFS_DEVICE_REMOVE_ARGS_MASK) {
 		ret = -EOPNOTSUPP;
 		goto out;
 	}