[PATCH] trace/blktrace: fix task hung in blk_trace_remove
From: Edward Adam Davis
Date: Wed Jan 31 2024 - 08:34:44 EST
Delete critical sections that are time-consuming and protected by other mutexes
to avoid this issue.
Reported-and-tested-by: syzbot+2373f6be3e6de4f92562@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Edward Adam Davis <eadavis@xxxxxx>
---
kernel/trace/blktrace.c | 2 ++
1 file changed, 2 insertions(+)
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);
--
2.43.0