[v5.15] possible deadlock in kernfs_remove_by_name_ns

0 views
Skip to first unread message

syzbot

unread,
Aug 9, 2026, 7:31:34 PM (8 days ago) Aug 9
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: aabd761612db Linux 5.15.215
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12b00079580000
kernel config: https://syzkaller.appspot.com/x/.config?x=f161cbc9aef65db0
dashboard link: https://syzkaller.appspot.com/bug?extid=b2e6592e0bc99fd16c8a
compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f636f56d3662/disk-aabd7616.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f1a46620f40c/vmlinux-aabd7616.xz
kernel image: https://storage.googleapis.com/syzbot-assets/9b78bb48b022/bzImage-aabd7616.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b2e659...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.3.171/5078 is trying to acquire lock:
ffff888017da7a00 (kn->active#487){++++}-{0:0}, at: kernfs_remove_by_name_ns+0x91/0x100 fs/kernfs/dir.c:1566

but task is already holding lock:
ffffffff8c95fde8 (pci_rescan_remove_lock){+.+.}-{3:3}, at: pci_stop_and_remove_bus_device_locked+0xe/0x30 drivers/pci/remove.c:124

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (pci_rescan_remove_lock){+.+.}-{3:3}:
__mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
dev_rescan_store+0xc2/0x150 drivers/pci/pci-sysfs.c:476
kernfs_fop_write_iter+0x3a8/0x500 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2173 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0x748/0xd70 fs/read_write.c:594
ksys_write+0x153/0x260 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (kn->active#487){++++}-{0:0}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3788 [inline]
__lock_acquire+0x2c66/0x7b50 kernel/locking/lockdep.c:5012
lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
kernfs_drain fs/kernfs/dir.c:478 [inline]
__kernfs_remove+0x5da/0xcb0 fs/kernfs/dir.c:1372
kernfs_remove_by_name_ns+0x91/0x100 fs/kernfs/dir.c:1566
kernfs_remove_by_name include/linux/kernfs.h:598 [inline]
remove_files fs/sysfs/group.c:28 [inline]
sysfs_remove_group+0xfd/0x290 fs/sysfs/group.c:289
sysfs_remove_groups+0x50/0xa0 fs/sysfs/group.c:313
device_remove_groups drivers/base/core.c:2498 [inline]
device_remove_attrs+0xf1/0x140 drivers/base/core.c:2701
device_del+0x637/0xa80 drivers/base/core.c:3614
pci_destroy_dev drivers/pci/remove.c:36 [inline]
pci_remove_bus_device+0x114/0x610 drivers/pci/remove.c:100
pci_stop_and_remove_bus_device drivers/pci/remove.c:118 [inline]
pci_stop_and_remove_bus_device_locked+0x1e/0x30 drivers/pci/remove.c:125
remove_store+0xe2/0x140 drivers/pci/pci-sysfs.c:494
kernfs_fop_write_iter+0x3a8/0x500 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2173 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0x748/0xd70 fs/read_write.c:594
ksys_write+0x153/0x260 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(pci_rescan_remove_lock);
lock(kn->active#487);
lock(pci_rescan_remove_lock);
lock(kn->active#487);

*** DEADLOCK ***

4 locks held by syz.3.171/5078:
#0: ffff88801e5639f0 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2bf/0x370 fs/file.c:1056
#1: ffff888023188460 (sb_writers#8){.+.+}-{0:0}, at: vfs_write+0x296/0xd70 fs/read_write.c:590
#2: ffff88802b335c88 (&of->mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0x1dc/0x500 fs/kernfs/file.c:287
#3: ffffffff8c95fde8 (pci_rescan_remove_lock){+.+.}-{3:3}, at: pci_stop_and_remove_bus_device_locked+0xe/0x30 drivers/pci/remove.c:124

stack backtrace:
CPU: 0 PID: 5078 Comm: syz.3.171 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Call Trace:
<TASK>
dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106
check_noncircular+0x296/0x330 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3788 [inline]
__lock_acquire+0x2c66/0x7b50 kernel/locking/lockdep.c:5012
lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
kernfs_drain fs/kernfs/dir.c:478 [inline]
__kernfs_remove+0x5da/0xcb0 fs/kernfs/dir.c:1372
kernfs_remove_by_name_ns+0x91/0x100 fs/kernfs/dir.c:1566
kernfs_remove_by_name include/linux/kernfs.h:598 [inline]
remove_files fs/sysfs/group.c:28 [inline]
sysfs_remove_group+0xfd/0x290 fs/sysfs/group.c:289
sysfs_remove_groups+0x50/0xa0 fs/sysfs/group.c:313
device_remove_groups drivers/base/core.c:2498 [inline]
device_remove_attrs+0xf1/0x140 drivers/base/core.c:2701
device_del+0x637/0xa80 drivers/base/core.c:3614
pci_destroy_dev drivers/pci/remove.c:36 [inline]
pci_remove_bus_device+0x114/0x610 drivers/pci/remove.c:100
pci_stop_and_remove_bus_device drivers/pci/remove.c:118 [inline]
pci_stop_and_remove_bus_device_locked+0x1e/0x30 drivers/pci/remove.c:125
remove_store+0xe2/0x140 drivers/pci/pci-sysfs.c:494
kernfs_fop_write_iter+0x3a8/0x500 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2173 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0x748/0xd70 fs/read_write.c:594
ksys_write+0x153/0x260 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fa7680190d9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fa766250028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fa7682a1090 RCX: 00007fa7680190d9
RDX: 0000000000000001 RSI: 00002000000000c0 RDI: 000000000000000a
RBP: 00007fa7680b0024 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fa7682a1128 R14: 00007fa7682a1090 R15: 00007fff83fc7518
</TASK>


---
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 syzk...@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 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
Reply all
Reply to author
Forward
0 new messages