]> git.hungrycats.org Git - linux/commitdiff
btrfs: check unsupported filters in balance arguments
authorDavid Sterba <dsterba@suse.com>
Mon, 12 Oct 2015 14:55:54 +0000 (16:55 +0200)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sat, 17 Oct 2015 03:18:17 +0000 (23:18 -0400)
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>
(cherry picked from commit 8eb934591f8bf584969454a658f629cd06e59f3a)
(cherry picked from commit 186540a8b86bdaa8591661df2f93e1274ef4e410)

fs/btrfs/ioctl.c
fs/btrfs/volumes.h

index 7ed75f55538ec435da036548e5ee0145b0738fc1..a816d9c6f01be05c589f9ce1adb179ba307a0cd9 100644 (file)
@@ -4753,6 +4753,11 @@ locked:
                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
index 95ae9a0671871bd5fada34cf02c79d41c665af96..1ebc3b90daec425c9e68954fbb3fff32bfcb727d 100644 (file)
@@ -377,6 +377,14 @@ struct map_lookup {
 #define BTRFS_BALANCE_ARGS_LIMIT       (1ULL << 5)
 #define BTRFS_BALANCE_ARGS_STRIPES     (1ULL << 6)
 
+#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