]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
crush: fix crash from invalid 'take' argument
authorIlya Dryomov <idryomov@gmail.com>
Fri, 12 Jun 2015 08:20:03 +0000 (11:20 +0300)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 25 Jun 2015 08:49:31 +0000 (11:49 +0300)
Verify that the 'take' argument is a valid device or bucket.
Otherwise ignore it (do not add the value to the working vector).

Reflects ceph.git commit 9324d0a1af61e1c234cc48e2175b4e6320fff8f4.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
net/ceph/crush/mapper.c

index 5b47736d27d94584bf33b2e60af56b5e76fc141c..7568cb59b9e5be3ac7e455333e6e4ebc8b2187cd 100644 (file)
@@ -790,8 +790,15 @@ int crush_do_rule(const struct crush_map *map,
 
                switch (curstep->op) {
                case CRUSH_RULE_TAKE:
-                       w[0] = curstep->arg1;
-                       wsize = 1;
+                       if ((curstep->arg1 >= 0 &&
+                            curstep->arg1 < map->max_devices) ||
+                           (-1-curstep->arg1 < map->max_buckets &&
+                            map->buckets[-1-curstep->arg1])) {
+                               w[0] = curstep->arg1;
+                               wsize = 1;
+                       } else {
+                               dprintk(" bad take value %d\n", curstep->arg1);
+                       }
                        break;
 
                case CRUSH_RULE_SET_CHOOSE_TRIES: