]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
block: RCU protect disk->conv_zones_bitmap
authorDamien Le Moal <dlemoal@kernel.org>
Thu, 7 Nov 2024 06:42:59 +0000 (15:42 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 19:03:35 +0000 (20:03 +0100)
commit493326c4f10cc71a42c27fdc97ce112182ee4cbc
tree545d7f4c35a96d8889b53736aa61762787bc522f
parentbe54e6e0f93a39a9c00478d70d12956a5f3d5b9b
block: RCU protect disk->conv_zones_bitmap

[ Upstream commit d7cb6d7414ea1b33536fa6d11805cb8dceec1f97 ]

Ensure that a disk revalidation changing the conventional zones bitmap
of a disk does not cause invalid memory references when using the
disk_zone_is_conv() helper by RCU protecting the disk->conv_zones_bitmap
pointer.

disk_zone_is_conv() is modified to operate under the RCU read lock and
the function disk_set_conv_zones_bitmap() is added to update a disk
conv_zones_bitmap pointer using rcu_replace_pointer() with the disk
zone_wplugs_lock spinlock held.

disk_free_zone_resources() is modified to call
disk_update_zone_resources() with a NULL bitmap pointer to free the disk
conv_zones_bitmap. disk_set_conv_zones_bitmap() is also used in
disk_update_zone_resources() to set the new (revalidated) bitmap and
free the old one.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20241107064300.227731-2-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-zoned.c
include/linux/blkdev.h