* [syzbot] [block?] possible deadlock in elv_iosched_store
@ 2025-03-28 14:37 syzbot
2025-03-29 1:59 ` Ming Lei
2025-03-29 2:01 ` Ming Lei
0 siblings, 2 replies; 7+ messages in thread
From: syzbot @ 2025-03-28 14:37 UTC (permalink / raw)
To: axboe, linux-block, linux-kernel, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 1a9239bb4253 Merge tag 'net-next-6.15' of git://git.kernel..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1384b43f980000
kernel config: https://syzkaller.appspot.com/x/.config?x=c7163a109ac459a8
dashboard link: https://syzkaller.appspot.com/bug?extid=4c7e0f9b94ad65811efb
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=178cfa4c580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a8ca4c580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/fc7dc9f0d9a7/disk-1a9239bb.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f555a3ae03d3/vmlinux-1a9239bb.xz
kernel image: https://storage.googleapis.com/syzbot-assets/55f6ea74eaf2/bzImage-1a9239bb.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+4c7e0f9b94ad65811efb@syzkaller.appspotmail.com
======================================================
WARNING: possible circular locking dependency detected
6.14.0-syzkaller-05877-g1a9239bb4253 #0 Not tainted
------------------------------------------------------
syz-executor192/5823 is trying to acquire lock:
ffff888144302cd8 (&q->elevator_lock){+.+.}-{4:4}, at: elv_iosched_store+0x201/0x5f0 block/elevator.c:735
but task is already holding lock:
ffff8881443027a8 (&q->q_usage_counter(io)#58){++++}-{0:0}, at: blk_mq_freeze_queue_nomemsave+0x15/0x20 block/blk-mq.c:215
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&q->q_usage_counter(io)#58){++++}-{0:0}:
blk_alloc_queue+0x619/0x760 block/blk-core.c:461
blk_mq_alloc_queue+0x179/0x290 block/blk-mq.c:4349
__blk_mq_alloc_disk+0x29/0x120 block/blk-mq.c:4396
nbd_dev_add+0x49d/0xbb0 drivers/block/nbd.c:1933
nbd_init+0x181/0x320 drivers/block/nbd.c:2670
do_one_initcall+0x120/0x6e0 init/main.c:1257
do_initcall_level init/main.c:1319 [inline]
do_initcalls init/main.c:1335 [inline]
do_basic_setup init/main.c:1354 [inline]
kernel_init_freeable+0x5c2/0x900 init/main.c:1567
kernel_init+0x1c/0x2b0 init/main.c:1457
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:153
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
-> #1 (fs_reclaim){+.+.}-{0:0}:
__fs_reclaim_acquire mm/page_alloc.c:3853 [inline]
fs_reclaim_acquire+0x102/0x150 mm/page_alloc.c:3867
might_alloc include/linux/sched/mm.h:318 [inline]
xa_insert include/linux/xarray.h:783 [inline]
blk_mq_init_hctx block/blk-mq.c:3924 [inline]
blk_mq_alloc_and_init_hctx+0x503/0x11c0 block/blk-mq.c:4457
blk_mq_realloc_hw_ctxs+0x8f6/0xc00 block/blk-mq.c:4486
blk_mq_init_allocated_queue+0x3af/0x1230 block/blk-mq.c:4540
blk_mq_alloc_queue+0x1c2/0x290 block/blk-mq.c:4353
__blk_mq_alloc_disk+0x29/0x120 block/blk-mq.c:4396
loop_add+0x496/0xb70 drivers/block/loop.c:2067
loop_init+0x164/0x270 drivers/block/loop.c:2302
do_one_initcall+0x120/0x6e0 init/main.c:1257
do_initcall_level init/main.c:1319 [inline]
do_initcalls init/main.c:1335 [inline]
do_basic_setup init/main.c:1354 [inline]
kernel_init_freeable+0x5c2/0x900 init/main.c:1567
kernel_init+0x1c/0x2b0 init/main.c:1457
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:153
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
-> #0 (&q->elevator_lock){+.+.}-{4:4}:
check_prev_add kernel/locking/lockdep.c:3166 [inline]
check_prevs_add kernel/locking/lockdep.c:3285 [inline]
validate_chain kernel/locking/lockdep.c:3909 [inline]
__lock_acquire+0x1173/0x1ba0 kernel/locking/lockdep.c:5235
lock_acquire kernel/locking/lockdep.c:5866 [inline]
lock_acquire+0x179/0x350 kernel/locking/lockdep.c:5823
__mutex_lock_common kernel/locking/mutex.c:587 [inline]
__mutex_lock+0x19a/0xb00 kernel/locking/mutex.c:732
elv_iosched_store+0x201/0x5f0 block/elevator.c:735
queue_attr_store+0x270/0x310 block/blk-sysfs.c:799
sysfs_kf_write+0x117/0x170 fs/sysfs/file.c:139
kernfs_fop_write_iter+0x349/0x510 fs/kernfs/file.c:334
iter_file_splice_write+0x91c/0x1150 fs/splice.c:738
do_splice_from fs/splice.c:935 [inline]
direct_splice_actor+0x18f/0x6c0 fs/splice.c:1158
splice_direct_to_actor+0x342/0xa30 fs/splice.c:1102
do_splice_direct_actor fs/splice.c:1201 [inline]
do_splice_direct+0x174/0x240 fs/splice.c:1227
do_sendfile+0xafd/0xe50 fs/read_write.c:1368
__do_sys_sendfile64 fs/read_write.c:1429 [inline]
__se_sys_sendfile64 fs/read_write.c:1415 [inline]
__x64_sys_sendfile64+0x1d8/0x220 fs/read_write.c:1415
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
other info that might help us debug this:
Chain exists of:
&q->elevator_lock --> fs_reclaim --> &q->q_usage_counter(io)#58
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&q->q_usage_counter(io)#58);
lock(fs_reclaim);
lock(&q->q_usage_counter(io)#58);
lock(&q->elevator_lock);
*** DEADLOCK ***
5 locks held by syz-executor192/5823:
#0: ffff888035bd2420 (sb_writers#7){.+.+}-{0:0}, at: splice_direct_to_actor+0x342/0xa30 fs/splice.c:1102
#1: ffff888033e17088 (&of->mutex){+.+.}-{4:4}, at: kernfs_fop_write_iter+0x287/0x510 fs/kernfs/file.c:325
#2: ffff8880258933c8 (kn->active#47){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x2aa/0x510 fs/kernfs/file.c:326
#3: ffff8881443027a8 (&q->q_usage_counter(io)#58){++++}-{0:0}, at: blk_mq_freeze_queue_nomemsave+0x15/0x20 block/blk-mq.c:215
#4: ffff8881443027e0 (&q->q_usage_counter(queue)#10){+.+.}-{0:0}, at: blk_mq_freeze_queue_nomemsave+0x15/0x20 block/blk-mq.c:215
stack backtrace:
CPU: 0 UID: 0 PID: 5823 Comm: syz-executor192 Not tainted 6.14.0-syzkaller-05877-g1a9239bb4253 #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
print_circular_bug+0x275/0x350 kernel/locking/lockdep.c:2079
check_noncircular+0x14c/0x170 kernel/locking/lockdep.c:2211
check_prev_add kernel/locking/lockdep.c:3166 [inline]
check_prevs_add kernel/locking/lockdep.c:3285 [inline]
validate_chain kernel/locking/lockdep.c:3909 [inline]
__lock_acquire+0x1173/0x1ba0 kernel/locking/lockdep.c:5235
lock_acquire kernel/locking/lockdep.c:5866 [inline]
lock_acquire+0x179/0x350 kernel/locking/lockdep.c:5823
__mutex_lock_common kernel/locking/mutex.c:587 [inline]
__mutex_lock+0x19a/0xb00 kernel/locking/mutex.c:732
elv_iosched_store+0x201/0x5f0 block/elevator.c:735
queue_attr_store+0x270/0x310 block/blk-sysfs.c:799
sysfs_kf_write+0x117/0x170 fs/sysfs/file.c:139
kernfs_fop_write_iter+0x349/0x510 fs/kernfs/file.c:334
iter_file_splice_write+0x91c/0x1150 fs/splice.c:738
do_splice_from fs/splice.c:935 [inline]
direct_splice_actor+0x18f/0x6c0 fs/splice.c:1158
splice_direct_to_actor+0x342/0xa30 fs/splice.c:1102
do_splice_direct_actor fs/splice.c:1201 [inline]
do_splice_direct+0x174/0x240 fs/splice.c:1227
do_sendfile+0xafd/0xe50 fs/read_write.c:1368
__do_sys_sendfile64 fs/read_write.c:1429 [inline]
__se_sys_sendfile64 fs/read_write.c:1415 [inline]
__x64_sys_sendfile64+0x1d8/0x220 fs/read_write.c:1415
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7ff2c3abb2e9
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fffc4e88b88 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 00007fffc4e88d58 RCX: 00007ff2c3abb2e9
RDX: 0000000000000000 RSI: 0000000000000003 RDI: 0000000000000003
RBP: 00007ff2c3b2e610 R08: 0000000000000000 R09: 00007fffc4e88d58
R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fffc4e88d48 R14: 0000000000000001 R15: 0000
---
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] 7+ messages in thread
* Re: [syzbot] [block?] possible deadlock in elv_iosched_store
2025-03-28 14:37 [syzbot] [block?] possible deadlock in elv_iosched_store syzbot
@ 2025-03-29 1:59 ` Ming Lei
2025-04-01 11:53 ` Nilay Shroff
2025-03-29 2:01 ` Ming Lei
1 sibling, 1 reply; 7+ messages in thread
From: Ming Lei @ 2025-03-29 1:59 UTC (permalink / raw)
To: syzbot; +Cc: axboe, linux-block, linux-kernel, syzkaller-bugs, Nilay Shroff
On Fri, Mar 28, 2025 at 07:37:25AM -0700, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 1a9239bb4253 Merge tag 'net-next-6.15' of git://git.kernel..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1384b43f980000
> kernel config: https://syzkaller.appspot.com/x/.config?x=c7163a109ac459a8
> dashboard link: https://syzkaller.appspot.com/bug?extid=4c7e0f9b94ad65811efb
> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=178cfa4c580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a8ca4c580000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/fc7dc9f0d9a7/disk-1a9239bb.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/f555a3ae03d3/vmlinux-1a9239bb.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/55f6ea74eaf2/bzImage-1a9239bb.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+4c7e0f9b94ad65811efb@syzkaller.appspotmail.com
>
...
>
> 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.
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ae8494d88897..d7a103dc258b 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4465,14 +4465,12 @@ static struct blk_mq_hw_ctx *blk_mq_alloc_and_init_hctx(
return NULL;
}
-static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
- struct request_queue *q)
+static void __blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
+ struct request_queue *q)
{
struct blk_mq_hw_ctx *hctx;
unsigned long i, j;
- /* protect against switching io scheduler */
- mutex_lock(&q->elevator_lock);
for (i = 0; i < set->nr_hw_queues; i++) {
int old_node;
int node = blk_mq_get_hctx_node(set, i);
@@ -4505,7 +4503,19 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
xa_for_each_start(&q->hctx_table, j, hctx, j)
blk_mq_exit_hctx(q, set, hctx, j);
- mutex_unlock(&q->elevator_lock);
+}
+
+static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
+ struct request_queue *q, bool lock)
+{
+ if (lock) {
+ /* protect against switching io scheduler */
+ mutex_lock(&q->elevator_lock);
+ __blk_mq_realloc_hw_ctxs(set, q);
+ mutex_unlock(&q->elevator_lock);
+ } else {
+ __blk_mq_realloc_hw_ctxs(set, q);
+ }
/* unregister cpuhp callbacks for exited hctxs */
blk_mq_remove_hw_queues_cpuhp(q);
@@ -4537,7 +4547,7 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
xa_init(&q->hctx_table);
- blk_mq_realloc_hw_ctxs(set, q);
+ blk_mq_realloc_hw_ctxs(set, q, false);
if (!q->nr_hw_queues)
goto err_hctxs;
@@ -5033,7 +5043,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
fallback:
blk_mq_update_queue_map(set);
list_for_each_entry(q, &set->tag_list, tag_set_list) {
- blk_mq_realloc_hw_ctxs(set, q);
+ blk_mq_realloc_hw_ctxs(set, q, true);
if (q->nr_hw_queues != set->nr_hw_queues) {
int i = prev_nr_hw_queues;
Thanks,
Ming
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [syzbot] [block?] possible deadlock in elv_iosched_store
2025-03-28 14:37 [syzbot] [block?] possible deadlock in elv_iosched_store syzbot
2025-03-29 1:59 ` Ming Lei
@ 2025-03-29 2:01 ` Ming Lei
2025-03-29 2:02 ` syzbot
1 sibling, 1 reply; 7+ messages in thread
From: Ming Lei @ 2025-03-29 2:01 UTC (permalink / raw)
To: syzbot; +Cc: axboe, linux-block, linux-kernel, syzkaller-bugs
On Fri, Mar 28, 2025 at 07:37:25AM -0700, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 1a9239bb4253 Merge tag 'net-next-6.15' of git://git.kernel..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1384b43f980000
> kernel config: https://syzkaller.appspot.com/x/.config?x=c7163a109ac459a8
> dashboard link: https://syzkaller.appspot.com/bug?extid=4c7e0f9b94ad65811efb
> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=178cfa4c580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a8ca4c580000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/fc7dc9f0d9a7/disk-1a9239bb.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/f555a3ae03d3/vmlinux-1a9239bb.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/55f6ea74eaf2/bzImage-1a9239bb.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+4c7e0f9b94ad65811efb@syzkaller.appspotmail.com
>
...
>
> ---
> 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
#syz dup: [syzbot] [block?] possible deadlock in elv_iosched_store
--
Ming
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [syzbot] [block?] possible deadlock in elv_iosched_store
2025-03-29 2:01 ` Ming Lei
@ 2025-03-29 2:02 ` syzbot
0 siblings, 0 replies; 7+ messages in thread
From: syzbot @ 2025-03-29 2:02 UTC (permalink / raw)
To: ming.lei; +Cc: axboe, linux-block, linux-kernel, ming.lei, syzkaller-bugs
> On Fri, Mar 28, 2025 at 07:37:25AM -0700, syzbot wrote:
>> Hello,
>>
>> syzbot found the following issue on:
>>
>> HEAD commit: 1a9239bb4253 Merge tag 'net-next-6.15' of git://git.kernel..
>> git tree: upstream
>> console output: https://syzkaller.appspot.com/x/log.txt?x=1384b43f980000
>> kernel config: https://syzkaller.appspot.com/x/.config?x=c7163a109ac459a8
>> dashboard link: https://syzkaller.appspot.com/bug?extid=4c7e0f9b94ad65811efb
>> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
>> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=178cfa4c580000
>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a8ca4c580000
>>
>> Downloadable assets:
>> disk image: https://storage.googleapis.com/syzbot-assets/fc7dc9f0d9a7/disk-1a9239bb.raw.xz
>> vmlinux: https://storage.googleapis.com/syzbot-assets/f555a3ae03d3/vmlinux-1a9239bb.xz
>> kernel image: https://storage.googleapis.com/syzbot-assets/55f6ea74eaf2/bzImage-1a9239bb.xz
>>
>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>> Reported-by: syzbot+4c7e0f9b94ad65811efb@syzkaller.appspotmail.com
>>
>
> ...
>
>>
>> ---
>> 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
>
> #syz dup: [syzbot] [block?] possible deadlock in elv_iosched_store
Can't dup bug to itself.
>
> --
> Ming
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [syzbot] [block?] possible deadlock in elv_iosched_store
2025-03-29 1:59 ` Ming Lei
@ 2025-04-01 11:53 ` Nilay Shroff
2025-04-01 12:16 ` Ming Lei
0 siblings, 1 reply; 7+ messages in thread
From: Nilay Shroff @ 2025-04-01 11:53 UTC (permalink / raw)
To: Ming Lei, syzbot; +Cc: axboe, linux-block, linux-kernel, syzkaller-bugs
On 3/29/25 7:29 AM, Ming Lei wrote:
> On Fri, Mar 28, 2025 at 07:37:25AM -0700, syzbot wrote:
>> Hello,
>>
>> syzbot found the following issue on:
>>
>> HEAD commit: 1a9239bb4253 Merge tag 'net-next-6.15' of git://git.kernel..
>> git tree: upstream
>> console output: https://syzkaller.appspot.com/x/log.txt?x=1384b43f980000
>> kernel config: https://syzkaller.appspot.com/x/.config?x=c7163a109ac459a8
>> dashboard link: https://syzkaller.appspot.com/bug?extid=4c7e0f9b94ad65811efb
>> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
>> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=178cfa4c580000
>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a8ca4c580000
>>
>> Downloadable assets:
>> disk image: https://storage.googleapis.com/syzbot-assets/fc7dc9f0d9a7/disk-1a9239bb.raw.xz
>> vmlinux: https://storage.googleapis.com/syzbot-assets/f555a3ae03d3/vmlinux-1a9239bb.xz
>> kernel image: https://storage.googleapis.com/syzbot-assets/55f6ea74eaf2/bzImage-1a9239bb.xz
>>
>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>> Reported-by: syzbot+4c7e0f9b94ad65811efb@syzkaller.appspotmail.com
>>
>
> ...
>
>>
>> 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.
>
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index ae8494d88897..d7a103dc258b 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -4465,14 +4465,12 @@ static struct blk_mq_hw_ctx *blk_mq_alloc_and_init_hctx(
> return NULL;
> }
>
> -static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
> - struct request_queue *q)
> +static void __blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
> + struct request_queue *q)
> {
> struct blk_mq_hw_ctx *hctx;
> unsigned long i, j;
>
> - /* protect against switching io scheduler */
> - mutex_lock(&q->elevator_lock);
> for (i = 0; i < set->nr_hw_queues; i++) {
> int old_node;
> int node = blk_mq_get_hctx_node(set, i);
> @@ -4505,7 +4503,19 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
>
> xa_for_each_start(&q->hctx_table, j, hctx, j)
> blk_mq_exit_hctx(q, set, hctx, j);
> - mutex_unlock(&q->elevator_lock);
> +}
> +
> +static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
> + struct request_queue *q, bool lock)
> +{
> + if (lock) {
> + /* protect against switching io scheduler */
> + mutex_lock(&q->elevator_lock);
> + __blk_mq_realloc_hw_ctxs(set, q);
> + mutex_unlock(&q->elevator_lock);
> + } else {
> + __blk_mq_realloc_hw_ctxs(set, q);
> + }
>
> /* unregister cpuhp callbacks for exited hctxs */
> blk_mq_remove_hw_queues_cpuhp(q);
> @@ -4537,7 +4547,7 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
>
> xa_init(&q->hctx_table);
>
> - blk_mq_realloc_hw_ctxs(set, q);
> + blk_mq_realloc_hw_ctxs(set, q, false);
> if (!q->nr_hw_queues)
> goto err_hctxs;
>
> @@ -5033,7 +5043,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
> fallback:
> blk_mq_update_queue_map(set);
> list_for_each_entry(q, &set->tag_list, tag_set_list) {
> - blk_mq_realloc_hw_ctxs(set, q);
> + blk_mq_realloc_hw_ctxs(set, q, true);
>
> if (q->nr_hw_queues != set->nr_hw_queues) {
> int i = prev_nr_hw_queues;
>
This patch looks good to me, however after we fix this one, I found another splat.
I see that these new splats are side effect of commit ffa1e7ada456 ("block: Make
request_queue lockdep splats show up earlier").
IMO in the block layer code (unless it's in an IO submission path or a path where we
have already frozen queue) we may still want to allow memory allocation with GFP_KERNEL.
So in that sense, for example, we may acquire ->elevator_lock followed by fs_reclaim.
Or in another words, shouldn't it be legitimate to acquire blk layer specific lock and
then allocate memory using GFP_KERNEL assuming we haven't freezed queue or we're not in
IO submission path. But this commit ffa1e7ada456 ("block: Make request_queue lockdep
splats show up earlier") now showing up some false-positive splat as well, please see
below:
======================================================
WARNING: possible circular locking dependency detected
6.14.0+ #147 Not tainted
------------------------------------------------------
bash/5903 is trying to acquire lock:
c0000000ba0c6ad8 (&q->elevator_lock){+.+.}-{4:4}, at: elv_iosched_store+0x11c/0x5d4
but task is already holding lock:
c0000000ba0c65b8 (&q->q_usage_counter(io)#20){++++}-{0:0}, at: blk_mq_freeze_queue_nomemsave+0x28/0x40
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&q->q_usage_counter(io)#20){++++}-{0:0}:
blk_alloc_queue+0x3a8/0x3e4
blk_mq_alloc_queue+0x88/0x11c
__blk_mq_alloc_disk+0x34/0xd8
null_add_dev+0x3c8/0x914 [null_blk]
null_init+0x1e0/0x4bc [null_blk]
do_one_initcall+0x8c/0x4b8
do_init_module+0x7c/0x2c4
init_module_from_file+0xb4/0x108
idempotent_init_module+0x26c/0x368
sys_finit_module+0x98/0x150
system_call_exception+0x134/0x360
system_call_vectored_common+0x15c/0x2ec
-> #1 (fs_reclaim){+.+.}-{0:0}:
fs_reclaim_acquire+0xe4/0x120
kmem_cache_alloc_noprof+0x74/0x570
__kernfs_new_node+0x98/0x378
kernfs_new_node+0x80/0xc4
kernfs_create_dir_ns+0x44/0xec
sysfs_create_dir_ns+0x94/0x160
kobject_add_internal+0xf4/0x3c8
kobject_add+0x70/0x10c
elv_register_queue+0x70/0x14c
blk_register_queue+0x1d8/0x2bc
add_disk_fwnode+0x3b4/0x5d0
sd_probe+0x3bc/0x5b4 [sd_mod]
really_probe+0x104/0x4c4
__driver_probe_device+0xb8/0x200
driver_probe_device+0x54/0x128
__driver_attach_async_helper+0x7c/0x150
async_run_entry_fn+0x60/0x1bc
process_one_work+0x2ac/0x7e4
worker_thread+0x238/0x460
kthread+0x158/0x188
start_kernel_thread+0x14/0x18
-> #0 (&q->elevator_lock){+.+.}-{4:4}:
__lock_acquire+0x1b6c/0x2ae0
lock_acquire+0x140/0x430
__mutex_lock+0xf0/0xb00
elv_iosched_store+0x11c/0x5d4
queue_attr_store+0x12c/0x164
sysfs_kf_write+0x6c/0xb0
kernfs_fop_write_iter+0x1ac/0x2a8
vfs_write+0x410/0x584
ksys_write+0x84/0x140
system_call_exception+0x134/0x360
system_call_vectored_common+0x15c/0x2ec
other info that might help us debug this:
Chain exists of:
&q->elevator_lock --> fs_reclaim --> &q->q_usage_counter(io)#20
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&q->q_usage_counter(io)#20);
lock(fs_reclaim);
lock(&q->q_usage_counter(io)#20);
lock(&q->elevator_lock);
*** DEADLOCK ***
5 locks held by bash/5903:
#0: c00000005cb7f400 (sb_writers#3){.+.+}-{0:0}, at: ksys_write+0x84/0x140
#1: c000000008711288 (&of->mutex#2){+.+.}-{4:4}, at: kernfs_fop_write_iter+0x168/0x2a8
#2: c00000000a1e2c08 (kn->active#57){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x174/0x2a8
#3: c0000000ba0c65b8 (&q->q_usage_counter(io)#20){++++}-{0:0}, at: blk_mq_freeze_queue_nomemsave+0x28/0x40
#4: c0000000ba0c65f0 (&q->q_usage_counter(queue)#21){+.+.}-{0:0}, at: blk_mq_freeze_queue_nomemsave+0x28/0x40
stack backtrace:
CPU: 17 UID: 0 PID: 5903 Comm: bash Kdump: loaded Not tainted 6.14.0+ #147 VOLUNTARY
Hardware name: IBM,9043-MRX POWER10 (architected) 0x800200 0xf000006 of:IBM,FW1060.00 (NM1060_028) hv:phyp pSeries
Call Trace:
[c0000000955df580] [c0000000011a7ef8] dump_stack_lvl+0x108/0x18c (unreliable)
[c0000000955df5b0] [c000000000225b0c] print_circular_bug+0x448/0x604
[c0000000955df660] [c000000000225f14] check_noncircular+0x24c/0x26c
[c0000000955df730] [c00000000022c3e8] __lock_acquire+0x1b6c/0x2ae0
[c0000000955df860] [c000000000229700] lock_acquire+0x140/0x430
[c0000000955df960] [c0000000011e84e8] __mutex_lock+0xf0/0xb00
[c0000000955dfa90] [c0000000008fb6f8] elv_iosched_store+0x11c/0x5d4
[c0000000955dfb50] [c000000000903ec0] queue_attr_store+0x12c/0x164
[c0000000955dfc60] [c0000000007ca58c] sysfs_kf_write+0x6c/0xb0
[c0000000955dfca0] [c0000000007c8df0] kernfs_fop_write_iter+0x1ac/0x2a8
[c0000000955dfcf0] [c0000000006a8c9c] vfs_write+0x410/0x584
[c0000000955dfdc0] [c0000000006a9148] ksys_write+0x84/0x140
[c0000000955dfe10] [c000000000031814] system_call_exception+0x134/0x360
[c0000000955dfe50] [c00000000000cedc] system_call_vectored_common+0x15c/0x2ec
What do you think?
Thanks,
--Nilay
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [syzbot] [block?] possible deadlock in elv_iosched_store
2025-04-01 11:53 ` Nilay Shroff
@ 2025-04-01 12:16 ` Ming Lei
2025-04-01 12:29 ` Nilay Shroff
0 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2025-04-01 12:16 UTC (permalink / raw)
To: Nilay Shroff; +Cc: syzbot, axboe, linux-block, linux-kernel, syzkaller-bugs
On Tue, Apr 01, 2025 at 05:23:56PM +0530, Nilay Shroff wrote:
>
>
> On 3/29/25 7:29 AM, Ming Lei wrote:
> > On Fri, Mar 28, 2025 at 07:37:25AM -0700, syzbot wrote:
> >> Hello,
> >>
> >> syzbot found the following issue on:
> >>
> >> HEAD commit: 1a9239bb4253 Merge tag 'net-next-6.15' of git://git.kernel..
> >> git tree: upstream
> >> console output: https://syzkaller.appspot.com/x/log.txt?x=1384b43f980000
> >> kernel config: https://syzkaller.appspot.com/x/.config?x=c7163a109ac459a8
> >> dashboard link: https://syzkaller.appspot.com/bug?extid=4c7e0f9b94ad65811efb
> >> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
> >> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=178cfa4c580000
> >> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a8ca4c580000
> >>
> >> Downloadable assets:
> >> disk image: https://storage.googleapis.com/syzbot-assets/fc7dc9f0d9a7/disk-1a9239bb.raw.xz
> >> vmlinux: https://storage.googleapis.com/syzbot-assets/f555a3ae03d3/vmlinux-1a9239bb.xz
> >> kernel image: https://storage.googleapis.com/syzbot-assets/55f6ea74eaf2/bzImage-1a9239bb.xz
> >>
> >> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> >> Reported-by: syzbot+4c7e0f9b94ad65811efb@syzkaller.appspotmail.com
> >>
> >
> > ...
> >
> >>
> >> 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.
> >
> >
> > diff --git a/block/blk-mq.c b/block/blk-mq.c
> > index ae8494d88897..d7a103dc258b 100644
> > --- a/block/blk-mq.c
> > +++ b/block/blk-mq.c
> > @@ -4465,14 +4465,12 @@ static struct blk_mq_hw_ctx *blk_mq_alloc_and_init_hctx(
> > return NULL;
> > }
> >
> > -static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
> > - struct request_queue *q)
> > +static void __blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
> > + struct request_queue *q)
> > {
> > struct blk_mq_hw_ctx *hctx;
> > unsigned long i, j;
> >
> > - /* protect against switching io scheduler */
> > - mutex_lock(&q->elevator_lock);
> > for (i = 0; i < set->nr_hw_queues; i++) {
> > int old_node;
> > int node = blk_mq_get_hctx_node(set, i);
> > @@ -4505,7 +4503,19 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
> >
> > xa_for_each_start(&q->hctx_table, j, hctx, j)
> > blk_mq_exit_hctx(q, set, hctx, j);
> > - mutex_unlock(&q->elevator_lock);
> > +}
> > +
> > +static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
> > + struct request_queue *q, bool lock)
> > +{
> > + if (lock) {
> > + /* protect against switching io scheduler */
> > + mutex_lock(&q->elevator_lock);
> > + __blk_mq_realloc_hw_ctxs(set, q);
> > + mutex_unlock(&q->elevator_lock);
> > + } else {
> > + __blk_mq_realloc_hw_ctxs(set, q);
> > + }
> >
> > /* unregister cpuhp callbacks for exited hctxs */
> > blk_mq_remove_hw_queues_cpuhp(q);
> > @@ -4537,7 +4547,7 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
> >
> > xa_init(&q->hctx_table);
> >
> > - blk_mq_realloc_hw_ctxs(set, q);
> > + blk_mq_realloc_hw_ctxs(set, q, false);
> > if (!q->nr_hw_queues)
> > goto err_hctxs;
> >
> > @@ -5033,7 +5043,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
> > fallback:
> > blk_mq_update_queue_map(set);
> > list_for_each_entry(q, &set->tag_list, tag_set_list) {
> > - blk_mq_realloc_hw_ctxs(set, q);
> > + blk_mq_realloc_hw_ctxs(set, q, true);
> >
> > if (q->nr_hw_queues != set->nr_hw_queues) {
> > int i = prev_nr_hw_queues;
> >
>
> This patch looks good to me, however after we fix this one, I found another splat.
> I see that these new splats are side effect of commit ffa1e7ada456 ("block: Make
> request_queue lockdep splats show up earlier").
>
> IMO in the block layer code (unless it's in an IO submission path or a path where we
> have already frozen queue) we may still want to allow memory allocation with GFP_KERNEL.
> So in that sense, for example, we may acquire ->elevator_lock followed by fs_reclaim.
If any memory GFP_KERNEL allocation grabs ->elevator_lock, it is one real
deadlock risk.
> Or in another words, shouldn't it be legitimate to acquire blk layer specific lock and
> then allocate memory using GFP_KERNEL assuming we haven't freezed queue or we're not in
> IO submission path. But this commit ffa1e7ada456 ("block: Make request_queue lockdep
> splats show up earlier") now showing up some false-positive splat as well, please see
> below:
It depends if we may run GFP_KERNEL allocation with ->elevator_lock.
I feel ->elevator_lock is still used too many...
thanks,
Ming
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [syzbot] [block?] possible deadlock in elv_iosched_store
2025-04-01 12:16 ` Ming Lei
@ 2025-04-01 12:29 ` Nilay Shroff
0 siblings, 0 replies; 7+ messages in thread
From: Nilay Shroff @ 2025-04-01 12:29 UTC (permalink / raw)
To: Ming Lei; +Cc: syzbot, axboe, linux-block, linux-kernel, syzkaller-bugs
On 4/1/25 5:46 PM, Ming Lei wrote:
> On Tue, Apr 01, 2025 at 05:23:56PM +0530, Nilay Shroff wrote:
>>
>>
>> On 3/29/25 7:29 AM, Ming Lei wrote:
>>> On Fri, Mar 28, 2025 at 07:37:25AM -0700, syzbot wrote:
>>>> Hello,
>>>>
>>>> syzbot found the following issue on:
>>>>
>>>> HEAD commit: 1a9239bb4253 Merge tag 'net-next-6.15' of git://git.kernel..
>>>> git tree: upstream
>>>> console output: https://syzkaller.appspot.com/x/log.txt?x=1384b43f980000
>>>> kernel config: https://syzkaller.appspot.com/x/.config?x=c7163a109ac459a8
>>>> dashboard link: https://syzkaller.appspot.com/bug?extid=4c7e0f9b94ad65811efb
>>>> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
>>>> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=178cfa4c580000
>>>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a8ca4c580000
>>>>
>>>> Downloadable assets:
>>>> disk image: https://storage.googleapis.com/syzbot-assets/fc7dc9f0d9a7/disk-1a9239bb.raw.xz
>>>> vmlinux: https://storage.googleapis.com/syzbot-assets/f555a3ae03d3/vmlinux-1a9239bb.xz
>>>> kernel image: https://storage.googleapis.com/syzbot-assets/55f6ea74eaf2/bzImage-1a9239bb.xz
>>>>
>>>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>>>> Reported-by: syzbot+4c7e0f9b94ad65811efb@syzkaller.appspotmail.com
>>>>
>>>
>>> ...
>>>
>>>>
>>>> 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.
>>>
>>>
>>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>>> index ae8494d88897..d7a103dc258b 100644
>>> --- a/block/blk-mq.c
>>> +++ b/block/blk-mq.c
>>> @@ -4465,14 +4465,12 @@ static struct blk_mq_hw_ctx *blk_mq_alloc_and_init_hctx(
>>> return NULL;
>>> }
>>>
>>> -static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
>>> - struct request_queue *q)
>>> +static void __blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
>>> + struct request_queue *q)
>>> {
>>> struct blk_mq_hw_ctx *hctx;
>>> unsigned long i, j;
>>>
>>> - /* protect against switching io scheduler */
>>> - mutex_lock(&q->elevator_lock);
>>> for (i = 0; i < set->nr_hw_queues; i++) {
>>> int old_node;
>>> int node = blk_mq_get_hctx_node(set, i);
>>> @@ -4505,7 +4503,19 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
>>>
>>> xa_for_each_start(&q->hctx_table, j, hctx, j)
>>> blk_mq_exit_hctx(q, set, hctx, j);
>>> - mutex_unlock(&q->elevator_lock);
>>> +}
>>> +
>>> +static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
>>> + struct request_queue *q, bool lock)
>>> +{
>>> + if (lock) {
>>> + /* protect against switching io scheduler */
>>> + mutex_lock(&q->elevator_lock);
>>> + __blk_mq_realloc_hw_ctxs(set, q);
>>> + mutex_unlock(&q->elevator_lock);
>>> + } else {
>>> + __blk_mq_realloc_hw_ctxs(set, q);
>>> + }
>>>
>>> /* unregister cpuhp callbacks for exited hctxs */
>>> blk_mq_remove_hw_queues_cpuhp(q);
>>> @@ -4537,7 +4547,7 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
>>>
>>> xa_init(&q->hctx_table);
>>>
>>> - blk_mq_realloc_hw_ctxs(set, q);
>>> + blk_mq_realloc_hw_ctxs(set, q, false);
>>> if (!q->nr_hw_queues)
>>> goto err_hctxs;
>>>
>>> @@ -5033,7 +5043,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
>>> fallback:
>>> blk_mq_update_queue_map(set);
>>> list_for_each_entry(q, &set->tag_list, tag_set_list) {
>>> - blk_mq_realloc_hw_ctxs(set, q);
>>> + blk_mq_realloc_hw_ctxs(set, q, true);
>>>
>>> if (q->nr_hw_queues != set->nr_hw_queues) {
>>> int i = prev_nr_hw_queues;
>>>
>>
>> This patch looks good to me, however after we fix this one, I found another splat.
>> I see that these new splats are side effect of commit ffa1e7ada456 ("block: Make
>> request_queue lockdep splats show up earlier").
>>
>> IMO in the block layer code (unless it's in an IO submission path or a path where we
>> have already frozen queue) we may still want to allow memory allocation with GFP_KERNEL.
>> So in that sense, for example, we may acquire ->elevator_lock followed by fs_reclaim.
>
> If any memory GFP_KERNEL allocation grabs ->elevator_lock, it is one real
> deadlock risk.
>
>> Or in another words, shouldn't it be legitimate to acquire blk layer specific lock and
>> then allocate memory using GFP_KERNEL assuming we haven't freezed queue or we're not in
>> IO submission path. But this commit ffa1e7ada456 ("block: Make request_queue lockdep
>> splats show up earlier") now showing up some false-positive splat as well, please see
>> below:
>
> It depends if we may run GFP_KERNEL allocation with ->elevator_lock.
>
Okay, so do you think we shall use GFP_NOIO for memory allocation if it's done after we
acquire ->elevator_lock?
Thanks,
--Nilay
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-04-01 12:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-28 14:37 [syzbot] [block?] possible deadlock in elv_iosched_store syzbot
2025-03-29 1:59 ` Ming Lei
2025-04-01 11:53 ` Nilay Shroff
2025-04-01 12:16 ` Ming Lei
2025-04-01 12:29 ` Nilay Shroff
2025-03-29 2:01 ` Ming Lei
2025-03-29 2:02 ` syzbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox