aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-10-12 10:55:54 -0400
committerChris Mason <clm@fb.com>2015-10-26 22:38:26 -0400
commit849ef9286f30c88113906dc35f44a499c0cb385d (patch)
tree583d82b294a3825459c960a0315186ec5cd703b5
parentb06c4bf5c874a57254b197f53ddf588e7a24a2bf (diff)
btrfs: check unsupported filters in balance arguments
We don't verify that all the balance filter arguments supplemented by the flags are actually known to the kernel. Thus we let it silently pass and do nothing. At the moment this means only the 'limit' filter, but we're going to add a few more soon so it's better to have that fixed. Also in older stable kernels so that it works with newer userspace tools. Cc: stable@vger.kernel.org # 3.16+ Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--fs/btrfs/ioctl.c5
-rw-r--r--fs/btrfs/volumes.h8
2 files changed, 13 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 4df0f2bd9af7..7375cf2e6bbf 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4691,6 +4691,11 @@ locked:
4691 bctl->flags |= BTRFS_BALANCE_TYPE_MASK; 4691 bctl->flags |= BTRFS_BALANCE_TYPE_MASK;
4692 } 4692 }
4693 4693
4694 if (bctl->flags & ~(BTRFS_BALANCE_ARGS_MASK | BTRFS_BALANCE_TYPE_MASK)) {
4695 ret = -EINVAL;
4696 goto out_bargs;
4697 }
4698
4694do_balance: 4699do_balance:
4695 /* 4700 /*
4696 * Ownership of bctl and mutually_exclusive_operation_running 4701 * Ownership of bctl and mutually_exclusive_operation_running
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 99c208f6718d..b8e64ea984f1 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -381,6 +381,14 @@ struct map_lookup {
381#define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4) 381#define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4)
382#define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5) 382#define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5)
383 383
384#define BTRFS_BALANCE_ARGS_MASK \
385 (BTRFS_BALANCE_ARGS_PROFILES | \
386 BTRFS_BALANCE_ARGS_USAGE | \
387 BTRFS_BALANCE_ARGS_DEVID | \
388 BTRFS_BALANCE_ARGS_DRANGE | \
389 BTRFS_BALANCE_ARGS_VRANGE | \
390 BTRFS_BALANCE_ARGS_LIMIT)
391
384/* 392/*
385 * Profile changing flags. When SOFT is set we won't relocate chunk if 393 * Profile changing flags. When SOFT is set we won't relocate chunk if
386 * it already has the target profile (even though it may be 394 * it already has the target profile (even though it may be