]> git.baikalelectronics.ru Git - kernel.git/commit
block: set the zone size in blk_revalidate_disk_zones atomically
authorChristoph Hellwig <hch@lst.de>
Tue, 3 Dec 2019 09:39:08 +0000 (10:39 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 3 Dec 2019 17:18:22 +0000 (10:18 -0700)
commit2c51ff05bbd001e256c0f2760b6018fa647032d5
tree0a738d6947054942fedcd44f532d6579976c1c28
parent884edc4ba55e09f07363379ca90150c35b2f197c
block: set the zone size in blk_revalidate_disk_zones atomically

The current zone revalidation code has a major problem in that it
doesn't update the zone size and q->nr_zones atomically, leading
to a short window where an out of bounds access to the zone arrays
is possible.

To fix this move the setting of the zone size into the crticial
sections blk_revalidate_disk_zones so that it gets updated together
with the zone bitmaps and q->nr_zones.  This also slightly simplifies
the caller as it deducts the zone size from the report_zones.

This change also allows to check for a power of two zone size in generic
code.

Reported-by: Hans Holmberg <hans@owltronix.com>
Reviewed-by: Javier González <javier@javigon.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-zoned.c
drivers/block/null_blk_main.c
drivers/scsi/sd_zbc.c