]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/mapper: ensure take bucket value is valid 6626/head
authorSage Weil <sage@redhat.com>
Tue, 13 Oct 2015 13:55:01 +0000 (09:55 -0400)
committerAbhishek Varshney <abhishek.varshney@flipkart.com>
Wed, 18 Nov 2015 07:11:12 +0000 (12:41 +0530)
Ensure that the take argument is a valid bucket ID before indexing the
buckets array.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 93ec538e8a667699876b72459b8ad78966d89c61)

src/crush/mapper.c

index 5fc7d33a6dcc643946e71d19400f3079ee26576e..412e7e83b21a7dea25124c4f73c7c8bc2818590b 100644 (file)
@@ -835,7 +835,8 @@ int crush_do_rule(const struct crush_map *map,
                case CRUSH_RULE_TAKE:
                        if ((curstep->arg1 >= 0 &&
                             curstep->arg1 < map->max_devices) ||
-                           (-1-curstep->arg1 < map->max_buckets &&
+                           (-1-curstep->arg1 >= 0 &&
+                            -1-curstep->arg1 < map->max_buckets &&
                             map->buckets[-1-curstep->arg1])) {
                                w[0] = curstep->arg1;
                                wsize = 1;