[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f89ae154-d6b7-0a3b-060d-f3131b0c1c1d@huawei.com>
Date: Mon, 10 Feb 2020 10:13:22 +0800
From: "yukuai (C)" <yukuai3@...wei.com>
To: Bart Van Assche <bvanassche@....org>, <axboe@...nel.dk>,
<ming.lei@...hat.com>, <chaitanya.kulkarni@....com>,
<damien.lemoal@....com>, <dhowells@...hat.com>,
<asml.silence@...il.com>, <ajay.joshi@....com>
CC: <linux-block@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<yi.zhang@...wei.com>, <zhangxiaoxu5@...wei.com>,
<luoshijie1@...wei.com>, jan kara <jack@...e.cz>
Subject: Re: [PATCH] block: revert pushing the final release of request_queue
to a workqueue.
On 2020/2/10 9:00, Bart Van Assche wrote:
> Have you already noticed patch "[PATCH] blktrace: Protect q->blk_trace
> with RCU"? If not, have you already tried to verify whether that patch
> fixes the use-after-free detected by syzbot?
I just tested and confirmed the patch didn't fix the problem.
By the way, I think Ming is right about "So release not by wq just
reduces the chance, instead of fixing it completely.", and "move
blk_mq_debugfs_unregister() into blk_unregister_queue()" is a good
choice. However, blk_trace_shutdown() and blk_mq_exit_queue() also
remove some files or dirs, and they may need to move to
blk_unregister_queue().
I tested following patch fixes the problem, however I'm not sure if
move blk_trace_shutdown() and blk_mu_exit_queue() is ok or we should
just move debgfs-related part.
---
block/blk-core.c | 3 ---
block/blk-sysfs.c | 12 ++++++------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 50a5de025d5e..1ab9808e73c7 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -395,9 +395,6 @@ void blk_cleanup_queue(struct request_queue *q)
del_timer_sync(&q->backing_dev_info->laptop_mode_wb_timer);
blk_sync_queue(q);
- if (queue_is_mq(q))
- blk_mq_exit_queue(q);
-
/*
┊* In theory, request pool of sched_tags belongs to request queue.
┊* However, the current implementation requires tag_set for freeing
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index fca9b158f4a0..a0f64d641cb0 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -893,11 +893,6 @@ static void __blk_release_queue(struct work_struct
*work)
if (queue_is_mq(q))
blk_mq_release(q);
- blk_trace_shutdown(q);
-
- if (queue_is_mq(q))
- blk_mq_debugfs_unregister(q);
-
bioset_exit(&q->bio_split);
ida_simple_remove(&blk_queue_ida, q->id);
@@ -1043,8 +1038,13 @@ void blk_unregister_queue(struct gendisk *disk)
┊* Remove the sysfs attributes before unregistering the queue data
┊* structures that can be modified through sysfs.
┊*/
- if (queue_is_mq(q))
+
+ blk_trace_shutdown(q);
+ if (queue_is_mq(q)) {
blk_mq_unregister_dev(disk_to_dev(disk), q);
+ blk_mq_exit_queue(q);
+ blk_mq_debugfs_unregister(q);
+ }
kobject_uevent(&q->kobj, KOBJ_REMOVE);
kobject_del(&q->kobj);
--
2.17.2
Powered by blists - more mailing lists