* [syzbot] [block?] WARNING: lock held when returning to user space in blk_throtl_init
@ 2026-10-11 15:19 syzbot
2026-11-08 2:21 ` [PATCH] block: release queue freeze lockdep locks under mq_freeze_lock Shuai Liu
0 siblings, 1 reply; 2+ messages in thread
From: syzbot @ 2026-10-11 15:19 UTC (permalink / raw)
To: axboe, linux-block, linux-kernel, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: becb95e45ef0 Add linux-next specific files for 20261009
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=119ea68e580000
kernel config: https://syzkaller.appspot.com/x/.config?x=7400eab0484d1dc
dashboard link: https://syzkaller.appspot.com/bug?extid=1eb53c83ab8b0a0302a6
compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=100e8999580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=159ea68e580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b16b9c03e69c/disk-becb95e4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/78483614b526/vmlinux-becb95e4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e333f1b9fe69/bzImage-becb95e4.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+1eb53c83ab8b0a0302a6@syzkaller.appspotmail.com
null_blk: disk nullb1 created
================================================
WARNING: lock held when returning to user space!
syzkaller #0 Not tainted
------------------------------------------------
syz.0.452/6787 is leaving the kernel with locks still held!
locks held by syz.0.452/6787: 2, last CPU#0:
#0: ffff88803652c190 (&q->q_usage_counter(io)#105){++++}-{0:0}, at: blk_mq_freeze_queue include/linux/blk-mq.h:956 [inline]
#0: ffff88803652c190 (&q->q_usage_counter(io)#105){++++}-{0:0}, at: blk_throtl_init+0x27b/0x420 block/blk-throttle.c:1332
#1: ffff88803652c1c8 (&q->q_usage_counter(queue)#88){+.+.}-{0:0}, at: blk_mq_freeze_queue include/linux/blk-mq.h:956 [inline]
#1: ffff88803652c1c8 (&q->q_usage_counter(queue)#88){+.+.}-{0:0}, at: blk_throtl_init+0x27b/0x420 block/blk-throttle.c:1332
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] block: release queue freeze lockdep locks under mq_freeze_lock
2026-10-11 15:19 [syzbot] [block?] WARNING: lock held when returning to user space in blk_throtl_init syzbot
@ 2026-11-08 2:21 ` Shuai Liu
0 siblings, 0 replies; 2+ messages in thread
From: Shuai Liu @ 2026-11-08 2:21 UTC (permalink / raw)
To: syzbot+1eb53c83ab8b0a0302a6
Cc: axboe, ming.lei, linux-block, linux-kernel, syzkaller-bugs, Shuai Liu
The lockdep model for the queue freeze owner decides whether to acquire
the q_usage_counter io and queue lockdep maps based on
mq_freeze_disk_dead and mq_freeze_queue_dying. These two flags are
re-sampled by blk_freeze_set_owner() whenever the freeze depth drops to
zero, i.e. after the previous owner released its freeze.
blk_mq_unfreeze_queue_nomemrestore() used to release the matching
lockdep locks only after dropping mq_freeze_lock. Between dropping the
lock and reading the live flags a new freeze can run
blk_freeze_set_owner() and flip the flags from false to true if the disk
dies in that window. The original owner then observes the flipped
flags and skips the release, leaking both lockdep maps, which triggers
"WARNING: lock held when returning to user space" with
&q->q_usage_counter(io) and &q->q_usage_counter(queue) still held.
Perform the lockdep release while still holding mq_freeze_lock so that
blk_freeze_set_owner() cannot interleave and the flags observed at
release match the values sampled at acquire time.
Fixes: 6f491a8d4b92 ("block: track disk DEAD state automatically for modeling queue freeze lockdep")
Reported-by: syzbot+1eb53c83ab8b0a0302a6@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=1eb53c83ab8b0a0302a6
Signed-off-by: Shuai Liu <847807867@qq.com>
---
block/blk-mq.c | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 025a799f35b9..db769c7c88ff 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -208,11 +208,10 @@ void blk_mq_freeze_queue_nomemsave(struct request_queue *q)
}
EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_nomemsave);
-bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic)
+/* caller has to hold q->mq_freeze_lock */
+static bool __blk_mq_unfreeze_queue_locked(struct request_queue *q,
+ bool force_atomic)
{
- bool unfreeze;
-
- mutex_lock(&q->mq_freeze_lock);
if (force_atomic)
q->q_usage_counter.data->force_atomic = true;
q->mq_freeze_depth--;
@@ -221,7 +220,15 @@ bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic)
percpu_ref_resurrect(&q->q_usage_counter);
wake_up_all(&q->mq_freeze_wq);
}
- unfreeze = blk_unfreeze_check_owner(q);
+ return blk_unfreeze_check_owner(q);
+}
+
+bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic)
+{
+ bool unfreeze;
+
+ mutex_lock(&q->mq_freeze_lock);
+ unfreeze = __blk_mq_unfreeze_queue_locked(q, force_atomic);
mutex_unlock(&q->mq_freeze_lock);
return unfreeze;
@@ -229,8 +236,19 @@ bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic)
void blk_mq_unfreeze_queue_nomemrestore(struct request_queue *q)
{
- if (__blk_mq_unfreeze_queue(q, false))
+ mutex_lock(&q->mq_freeze_lock);
+ /*
+ * Release the lockdep freeze locks while still holding
+ * mq_freeze_lock. blk_freeze_set_owner() re-samples
+ * mq_freeze_disk_dead/mq_freeze_queue_dying once the freeze depth
+ * reaches zero, and reading the flags after dropping the lock races
+ * with that re-sampling: if the disk died in between, the flags flip
+ * and the release is skipped even though the matching acquire
+ * grabbed the locks, leaking them.
+ */
+ if (__blk_mq_unfreeze_queue_locked(q, false))
blk_unfreeze_release_lock(q);
+ mutex_unlock(&q->mq_freeze_lock);
}
EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue_nomemrestore);
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-08 2:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-11 15:19 [syzbot] [block?] WARNING: lock held when returning to user space in blk_throtl_init syzbot
2026-11-08 2:21 ` [PATCH] block: release queue freeze lockdep locks under mq_freeze_lock Shuai Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®