Skip to content

Commit a9cb9f4

Browse files
morbidrsasnitm
authored andcommitted
dm: don't call report zones for more than the user requested
Don't call report zones for more zones than the user actually requested, otherwise this can lead to out-of-bounds accesses in the callback functions. Such a situation can happen if the target's ->report_zones() callback function returns 0 because we've reached the end of the target and then restart the report zones on the second target. We're again calling into ->report_zones() and ultimately into the user supplied callback function but when we're not subtracting the number of zones already processed this may lead to out-of-bounds accesses in the user callbacks. Signed-off-by: Johannes Thumshirn <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Fixes: d410035 ("block: rework zone reporting") Cc: [email protected] # v5.5+ Signed-off-by: Mike Snitzer <[email protected]>
1 parent 4cb6f22 commit a9cb9f4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/md/dm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ static int dm_blk_report_zones(struct gendisk *disk, sector_t sector,
503503
}
504504

505505
args.tgt = tgt;
506-
ret = tgt->type->report_zones(tgt, &args, nr_zones);
506+
ret = tgt->type->report_zones(tgt, &args,
507+
nr_zones - args.zone_idx);
507508
if (ret < 0)
508509
goto out;
509510
} while (args.zone_idx < nr_zones &&

0 commit comments

Comments
 (0)