syzbot
WARNING in rfkill_dev_uevent
Status:
upstream: reported C repro on 2026/10/31 08:52
Subsystems:
wireless
Labels:
prio:low
[Documentation on labels]
Reported-by: syzbot+56f5119a6b206041a6b7@syzkaller.appspotmail.com
First crash: 21d, last: 1d12h
⨠AI-generated root cause summary:
In mac80211_hwsim and cfg80211, the netlink attribute HWSIM_ATTR_RADIO_NAME is accepted without a length limit, and cfg80211 does not bound requested_name when setting the device and rfkill names. When a user creates a virtual radio with an excessively long name via netlink, rfkill registration triggers a uevent where RFKILL_NAME exceeds the fixed 2048-byte UEVENT_BUFFER_SIZE in add_uevent_var(), triggering a WARN. In production kernels, add_uevent_var() safely returns -ENOMEM and drops the uevent without memory corruption or system crashes.
▶
▼
⨠Full AI root cause analysis
Root Cause Analysis
1. Components and Files Involved
drivers/net/wireless/virtual/mac80211_hwsim_main.c: In hwsim_genl_policy, [HWSIM_ATTR_RADIO_NAME] = { .type = NLA_STRING } is defined without .len bounds. In hwsim_new_radio_nl(), the attribute is duplicated with kstrndup() without validating or capping its length before passing it to mac80211_hwsim_new_radio().
net/wireless/core.c: wiphy_new_nm() accepts requested_name without length restriction, assigns it as the device name via dev_set_name(&rdev->wiphy.dev, "%s", requested_name), and subsequently forwards dev_name(&rdev->wiphy.dev) to rfkill_alloc().
net/rfkill/core.c: rfkill_alloc() stores the wiphy name in rfkill->name. When rfkill_register() is invoked during wiphy_register(), device_add() triggers a kobject_uevent() with action KOBJ_ADD.
lib/kobject_uevent.c: During the KOBJ_ADD event dispatch, rfkill_dev_uevent() formats environment variables including "RFKILL_NAME=%s" into the fixed-size 2048-byte buffer (env->buf of struct kobj_uevent_env). add_uevent_var() checks if the formatted variable exceeds available buffer space.
2. Trigger Mechanism & Lifecycle Violation
- A userspace process sends a Generic Netlink command
HWSIM_CMD_NEW_RADIO with an oversized HWSIM_ATTR_RADIO_NAME attribute (several kilobytes long).
hwsim_new_radio_nl() accepts the name and calls mac80211_hwsim_new_radio(), which calls ieee80211_alloc_hw_nm() -> wiphy_new_nm().
- In
net/mac80211/main.c, ieee80211_register_hw() invokes alloc_ordered_workqueue("%s", 0, wiphy_name(local->hw.wiphy)) which emits:
workqueue: name exceeds WQ_NAME_LEN. Truncating to: ...
ieee80211_register_hw() then calls wiphy_register(), which calls rfkill_register(rdev->wiphy.rfkill) -> device_add(&rfkill->dev).
device_add() calls kobject_uevent(&dev->kobj, KOBJ_ADD) -> kobject_uevent_env() -> rfkill_dev_uevent().
rfkill_dev_uevent() calls add_uevent_var(env, "RFKILL_NAME=%s", rfkill->name).
- Because
rfkill->name exceeds the remaining capacity of the 2048-byte UEVENT_BUFFER_SIZE, vsnprintf() returns a length greater than or equal to sizeof(env->buf) - env->buflen.
add_uevent_var() detects this buffer overflow condition, hits line 688 (WARN(1, KERN_ERR "add_uevent_var: buffer size too small\n");), and returns -ENOMEM.
3. Runtime Consequences in Production Kernels
- Memory Corruption (
false): add_uevent_var() bounds formatting using vsnprintf() against sizeof(env->buf) - env->buflen and checks for truncation before advancing env->buflen or updating pointers. There is no out-of-bounds write, use-after-free, or corrupted memory state.
- Information Leak (
"none"): No uninitialized or kernel memory is leaked to userspace.
- Denial of Service (
false): In a production kernel without CONFIG_PANIC_ON_WARN, the warning does not halt execution. add_uevent_var() returns -ENOMEM, which causes kobject_uevent_env() to discard the uevent buffer and cleanly return -ENOMEM. The return code of kobject_uevent() is ignored in device_add(), meaning registration finishes normally and no hang, panic, or unhandled leak occurs.
- Networking Candidate (
true): The bug is triggered via netlink into mac80211_hwsim, cfg80211, and rfkill.
- KVM Candidate (
false): Virtualization / KVM subsystems are not involved.
Sample crash report:
workqueue: name exceeds WQ_NAME_LEN. Truncating to: ’„śeč45µ8000000 goto pc+2
------------[ cut here ]------------
add_uevent_var: buffer size too small
WARNING: lib/kobject_uevent.c:688 at add_uevent_var+0x336/0x3a0 lib/kobject_uevent.c:688, CPU#1: syz.0.17/6011
Modules linked in:
CPU: 1 UID: 0 PID: 6011 Comm: syz.0.17 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
RIP: 0010:add_uevent_var+0x336/0x3a0 lib/kobject_uevent.c:688
Code: ff ff e8 7d a0 27 f6 48 8d 3d a6 4e 96 06 67 48 0f b9 3a 41 bc f4 ff ff ff e9 57 ff ff ff e8 61 a0 27 f6 48 8d 3d 9a 4e 96 06 <67> 48 0f b9 3a eb e2 4c 89 ee 48 c7 c7 80 c3 4c 92 e8 14 60 51 f5
RSP: 0018:ffffc90005c36bd8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 1ffff92000b86d7e RCX: 0000000000000000
RDX: ffff888030f52580 RSI: ffffffff8be6e09f RDI: ffffffff927d2f40
RBP: ffffc90005c36cc8 R08: 0000000000001770 R09: 000000000000079d
R10: ffff88802dfae28a R11: 0000000000000000 R12: ffff88802dfae000
R13: 0000000000000063 R14: ffff88802dfae218 R15: 0000000000000063
FS: 000055555d669500(0000) GS:ffff8880d456e000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f534fe71f20 CR3: 000000002b75a000 CR4: 0000000000352ef0
Call Trace:
<TASK>
rfkill_dev_uevent+0x31/0x220 net/rfkill/core.c:875
dev_uevent+0x26f/0x870 drivers/base/core.c:2774
kobject_uevent_env+0x6eb/0x18b0 lib/kobject_uevent.c:576
device_add+0x1173/0x1970 drivers/base/core.c:3744
rfkill_register+0x1ad/0xb30 net/rfkill/core.c:1100
wiphy_register+0x2a64/0x3380 net/wireless/core.c:1309
ieee80211_register_hw+0x3086/0x45c0 net/mac80211/main.c:1634
mac80211_hwsim_new_radio+0x2b01/0x66f0 drivers/net/wireless/virtual/mac80211_hwsim_main.c:6186
hwsim_new_radio_nl+0xc6b/0x13f0 drivers/net/wireless/virtual/mac80211_hwsim_main.c:7062
genl_family_rcv_msg_doit+0x214/0x300 net/netlink/genetlink.c:1114
genl_family_rcv_msg net/netlink/genetlink.c:1194 [inline]
genl_rcv_msg+0x560/0x800 net/netlink/genetlink.c:1209
netlink_rcv_skb+0x159/0x420 net/netlink/af_netlink.c:2585
genl_rcv+0x28/0x40 net/netlink/genetlink.c:1218
netlink_unicast_kernel net/netlink/af_netlink.c:1336 [inline]
netlink_unicast+0x668/0x950 net/netlink/af_netlink.c:1362
netlink_sendmsg+0x9ac/0x10c0 net/netlink/af_netlink.c:1921
sock_sendmsg_nosec net/socket.c:800 [inline]
__sock_sendmsg net/socket.c:818 [inline]
____sys_sendmsg+0xa13/0xb90 net/socket.c:2713
___sys_sendmsg+0x208/0x270 net/socket.c:2770
__sys_sendmsg+0x160/0x210 net/socket.c:2802
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x123/0x7b0 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f534ffa94d9
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:00007ffe9ec20288 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f5350225fa0 RCX: 00007f534ffa94d9
RDX: 0000000000000084 RSI: 0000200000000a00 RDI: 0000000000000004
RBP: 00007f535003804e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f5350225fac R14: 00007f5350225fa0 R15: 00007f5350225fa0
</TASK>
----------------
Code disassembly (best guess), 1 bytes skipped:
0: ff ljmp (bad)
1: e8 7d a0 27 f6 call 0xf627a083
6: 48 8d 3d a6 4e 96 06 lea 0x6964ea6(%rip),%rdi # 0x6964eb3
d: 67 48 0f b9 3a ud1 (%edx),%rdi
12: 41 bc f4 ff ff ff mov $0xfffffff4,%r12d
18: e9 57 ff ff ff jmp 0xffffff74
1d: e8 61 a0 27 f6 call 0xf627a083
22: 48 8d 3d 9a 4e 96 06 lea 0x6964e9a(%rip),%rdi # 0x6964ec3
* 29: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2e: eb e2 jmp 0x12
30: 4c 89 ee mov %r13,%rsi
33: 48 c7 c7 80 c3 4c 92 mov $0xffffffff924cc380,%rdi
3a: e8 14 60 51 f5 call 0xf5516053
* Struck through repros no longer work on HEAD.