public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ming Lei <ming.lei@redhat.com>
Cc: stable@vger.kernel.org, linux-block@vger.kernel.org,
	Shiwei Cui <cuishw@inspur.com>, Christoph Hellwig <hch@lst.de>,
	Jan Kara <jack@suse.cz>
Subject: Re: [PATCH 5.10.y stable v2] block: unhash blkdev part inode when the part is deleted
Date: Mon, 5 Dec 2022 08:19:23 -0700	[thread overview]
Message-ID: <50de97fe-43f1-188f-511a-f29611944ce7@kernel.dk> (raw)
In-Reply-To: <Y44JWBw9opr2HVyN@kroah.com>

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@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>
>> ---
>> 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@kernel.dk>

-- 
Jens Axboe



  reply	other threads:[~2022-12-05 15:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 13:27 [PATCH 5.10.y stable v2] block: unhash blkdev part inode when the part is deleted Ming Lei
2022-12-05 13:29 ` kernel test robot
2022-12-05 15:08 ` Greg Kroah-Hartman
2022-12-05 15:19   ` Jens Axboe [this message]
2022-12-05 16:36     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50de97fe-43f1-188f-511a-f29611944ce7@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=cuishw@inspur.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox