linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Yufen Yu <yuyufen@huawei.com>,
	Hou Tao <houtao1@huawei.com>
Subject: Re: [PATCH 1/4] block: fix use-after-free on cached last_lookup partition
Date: Fri, 8 May 2020 09:54:25 +0800	[thread overview]
Message-ID: <20200508015425.GB1360332@T590> (raw)
In-Reply-To: <20200507141626.GA11551@infradead.org>

On Thu, May 07, 2020 at 07:16:26AM -0700, Christoph Hellwig wrote:
> On Thu, May 07, 2020 at 04:52:36PM +0800, Ming Lei wrote:
> >  	for (i = 1; i < ptbl->len; i++) {
> >  		part = rcu_dereference(ptbl->part[i]);
> >  
> >  		if (part && sector_in_part(part, sector)) {
> > +			if (!hd_struct_try_get(part))
> > +				goto exit;
> 
> I think this needs the comment that was in blk_account_io_start to
> explain the logic.  Also no need for the goto, this can just be a break.

OK, not did it because I thought the logic is straightforward.

> 
> > -	rcu_assign_pointer(ptbl->last_lookup, NULL);
> >  	kobject_put(part->holder_dir);
> >  	device_del(part_to_dev(part));
> >  
> > @@ -393,6 +402,7 @@ static struct hd_struct *add_partition(struct gendisk *disk, int partno,
> >  	p->nr_sects = len;
> >  	p->partno = partno;
> >  	p->policy = get_disk_ro(disk);
> > +	p->disk = disk;
> 
> Do we really need this pointer?  Can't we use part_to_disk in the
> free path for some reason?

Looks I did miss this function, :-)

Thanks, 
Ming


  reply	other threads:[~2020-05-08  1:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07  8:52 [PATCH 0/4] block: fix partition use-after-free and optimization Ming Lei
2020-05-07  8:52 ` [PATCH 1/4] block: fix use-after-free on cached last_lookup partition Ming Lei
2020-05-07 14:16   ` Christoph Hellwig
2020-05-08  1:54     ` Ming Lei [this message]
2020-05-07  8:52 ` [PATCH 2/4] block: only define 'nr_sects_seq' in hd_part for 32bit SMP Ming Lei
2020-05-07 14:16   ` Christoph Hellwig
2020-05-07  8:52 ` [PATCH 3/4] block: re-organize fields of 'struct hd_part' Ming Lei
2020-05-07 14:16   ` Christoph Hellwig
2020-05-07  8:52 ` [PATCH 4/4] block: don't hold part0's refcount in IO path Ming Lei
2020-05-07 14:20   ` Christoph Hellwig
2020-05-08  1:59     ` Ming Lei
  -- strict thread matches above, loose matches on Subject: below --
2020-01-09  6:21 [PATCH 0/4] block: fix partition use-after-free and optimization Ming Lei
2020-01-09  6:21 ` [PATCH 1/4] block: fix use-after-free on cached last_lookup partition Ming Lei
2020-02-21  3:05   ` Yufen Yu
2020-02-21  4:03   ` Bart Van Assche
2020-02-21  7:47     ` Ming Lei

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=20200508015425.GB1360332@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=houtao1@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=yuyufen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).