linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>,
	"Christoph Hellwig" <hch@lst.de>
Cc: <linux-block@vger.kernel.org>,
	<syzbot+77ba3d171a25c56756ea@syzkaller.appspotmail.com>
Subject: Re: [PATCH] blk-mq: fix use-after-free in blk_mq_exit_sched
Date: Tue, 15 Jun 2021 11:02:29 +0100	[thread overview]
Message-ID: <2c2fd2b2-c622-15dc-58f6-c588cab4f79d@huawei.com> (raw)
In-Reply-To: <YMfTBagmPCHGkhYa@T590>

>> Reported-by:syzbot+77ba3d171a25c56756ea@syzkaller.appspotmail.com
>> Fixes: d97e594c5166 ("blk-mq: Use request queue-wide tags for tagset-wide sbitmap")
>> Cc: John Garry<john.garry@huawei.com>
>> Signed-off-by: Ming Lei<ming.lei@redhat.com>
Tested-by: John Garry <john.garry@huawei.com>
Reviewed-by: John Garry <john.garry@huawei.com>

 >> ---
>>   block/blk-mq-sched.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
>> index a9182d2f8ad3..80273245d11a 100644
>> --- a/block/blk-mq-sched.c
>> +++ b/block/blk-mq-sched.c
>> @@ -680,6 +680,7 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e)
>>   {
>>   	struct blk_mq_hw_ctx *hctx;
>>   	unsigned int i;
>> +	unsigned int flags = 0;
>>   
>>   	queue_for_each_hw_ctx(q, hctx, i) {
>>   		blk_mq_debugfs_unregister_sched_hctx(hctx);
>> @@ -687,12 +688,13 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e)
>>   			e->type->ops.exit_hctx(hctx, i);
>>   			hctx->sched_data = NULL;
>>   		}
>> +		flags = hctx->flags;
>>   	}
>>   	blk_mq_debugfs_unregister_sched(q);
>>   	if (e->type->ops.exit_sched)
>>   		e->type->ops.exit_sched(e);
>>   	blk_mq_sched_tags_teardown(q);
>> -	if (blk_mq_is_sbitmap_shared(q->tag_set->flags))
>> +	if (blk_mq_is_sbitmap_shared(flags))

I suppose we could also have this also, but not nice to snoop around 
sbitmap internals:
	if (q->sched_bitmap_tags.sb.map)
		blk_mq_exit_sched_shared_sbitmap(q);

>>   		blk_mq_exit_sched_shared_sbitmap(q);
>>   	q->elevator = NULL;
>>   }


Thanks,
John



  reply	other threads:[~2021-06-15 10:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09  6:30 [PATCH] blk-mq: fix use-after-free in blk_mq_exit_sched Ming Lei
2021-06-09  8:59 ` John Garry
2021-06-09 10:16   ` Ming Lei
2021-06-09 11:42     ` John Garry
2021-06-14 22:07 ` Ming Lei
2021-06-15 10:02   ` John Garry [this message]
2021-06-18  6:03     ` Ming Lei
2021-06-18 14:50 ` Jens Axboe

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=2c2fd2b2-c622-15dc-58f6-c588cab4f79d@huawei.com \
    --to=john.garry@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=syzbot+77ba3d171a25c56756ea@syzkaller.appspotmail.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).