summaryrefslogtreecommitdiff
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2022-12-05 21:27:39 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-08 11:23:59 +0100
commit5f2f775605917aa5087ee5c6f3339da94c100679 (patch)
tree380dc8811adb3e532a369e8061d4e0929f5166f0 /kernel/sysctl.c
parenta82869ac52f3d9db4b2cf8fd41edc2dee7a75a61 (diff)
block: unhash blkdev part inode when the part is deleted
v5.11 changes the blkdev lookup mechanism completely since commit 22ae8ce8b892 ("block: simplify bdev/disk lookup in blkdev_get"), and small part of the change is to unhash part bdev inode when deleting partition. Turns out this kind of change does fix one nasty issue in case of BLOCK_EXT_MAJOR: 1) when one partition is deleted & closed, disk_put_part() is always called before bdput(bdev), see blkdev_put(); so the part's devt can be freed & re-used before the inode is dropped 2) then new partition with same devt can be created just before the inode in 1) is dropped, then the old inode/bdev structurein 1) is re-used for this new partition, this way causes use-after-free and kernel panic. It isn't possible to backport the whole big patchset of "merge struct block_device and struct hd_struct v4" for addressing this issue. https://lore.kernel.org/linux-block/20201128161510.347752-1-hch@lst.de/ So fixes it by unhashing part bdev in delete_partition(), and this way is actually aligned with v5.11+'s behavior. Reported-by: Shiwei Cui <cuishw@inspur.com> Tested-by: Shiwei Cui <cuishw@inspur.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Ming Lei <ming.lei@redhat.com> Acked-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'kernel/sysctl.c')
0 files changed, 0 insertions, 0 deletions