* Re: [syzbot] [wireless?] INFO: trying to register non-static key in cfg80211_dev_free
2025-03-17 20:04 [syzbot] [wireless?] INFO: trying to register non-static key in cfg80211_dev_free syzbot
@ 2025-03-18 2:01 ` Edward Adam Davis
2025-03-18 2:17 ` syzbot
2025-03-18 2:03 ` Edward Adam Davis
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Edward Adam Davis @ 2025-03-18 2:01 UTC (permalink / raw)
To: syzbot+aaf0488c83d1d5f4f029; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 828e29872633..df3ea9ee3ee9 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -1193,10 +1193,12 @@ void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
struct cfg80211_beacon_registration *reg, *treg;
unsigned long flags;
- spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
- WARN_ON(!list_empty(&rdev->wiphy_work_list));
- spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
- cancel_work_sync(&rdev->wiphy_work);
+ if (!rdev->wiphy.rfkill) {
+ spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
+ WARN_ON(!list_empty(&rdev->wiphy_work_list));
+ spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
+ cancel_work_sync(&rdev->wiphy_work);
+ }
rfkill_destroy(rdev->wiphy.rfkill);
list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) {
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [syzbot] [wireless?] INFO: trying to register non-static key in cfg80211_dev_free
2025-03-18 2:01 ` Edward Adam Davis
@ 2025-03-18 2:17 ` syzbot
0 siblings, 0 replies; 8+ messages in thread
From: syzbot @ 2025-03-18 2:17 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
INFO: trying to register non-static key in cfg80211_dev_free
RBP: 00007f4a52781090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 0000000000000000 R14: 00007f4a51ba5fa0 R15: 00007fff60422438
</TASK>
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
CPU: 0 UID: 0 PID: 6546 Comm: syz.0.16 Not tainted 6.14.0-rc7-syzkaller-g4701f33a1070-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
assign_lock_key kernel/locking/lockdep.c:983 [inline]
register_lock_class+0xc39/0x1240 kernel/locking/lockdep.c:1297
__lock_acquire+0x135/0x3c40 kernel/locking/lockdep.c:5103
lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5851
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162
cfg80211_dev_free+0x2b1/0x420 net/wireless/core.c:1197
device_release+0xa1/0x240 drivers/base/core.c:2568
kobject_cleanup lib/kobject.c:689 [inline]
kobject_release lib/kobject.c:720 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1e4/0x5a0 lib/kobject.c:737
put_device+0x1f/0x30 drivers/base/core.c:3774
wiphy_free net/wireless/core.c:1226 [inline]
wiphy_new_nm+0x1c1f/0x2160 net/wireless/core.c:562
ieee80211_alloc_hw_nm+0x1b7a/0x2260 net/mac80211/main.c:835
mac80211_hwsim_new_radio+0x1d6/0x54e0 drivers/net/wireless/virtual/mac80211_hwsim.c:5185
hwsim_new_radio_nl+0xb42/0x12b0 drivers/net/wireless/virtual/mac80211_hwsim.c:6242
genl_family_rcv_msg_doit+0x202/0x2f0 net/netlink/genetlink.c:1115
genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline]
genl_rcv_msg+0x565/0x800 net/netlink/genetlink.c:1210
netlink_rcv_skb+0x16b/0x440 net/netlink/af_netlink.c:2533
genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219
netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
netlink_unicast+0x53c/0x7f0 net/netlink/af_netlink.c:1338
netlink_sendmsg+0x8b8/0xd70 net/netlink/af_netlink.c:1882
sock_sendmsg_nosec net/socket.c:718 [inline]
__sock_sendmsg net/socket.c:733 [inline]
____sys_sendmsg+0xaaf/0xc90 net/socket.c:2573
___sys_sendmsg+0x135/0x1e0 net/socket.c:2627
__sys_sendmsg+0x16e/0x220 net/socket.c:2659
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4a5198d169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f4a52781038 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f4a51ba5fa0 RCX: 00007f4a5198d169
RDX: 0000000020000000 RSI: 0000400000000140 RDI: 0000000000000003
RBP: 00007f4a52781090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 0000000000000000 R14: 00007f4a51ba5fa0 R15: 00007fff60422438
</TASK>
------------[ cut here ]------------
WARNING: CPU: 0 PID: 6546 at net/wireless/core.c:1198 cfg80211_dev_free+0x324/0x420 net/wireless/core.c:1198
Modules linked in:
CPU: 0 UID: 0 PID: 6546 Comm: syz.0.16 Not tainted 6.14.0-rc7-syzkaller-g4701f33a1070-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:cfg80211_dev_free+0x324/0x420 net/wireless/core.c:1198
Code: 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 80 3c 02 00 0f 85 e6 00 00 00 49 8b 9d 08 0e 00 00 e9 2e fd ff ff e8 4d 10 11 f7 90 <0f> 0b 90 eb b2 4c 89 ff e8 bf 22 74 f7 e9 04 ff ff ff 48 89 ef e8
RSP: 0018:ffffc90003fff1b8 EFLAGS: 00010093
RAX: 0000000000000000 RBX: 0000000000000293 RCX: ffffffff81972ead
RDX: ffff88802d654880 RSI: ffffffff8aa8e213 RDI: ffffc90003fff128
RBP: ffff88802c9d8e08 R08: 0000000000000001 R09: fffff520007ffe25
R10: 0000000000000003 R11: 0000000000000001 R12: ffff88802c9d86a8
R13: ffff88802c9d8000 R14: ffff88802c9d86b8 R15: 0000000000000000
FS: 00007f4a527816c0(0000) GS:ffff88806a600000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000400000001ac0 CR3: 0000000030dea000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
device_release+0xa1/0x240 drivers/base/core.c:2568
kobject_cleanup lib/kobject.c:689 [inline]
kobject_release lib/kobject.c:720 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1e4/0x5a0 lib/kobject.c:737
put_device+0x1f/0x30 drivers/base/core.c:3774
wiphy_free net/wireless/core.c:1226 [inline]
wiphy_new_nm+0x1c1f/0x2160 net/wireless/core.c:562
ieee80211_alloc_hw_nm+0x1b7a/0x2260 net/mac80211/main.c:835
mac80211_hwsim_new_radio+0x1d6/0x54e0 drivers/net/wireless/virtual/mac80211_hwsim.c:5185
hwsim_new_radio_nl+0xb42/0x12b0 drivers/net/wireless/virtual/mac80211_hwsim.c:6242
genl_family_rcv_msg_doit+0x202/0x2f0 net/netlink/genetlink.c:1115
genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline]
genl_rcv_msg+0x565/0x800 net/netlink/genetlink.c:1210
netlink_rcv_skb+0x16b/0x440 net/netlink/af_netlink.c:2533
genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219
netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
netlink_unicast+0x53c/0x7f0 net/netlink/af_netlink.c:1338
netlink_sendmsg+0x8b8/0xd70 net/netlink/af_netlink.c:1882
sock_sendmsg_nosec net/socket.c:718 [inline]
__sock_sendmsg net/socket.c:733 [inline]
____sys_sendmsg+0xaaf/0xc90 net/socket.c:2573
___sys_sendmsg+0x135/0x1e0 net/socket.c:2627
__sys_sendmsg+0x16e/0x220 net/socket.c:2659
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4a5198d169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f4a52781038 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f4a51ba5fa0 RCX: 00007f4a5198d169
RDX: 0000000020000000 RSI: 0000400000000140 RDI: 0000000000000003
RBP: 00007f4a52781090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 0000000000000000 R14: 00007f4a51ba5fa0 R15: 00007fff60422438
</TASK>
Tested on:
commit: 4701f33a Linux 6.14-rc7
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10466474580000
kernel config: https://syzkaller.appspot.com/x/.config?x=2e330e9768b5b8ff
dashboard link: https://syzkaller.appspot.com/bug?extid=aaf0488c83d1d5f4f029
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1684c44c580000
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [syzbot] [wireless?] INFO: trying to register non-static key in cfg80211_dev_free
2025-03-17 20:04 [syzbot] [wireless?] INFO: trying to register non-static key in cfg80211_dev_free syzbot
2025-03-18 2:01 ` Edward Adam Davis
@ 2025-03-18 2:03 ` Edward Adam Davis
2025-03-18 2:36 ` syzbot
2025-03-18 2:26 ` Edward Adam Davis
2025-03-18 3:13 ` [PATCH] wifi: cfg80211: init wiphy_work before allocating rfkill fails Edward Adam Davis
3 siblings, 1 reply; 8+ messages in thread
From: Edward Adam Davis @ 2025-03-18 2:03 UTC (permalink / raw)
To: syzbot+aaf0488c83d1d5f4f029; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 828e29872633..df3ea9ee3ee9 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -1193,10 +1193,12 @@ void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
struct cfg80211_beacon_registration *reg, *treg;
unsigned long flags;
- spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
- WARN_ON(!list_empty(&rdev->wiphy_work_list));
- spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
- cancel_work_sync(&rdev->wiphy_work);
+ if (rdev->wiphy.rfkill) {
+ spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
+ WARN_ON(!list_empty(&rdev->wiphy_work_list));
+ spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
+ cancel_work_sync(&rdev->wiphy_work);
+ }
rfkill_destroy(rdev->wiphy.rfkill);
list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) {
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [syzbot] [wireless?] INFO: trying to register non-static key in cfg80211_dev_free
2025-03-17 20:04 [syzbot] [wireless?] INFO: trying to register non-static key in cfg80211_dev_free syzbot
2025-03-18 2:01 ` Edward Adam Davis
2025-03-18 2:03 ` Edward Adam Davis
@ 2025-03-18 2:26 ` Edward Adam Davis
2025-03-18 2:54 ` syzbot
2025-03-18 3:13 ` [PATCH] wifi: cfg80211: init wiphy_work before allocating rfkill fails Edward Adam Davis
3 siblings, 1 reply; 8+ messages in thread
From: Edward Adam Davis @ 2025-03-18 2:26 UTC (permalink / raw)
To: syzbot+aaf0488c83d1d5f4f029; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 828e29872633..ceb768925b85 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -546,6 +546,9 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
INIT_WORK(&rdev->mgmt_registrations_update_wk,
cfg80211_mgmt_registrations_update_wk);
spin_lock_init(&rdev->mgmt_registrations_lock);
+ INIT_WORK(&rdev->wiphy_work, cfg80211_wiphy_work);
+ INIT_LIST_HEAD(&rdev->wiphy_work_list);
+ spin_lock_init(&rdev->wiphy_work_lock);
#ifdef CONFIG_CFG80211_DEFAULT_PS
rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
@@ -563,9 +566,6 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
return NULL;
}
- INIT_WORK(&rdev->wiphy_work, cfg80211_wiphy_work);
- INIT_LIST_HEAD(&rdev->wiphy_work_list);
- spin_lock_init(&rdev->wiphy_work_lock);
INIT_WORK(&rdev->rfkill_block, cfg80211_rfkill_block_work);
INIT_WORK(&rdev->conn_work, cfg80211_conn_work);
INIT_WORK(&rdev->event_work, cfg80211_event_work);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] wifi: cfg80211: init wiphy_work before allocating rfkill fails
2025-03-17 20:04 [syzbot] [wireless?] INFO: trying to register non-static key in cfg80211_dev_free syzbot
` (2 preceding siblings ...)
2025-03-18 2:26 ` Edward Adam Davis
@ 2025-03-18 3:13 ` Edward Adam Davis
3 siblings, 0 replies; 8+ messages in thread
From: Edward Adam Davis @ 2025-03-18 3:13 UTC (permalink / raw)
To: syzbot+aaf0488c83d1d5f4f029
Cc: johannes, linux-kernel, linux-wireless, netdev, syzkaller-bugs
syzbort reported a uninitialize wiphy_work_lock in cfg80211_dev_free. [1]
After rfkill allocation fails, the wiphy release process will be performed,
which will cause cfg80211_dev_free to access the uninitialized wiphy_work
related data.
Move the initialization of wiphy_work to before rfkill initialization to
avoid this issue.
[1]
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
CPU: 0 UID: 0 PID: 5935 Comm: syz-executor550 Not tainted 6.14.0-rc6-syzkaller-00103-g4003c9e78778 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
assign_lock_key kernel/locking/lockdep.c:983 [inline]
register_lock_class+0xc39/0x1240 kernel/locking/lockdep.c:1297
__lock_acquire+0x135/0x3c40 kernel/locking/lockdep.c:5103
lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5851
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162
cfg80211_dev_free+0x30/0x3d0 net/wireless/core.c:1196
device_release+0xa1/0x240 drivers/base/core.c:2568
kobject_cleanup lib/kobject.c:689 [inline]
kobject_release lib/kobject.c:720 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1e4/0x5a0 lib/kobject.c:737
put_device+0x1f/0x30 drivers/base/core.c:3774
wiphy_free net/wireless/core.c:1224 [inline]
wiphy_new_nm+0x1c1f/0x2160 net/wireless/core.c:562
ieee80211_alloc_hw_nm+0x1b7a/0x2260 net/mac80211/main.c:835
mac80211_hwsim_new_radio+0x1d6/0x54e0 drivers/net/wireless/virtual/mac80211_hwsim.c:5185
hwsim_new_radio_nl+0xb42/0x12b0 drivers/net/wireless/virtual/mac80211_hwsim.c:6242
genl_family_rcv_msg_doit+0x202/0x2f0 net/netlink/genetlink.c:1115
genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline]
genl_rcv_msg+0x565/0x800 net/netlink/genetlink.c:1210
netlink_rcv_skb+0x16b/0x440 net/netlink/af_netlink.c:2533
genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219
netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
netlink_unicast+0x53c/0x7f0 net/netlink/af_netlink.c:1338
netlink_sendmsg+0x8b8/0xd70 net/netlink/af_netlink.c:1882
sock_sendmsg_nosec net/socket.c:718 [inline]
__sock_sendmsg net/socket.c:733 [inline]
____sys_sendmsg+0xaaf/0xc90 net/socket.c:2573
___sys_sendmsg+0x135/0x1e0 net/socket.c:2627
__sys_sendmsg+0x16e/0x220 net/socket.c:2659
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
Fixes: 72d520476a2f ("wifi: cfg80211: cancel wiphy_work before freeing wiphy")
Reported-by: syzbot+aaf0488c83d1d5f4f029@syzkaller.appspotmail.com
Close: https://syzkaller.appspot.com/bug?extid=aaf0488c83d1d5f4f029
Tested-by: syzbot+aaf0488c83d1d5f4f029@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
net/wireless/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 828e29872633..ceb768925b85 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -546,6 +546,9 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
INIT_WORK(&rdev->mgmt_registrations_update_wk,
cfg80211_mgmt_registrations_update_wk);
spin_lock_init(&rdev->mgmt_registrations_lock);
+ INIT_WORK(&rdev->wiphy_work, cfg80211_wiphy_work);
+ INIT_LIST_HEAD(&rdev->wiphy_work_list);
+ spin_lock_init(&rdev->wiphy_work_lock);
#ifdef CONFIG_CFG80211_DEFAULT_PS
rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
@@ -563,9 +566,6 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
return NULL;
}
- INIT_WORK(&rdev->wiphy_work, cfg80211_wiphy_work);
- INIT_LIST_HEAD(&rdev->wiphy_work_list);
- spin_lock_init(&rdev->wiphy_work_lock);
INIT_WORK(&rdev->rfkill_block, cfg80211_rfkill_block_work);
INIT_WORK(&rdev->conn_work, cfg80211_conn_work);
INIT_WORK(&rdev->event_work, cfg80211_event_work);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread