dm flakey: check for null arg_name in parse_features()
authorGoldwyn Rodrigues <rgoldwyn@suse.com>
Mon, 4 Dec 2017 03:14:12 +0000 (21:14 -0600)
committerMike Snitzer <snitzer@redhat.com>
Wed, 17 Jan 2018 14:16:13 +0000 (09:16 -0500)
One can crash dm-flakey by specifying more feature arguments than the
number of features supplied.  Checking for null in arg_name avoids
this.

dmsetup create flakey-test --table "0 66076080 flakey /dev/sdb9 0 0 180 2 drop_writes"

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-flakey.c

index b82cb1ab1eaa338a67800bfdb0c38d36f7913ef2..1b907b15f5c3be312569452ea1476ada54e01db5 100644 (file)
@@ -70,6 +70,11 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
                arg_name = dm_shift_arg(as);
                argc--;
 
+               if (!arg_name) {
+                       ti->error = "Insufficient feature arguments";
+                       return -EINVAL;
+               }
+
                /*
                 * drop_writes
                 */