Re: [PATCH 5.10.y stable v2] block: unhash blkdev part inode when the part is deleted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/5/22 8:08 AM, Greg Kroah-Hartman wrote:
> On Mon, Dec 05, 2022 at 09:27:39PM +0800, Ming Lei wrote:
>> 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@xxxxxx/
>>
>> 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@xxxxxxxxxx>
>> Tested-by: Shiwei Cui <cuishw@xxxxxxxxxx>
>> Cc: Christoph Hellwig <hch@xxxxxx>
>> Cc: Jan Kara <jack@xxxxxxx>
>> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
>> ---
>> V2:
>> 	- fix one typo and Shiwei's email format
>>
>>  block/partitions/core.c | 7 +++++++
> 
> I need an ack from the block maintainers/developers to be able to take
> this.

Acked-by: Jens Axboe <axboe@xxxxxxxxx>

-- 
Jens Axboe





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux