diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 4df0f2bd9af7964c6e5d03ac700721cddaffb103..7375cf2e6bbf9952603138350ef43538e63a04cb 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4691,6 +4691,11 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) bctl->flags |= BTRFS_BALANCE_TYPE_MASK; } + if (bctl->flags & ~(BTRFS_BALANCE_ARGS_MASK | BTRFS_BALANCE_TYPE_MASK)) { + ret = -EINVAL; + goto out_bargs; + } + do_balance: /* * Ownership of bctl and mutually_exclusive_operation_running diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 99c208f6718d03353364d198ffa292f8bfa25a06..b8e64ea984f18e3b8d38630358c1e8122a229cb8 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -381,6 +381,14 @@ struct map_lookup { #define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4) #define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5) +#define BTRFS_BALANCE_ARGS_MASK \ + (BTRFS_BALANCE_ARGS_PROFILES | \ + BTRFS_BALANCE_ARGS_USAGE | \ + BTRFS_BALANCE_ARGS_DEVID | \ + BTRFS_BALANCE_ARGS_DRANGE | \ + BTRFS_BALANCE_ARGS_VRANGE | \ + BTRFS_BALANCE_ARGS_LIMIT) + /* * Profile changing flags. When SOFT is set we won't relocate chunk if * it already has the target profile (even though it may be