lkml.org 
[lkml]   [2020]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] block: revert pushing the final release of request_queue to a workqueue.
From
Date
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

\
 
 \ /
  Last update: 2020-02-10 03:14    [W:0.096 / U:3.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site