trace/blktrace: fix task hung in blk_trace_remove

Message ID tencent_6D33089EBD1B9C4BEE1B2425C6BAB4BB9F08@qq.com
State New
Headers
Series trace/blktrace: fix task hung in blk_trace_remove |

Commit Message

Edward Adam Davis Jan. 31, 2024, 1:28 p.m. UTC
  Delete critical sections that are time-consuming and protected by other mutexes
to avoid this issue.

Reported-and-tested-by: syzbot+2373f6be3e6de4f92562@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 kernel/trace/blktrace.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Jens Axboe Jan. 31, 2024, 2:54 p.m. UTC | #1
On 1/31/24 6:28 AM, Edward Adam Davis wrote:
> Delete critical sections that are time-consuming and protected by other mutexes
> to avoid this issue.

What is "this issue"?
  

Patch

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index d5d94510afd3..4543be718362 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -313,6 +313,7 @@  static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
 
 static void blk_trace_free(struct request_queue *q, struct blk_trace *bt)
 {
+	mutex_unlock(&q->debugfs_mutex);
 	relay_close(bt->rchan);
 
 	/*
@@ -325,6 +326,7 @@  static void blk_trace_free(struct request_queue *q, struct blk_trace *bt)
 	} else {
 		debugfs_remove(bt->dir);
 	}
+	mutex_lock(&q->debugfs_mutex);
 	free_percpu(bt->sequence);
 	free_percpu(bt->msg_data);
 	kfree(bt);