lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <34f7fcf0.910d.1968611014a.Coremail.luckd0g@163.com>
Date: Wed, 30 Apr 2025 17:39:43 +0800 (CST)
From: "Jianzhou Zhao" <luckd0g@....com>
To: stable@...r.kernel.org
Cc: axboe@...nel.dk, linux-block@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: possible deadlock in blk_mq_freeze_queue in Linux6.1.25(longterm
 maintenance, last updated on April 25, 2025)

Hello, I found a potential bug titled "    possible deadlock in blk_mq_freeze_queue" with modified syzkaller in the Linux6.12.25(longterm maintenance, last updated on April 25, 2025)
If you fix this issue, please add the following tag to the commit:  Reported-by: Jianzhou Zhao <luckd0g@....com>,    xingwei lee <xrivendell7@...il.com>
The commit of the kernel is : 	ef4999852d307d38cfdecd91ed6892cc03beb9b8 
kernel config: https://syzkaller.appspot.com/text?tag=KernelConfig&x=55f8591b98dd132
compiler: gcc version 11.4.0

Unfortunately, although my fuzz testing tool can trigger this bug relatively frequently, it still cannot generate a reproduction program.

------------[ cut here ]-----------------------------------------
 TITLE:    possible deadlock in blk_mq_freeze_queue
------------[ cut here ]------------
loop6: detected capacity change from 1024 to 1023
======================================================
WARNING: possible circular locking dependency detected
6.12.25 #1 Not tainted
------------------------------------------------------
syz.8.1968/32422 is trying to acquire lock:
ffffffff8e34acc0 (fs_reclaim){+.+.}-{0:0}, at: might_alloc include/linux/sched/mm.h:318 [inline]
ffffffff8e34acc0 (fs_reclaim){+.+.}-{0:0}, at: slab_pre_alloc_hook mm/slub.c:4068 [inline]
ffffffff8e34acc0 (fs_reclaim){+.+.}-{0:0}, at: slab_alloc_node mm/slub.c:4146 [inline]
ffffffff8e34acc0 (fs_reclaim){+.+.}-{0:0}, at: __kmalloc_cache_noprof+0x56/0x3e0 mm/slub.c:4322

but task is already holding lock:
ffff8880435f1468 (&q->q_usage_counter(io)#23){++++}-{0:0}, at: blk_freeze_queue block/blk-mq.c:224 [inline]
ffff8880435f1468 (&q->q_usage_counter(io)#23){++++}-{0:0}, at: blk_mq_freeze_queue+0x15/0x20 block/blk-mq.c:234

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&q->q_usage_counter(io)#23){++++}-{0:0}:
       bio_queue_enter block/blk.h:76 [inline]
       blk_mq_submit_bio+0x22fd/0x2dd0 block/blk-mq.c:3088
       __submit_bio+0x63b/0x10b0 block/blk-core.c:629
       __submit_bio_noacct_mq block/blk-core.c:716 [inline]
       submit_bio_noacct_nocheck block/blk-core.c:745 [inline]
       submit_bio_noacct_nocheck+0x6cc/0xd30 block/blk-core.c:722
       submit_bio_noacct+0x6c9/0x1fc0 block/blk-core.c:868
       xfs_buf_ioapply_map fs/xfs/xfs_buf.c:1585 [inline]
       _xfs_buf_ioapply+0xa65/0xed0 fs/xfs/xfs_buf.c:1673
       __xfs_buf_submit+0x26c/0x700 fs/xfs/xfs_buf.c:1757
       xfs_buf_submit fs/xfs/xfs_buf.c:61 [inline]
       _xfs_buf_read fs/xfs/xfs_buf.c:808 [inline]
       xfs_buf_read_map+0x672/0xde0 fs/xfs/xfs_buf.c:872
       xfs_trans_read_buf_map+0x356/0xcf0 fs/xfs/xfs_trans_buf.c:289
       xfs_trans_read_buf fs/xfs/xfs_trans.h:212 [inline]
       xfs_imap_to_bp+0x110/0x2a0 fs/xfs/libxfs/xfs_inode_buf.c:138
       xfs_inode_item_precommit+0x5d9/0x980 fs/xfs/xfs_inode_item.c:174
       xfs_trans_run_precommits fs/xfs/xfs_trans.c:802 [inline]
       __xfs_trans_commit+0x303/0xda0 fs/xfs/xfs_trans.c:845
       xfs_trans_commit+0x117/0x1b0 fs/xfs/xfs_trans.c:930
       xfs_qm_qino_alloc+0x4da/0x700 fs/xfs/xfs_qm.c:861
       xfs_qm_init_quotainos+0x526/0x6e0 fs/xfs/xfs_qm.c:1664
       xfs_qm_init_quotainfo+0xf8/0xb00 fs/xfs/xfs_qm.c:667
       xfs_qm_mount_quotas+0x59/0x650 fs/xfs/xfs_qm.c:1514
       xfs_mountfs+0x1c0e/0x20e0 fs/xfs/xfs_mount.c:984
       xfs_fs_fill_super+0x148f/0x1f30 fs/xfs/xfs_super.c:1764
       get_tree_bdev_flags+0x389/0x620 fs/super.c:1636
       vfs_get_tree+0x90/0x340 fs/super.c:1814
       do_new_mount fs/namespace.c:3512 [inline]
       path_mount+0x1290/0x1bc0 fs/namespace.c:3839
       do_mount+0xf8/0x110 fs/namespace.c:3852
       __do_sys_mount fs/namespace.c:4062 [inline]
       __se_sys_mount fs/namespace.c:4039 [inline]
       __x64_sys_mount+0x193/0x230 fs/namespace.c:4039
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xcf/0x250 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&xfs_nondir_ilock_class#3){++++}-{3:3}:
       down_write_nested+0x96/0x210 kernel/locking/rwsem.c:1693
       xfs_ilock+0x35c/0x420 fs/xfs/xfs_inode.c:164
       xfs_reclaim_inode fs/xfs/xfs_icache.c:981 [inline]
       xfs_icwalk_process_inode fs/xfs/xfs_icache.c:1675 [inline]
       xfs_icwalk_ag+0xa64/0x17c0 fs/xfs/xfs_icache.c:1757
       xfs_icwalk+0x4b/0xa0 fs/xfs/xfs_icache.c:1805
       xfs_reclaim_inodes_nr+0x1ad/0x2b0 fs/xfs/xfs_icache.c:1047
       super_cache_scan+0x364/0x490 fs/super.c:227
       do_shrink_slab+0x464/0x11d0 mm/shrinker.c:437
       shrink_slab+0x336/0x12c0 mm/shrinker.c:664
       shrink_one+0x4a8/0x7d0 mm/vmscan.c:4835
       shrink_many mm/vmscan.c:4896 [inline]
       lru_gen_shrink_node mm/vmscan.c:4974 [inline]
       shrink_node+0x24da/0x3b50 mm/vmscan.c:5954
       kswapd_shrink_node mm/vmscan.c:6782 [inline]
       balance_pgdat+0x9d0/0x1670 mm/vmscan.c:6974
       kswapd+0x538/0xc70 mm/vmscan.c:7243
       kthread+0x342/0x450 kernel/kthread.c:389
       ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:152
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

-> #0 (fs_reclaim){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3161 [inline]
       check_prevs_add kernel/locking/lockdep.c:3280 [inline]
       validate_chain kernel/locking/lockdep.c:3904 [inline]
       __lock_acquire+0x2940/0x4810 kernel/locking/lockdep.c:5202
       lock_acquire kernel/locking/lockdep.c:5825 [inline]
       lock_acquire+0x1b4/0x590 kernel/locking/lockdep.c:5790
       __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]
       slab_pre_alloc_hook mm/slub.c:4068 [inline]
       slab_alloc_node mm/slub.c:4146 [inline]
       __kmalloc_cache_noprof+0x56/0x3e0 mm/slub.c:4322
       kmalloc_noprof include/linux/slab.h:878 [inline]
       kzalloc_noprof include/linux/slab.h:1014 [inline]
       kobject_uevent_env+0x23a/0x16b0 lib/kobject_uevent.c:540
       set_capacity_and_notify+0x1cb/0x250 block/genhd.c:95
       loop_set_size.isra.0+0x2f/0xc0 drivers/block/loop.c:232
       loop_set_status+0x486/0x740 drivers/block/loop.c:1210
       loop_set_status_old+0x148/0x1c0 drivers/block/loop.c:1313
       lo_ioctl+0xc5e/0x1830 drivers/block/loop.c:1466
       blkdev_ioctl+0x27b/0x6d0 block/ioctl.c:693
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:907 [inline]
       __se_sys_ioctl fs/ioctl.c:893 [inline]
       __x64_sys_ioctl+0x19d/0x210 fs/ioctl.c:893
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xcf/0x250 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  fs_reclaim --> &xfs_nondir_ilock_class#3 --> &q->q_usage_counter(io)#23

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&q->q_usage_counter(io)#23);
                               lock(&xfs_nondir_ilock_class#3);
                               lock(&q->q_usage_counter(io)#23);
  lock(fs_reclaim);

 *** DEADLOCK ***

3 locks held by syz.8.1968/32422:
 #0: ffff888020454b70 (&lo->lo_mutex){+.+.}-{3:3}, at: loop_set_status+0x2a/0x740 drivers/block/loop.c:1176
 #1: ffff8880435f1468 (&q->q_usage_counter(io)#23){++++}-{0:0}, at: blk_freeze_queue block/blk-mq.c:224 [inline]
 #1: ffff8880435f1468 (&q->q_usage_counter(io)#23){++++}-{0:0}, at: blk_mq_freeze_queue+0x15/0x20 block/blk-mq.c:234
 #2: ffff8880435f14a0 (&q->q_usage_counter(queue)#7){+.+.}-{0:0}, at: blk_freeze_queue block/blk-mq.c:224 [inline]
 #2: ffff8880435f14a0 (&q->q_usage_counter(queue)#7){+.+.}-{0:0}, at: blk_mq_freeze_queue+0x15/0x20 block/blk-mq.c:234

stack backtrace:
CPU: 0 UID: 0 PID: 32422 Comm: syz.8.1968 Not tainted 6.12.25 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1b0 lib/dump_stack.c:120
 print_circular_bug.isra.0+0x5e5/0x9f0 kernel/locking/lockdep.c:2074
 check_noncircular+0x2f1/0x3d0 kernel/locking/lockdep.c:2206
 check_prev_add kernel/locking/lockdep.c:3161 [inline]
 check_prevs_add kernel/locking/lockdep.c:3280 [inline]
 validate_chain kernel/locking/lockdep.c:3904 [inline]
 __lock_acquire+0x2940/0x4810 kernel/locking/lockdep.c:5202
 lock_acquire kernel/locking/lockdep.c:5825 [inline]
 lock_acquire+0x1b4/0x590 kernel/locking/lockdep.c:5790
 __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]
 slab_pre_alloc_hook mm/slub.c:4068 [inline]
 slab_alloc_node mm/slub.c:4146 [inline]
 __kmalloc_cache_noprof+0x56/0x3e0 mm/slub.c:4322
 kmalloc_noprof include/linux/slab.h:878 [inline]
 kzalloc_noprof include/linux/slab.h:1014 [inline]
 kobject_uevent_env+0x23a/0x16b0 lib/kobject_uevent.c:540
 set_capacity_and_notify+0x1cb/0x250 block/genhd.c:95
 loop_set_size.isra.0+0x2f/0xc0 drivers/block/loop.c:232
 loop_set_status+0x486/0x740 drivers/block/loop.c:1210
 loop_set_status_old+0x148/0x1c0 drivers/block/loop.c:1313
 lo_ioctl+0xc5e/0x1830 drivers/block/loop.c:1466
 blkdev_ioctl+0x27b/0x6d0 block/ioctl.c:693
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:907 [inline]
 __se_sys_ioctl fs/ioctl.c:893 [inline]
 __x64_sys_ioctl+0x19d/0x210 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcf/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f22897ac5ad
Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f228a5f2f98 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f22899e5fa0 RCX: 00007f22897ac5ad
RDX: 0000200000000080 RSI: 0000000000004c02 RDI: 0000000000000006
RBP: 00007f228984458e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f22899e5fa0 R15: 00007f228a5d3000
 </TASK>

===================================================================


I hope it helps.
Best regards
Jianzhou Zhao

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ