WARNING: still has locks held in devlink_compat_flash_update
Subsystems (3)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 73ae59e97596 Merge tag 'erofs-for-7.3-rc1-2' of git://git... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=13005415580000 kernel config: https://syzkaller.appspot.com/x/.config?x=8d423d3e91ba4f47 dashboard link: https://syzkaller.appspot.com/bug?extid=372a7d84708b07f64d9b compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 userspace arch: i386 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17daf979580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13281625580000
Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-73ae59e9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2edc303b5fba/vmlinux-73ae59e9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2624d8e0a8af/bzImage-73ae59e9.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
====================================
WARNING: syz.1.24/6043 still has locks held!
syzkaller #0 Not tainted
------------------------------------
locks held by syz.1.24/6043: 1, last CPU#3:
#0: ffff888029f7e258 (&devlink->lock_key#4){+.+.}-{4:4}, at: devlink_compat_flash_update+0xaf/0x360 net/devlink/dev.c:1237
stack backtrace: CPU: 3 UID: 0 PID: 6043 Comm: syz.1.24 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120 print_held_locks_bug kernel/locking/lockdep.c:6770 [inline] debug_check_no_locks_held+0x90/0xa0 kernel/locking/lockdep.c:6778 try_to_freeze include/linux/freezer.h:62 [inline] usermodehelper_read_trylock+0x238/0x250 kernel/umh.c:228 fw_load_from_user_helper drivers/base/firmware_loader/fallback.c:157 [inline] firmware_fallback_sysfs+0x6d6/0xc60 drivers/base/firmware_loader/fallback.c:248 _request_firmware+0xfd7/0x13c0 drivers/base/firmware_loader/main.c:898 request_firmware+0x35/0x50 drivers/base/firmware_loader/main.c:948 devlink_compat_flash_update+0x191/0x360 net/devlink/dev.c:1248 dev_ethtool+0x64e/0x6bb0 net/ethtool/ioctl.c:3676 dev_ioctl+0x63b/0x1070 net/core/dev_ioctl.c:751 compat_ifr_data_ioctl net/socket.c:3534 [inline] compat_sock_ioctl_trans net/socket.c:3564 [inline] compat_sock_ioctl+0x4f9/0x760 net/socket.c:3654 __do_compat_sys_ioctl fs/ioctl.c:695 [inline] __se_compat_sys_ioctl fs/ioctl.c:638 [inline] __ia32_compat_sys_ioctl+0x2cf/0x360 fs/ioctl.c:638 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x13a/0x8b0 arch/x86/entry/syscall_32.c:291 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:316 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf6fdefec Code: Unable to access opcode bytes at 0xf6fdefc2. RSP: 002b:00000000ff8f659c EFLAGS: 00000292 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 0000000000008946 RDX: 0000000080000040 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 </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 [email protected].
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
PATCH 1/1 devlink: request flash firmware without instance lock
request_firmware() may enter the userspace fallback and call try_to_freeze(). Holding the devlink instance lock across that call triggers a lockdep warning and can block unregister for the duration of the firmware fallback.
Drop the instance lock around firmware loading in both flash update paths. The callers hold a devlink reference, which also pins the parent device. Recheck registration after reacquiring the lock before calling into the driver.
--- net/devlink/dev.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
net/devlink/dev.c +17 -0
@@ -1169,17 +1169,25 @@ int devlink_nl_flash_update_doit(struct sk_buff *skb, struct genl_info *info) nla_file_name = info->attrs[DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME ]; file_name =nla_data (nla_file_name); +devl_unlock (devlink); ret =request_firmware (¶ms.fw, file_name, devlink->dev); +devl_lock (devlink);if (ret) {NL_SET_ERR_MSG_ATTR (info->extack, nla_file_name,"failed to locate the requested firmware file" );return ret; } +/* The device may have been unregistered while the lock was dropped. */ +if (!devl_is_registered (devlink)) { + ret = -ENODEV ; + goto out_release; + }devlink_flash_update_begin_notify (devlink); ret = devlink->ops->flash_update (devlink, ¶ms, info->extack);devlink_flash_update_end_notify (devlink); +out_release:release_firmware (params.fw);return ret;
@@ -1244,15 +1252,24 @@ int devlink_compat_flash_update(struct devlink *devlink, const char *file_name) ret = -EOPNOTSUPP ; goto out_unlock; } +devl_unlock (devlink); ret =request_firmware (¶ms.fw, file_name, devlink->dev); +devl_lock (devlink);if (ret) goto out_unlock; +/* The device may have been unregistered while the lock was dropped. */ +if (!devl_is_registered (devlink)) { + ret = -ENODEV ; + goto out_release; + } +devlink_flash_update_begin_notify (devlink); ret = devlink->ops->flash_update (devlink, ¶ms,NULL );devlink_flash_update_end_notify (devlink); +out_release:release_firmware (params.fw); out_unlock:devl_unlock (devlink);
Signature · 1 line
2.43.0
Re: [PATCH net] devlink: request flash firmware without instance lock
Quoted 11 lines · Miguel Garcia
request_firmware()may enter the userspace fallback and calltry_to_freeze(). Holding the devlink instance lock across that call triggers a lockdep warning and can block unregister for the duration of the firmware fallback.Drop the instance lock around firmware loading in both flash update paths. The callers hold a devlink reference, which also pins the parent device. Recheck registration after reacquiring the lock before calling into the driver.
Fixes b44cfd4f5b91 ("devlink: move request_firmware out of driver")
Jacob Keller was the author of this patch. It would be good to Cc:
him.
Andrew