All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: Christoph Hellwig <hch@lst.de>, Yu Kuai <yukuai1@huaweicloud.com>
Cc: Jens Axboe <axboe@kernel.dk>, Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	dm-devel@redhat.com, linux-block@vger.kernel.org,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH 7/7] block: store the holder kobject in bd_holder_disk
Date: Tue, 1 Nov 2022 21:29:23 +0800	[thread overview]
Message-ID: <51362eda-fd76-ed35-1961-f17d8e9a9d93@huaweicloud.com> (raw)
In-Reply-To: <20221101131830.GA16341@lst.de>

Hi,

在 2022/11/01 21:18, Christoph Hellwig 写道:
> On Tue, Nov 01, 2022 at 07:28:17PM +0800, Yu Kuai wrote:
>> What if bd_holder_dir is already freed here, then uaf can be triggered.
>> Thus bd_holder_dir need to be resed in del_gendisk() if it's reference
>> is dropped to 0, however, kobject apis can't do that...
> 
> Indeed.  I don't think we can simply move the dropping of the reference
> as you suggested as that also implies taking it earlier, and the
> device in the disk is only initialized in add_disk.
> 
> Now what I think we could do is:
> 
>   - hold open_mutex in bd_link_disk_holder as you suggested
>   - check that the bdev inode is hashed inside open_mutex before doing
>     the kobject_get

Yes, that's sounds good, check if inode is hashed is better than
what I did in another thread to introduce a new field.

Thansk,
Kuai
> 
> .
> 


WARNING: multiple messages have this Message-ID (diff)
From: Yu Kuai <yukuai1@huaweicloud.com>
To: Christoph Hellwig <hch@lst.de>, Yu Kuai <yukuai1@huaweicloud.com>
Cc: Jens Axboe <axboe@kernel.dk>, Mike Snitzer <snitzer@kernel.org>,
	linux-block@vger.kernel.org, dm-devel@redhat.com,
	"yukuai \(C\)" <yukuai3@huawei.com>,
	Alasdair Kergon <agk@redhat.com>
Subject: Re: [dm-devel] [PATCH 7/7] block: store the holder kobject in bd_holder_disk
Date: Tue, 1 Nov 2022 21:29:23 +0800	[thread overview]
Message-ID: <51362eda-fd76-ed35-1961-f17d8e9a9d93@huaweicloud.com> (raw)
In-Reply-To: <20221101131830.GA16341@lst.de>

Hi,

在 2022/11/01 21:18, Christoph Hellwig 写道:
> On Tue, Nov 01, 2022 at 07:28:17PM +0800, Yu Kuai wrote:
>> What if bd_holder_dir is already freed here, then uaf can be triggered.
>> Thus bd_holder_dir need to be resed in del_gendisk() if it's reference
>> is dropped to 0, however, kobject apis can't do that...
> 
> Indeed.  I don't think we can simply move the dropping of the reference
> as you suggested as that also implies taking it earlier, and the
> device in the disk is only initialized in add_disk.
> 
> Now what I think we could do is:
> 
>   - hold open_mutex in bd_link_disk_holder as you suggested
>   - check that the bdev inode is hashed inside open_mutex before doing
>     the kobject_get

Yes, that's sounds good, check if inode is hashed is better than
what I did in another thread to introduce a new field.

Thansk,
Kuai
> 
> .
> 

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel

  reply	other threads:[~2022-11-01 13:29 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-30 15:31 fix delayed holder tracking v2 Christoph Hellwig
2022-10-30 15:31 ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 1/7] block: clear ->slave_dir when dropping the main slave_dir reference Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 2/7] dm: remove free_table_devices Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 3/7] dm: cleanup open_table_device Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 4/7] dm: cleanup close_table_device Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 5/7] dm: track per-add_disk holder relations in DM Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-11-09  2:08   ` Yu Kuai
2022-11-09  2:08     ` [dm-devel] " Yu Kuai
2022-11-09  8:26     ` Christoph Hellwig
2022-11-09  8:26       ` [dm-devel] " Christoph Hellwig
2022-11-10 18:09       ` Mike Snitzer
2022-11-10 18:09         ` [dm-devel] " Mike Snitzer
2022-11-10 19:48         ` Mike Snitzer
2022-11-10 19:48           ` Mike Snitzer
2022-11-12  6:23         ` Yu Kuai
2022-11-12  6:23           ` [dm-devel] " Yu Kuai
2022-10-30 15:31 ` [PATCH 6/7] block: remove delayed holder registration Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 7/7] block: store the holder kobject in bd_holder_disk Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-31  1:52   ` Yu Kuai
2022-10-31  1:52     ` [dm-devel] " Yu Kuai
2022-11-01 10:49     ` Christoph Hellwig
2022-11-01 10:49       ` [dm-devel] " Christoph Hellwig
2022-11-01 11:12       ` Yu Kuai
2022-11-01 11:12         ` [dm-devel] " Yu Kuai
2022-11-01 11:21         ` Christoph Hellwig
2022-11-01 11:21           ` [dm-devel] " Christoph Hellwig
2022-11-01 11:28           ` Yu Kuai
2022-11-01 11:28             ` [dm-devel] " Yu Kuai
2022-11-01 13:18             ` Christoph Hellwig
2022-11-01 13:18               ` [dm-devel] " Christoph Hellwig
2022-11-01 13:29               ` Yu Kuai [this message]
2022-11-01 13:29                 ` Yu Kuai

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=51362eda-fd76-ed35-1961-f17d8e9a9d93@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=snitzer@kernel.org \
    --cc=yukuai3@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.