Skip to content

Commit 8f52979

Browse files
committed
crush: fix crash from invalid 'take' argument
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>
1 parent 687265e commit 8f52979

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎net/ceph/crush/mapper.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,15 @@ int crush_do_rule(const struct crush_map *map,
790790

791791
switch (curstep->op) {
792792
case CRUSH_RULE_TAKE:
793-
w[0] = curstep->arg1;
794-
wsize = 1;
793+
if ((curstep->arg1 >= 0 &&
794+
curstep->arg1 < map->max_devices) ||
795+
(-1-curstep->arg1 < map->max_buckets &&
796+
map->buckets[-1-curstep->arg1])) {
797+
w[0] = curstep->arg1;
798+
wsize = 1;
799+
} else {
800+
dprintk(" bad take value %d\n", curstep->arg1);
801+
}
795802
break;
796803

797804
case CRUSH_RULE_SET_CHOOSE_TRIES:

0 commit comments

Comments
 (0)