WARNING in spi_register_controller (2)

Status: upstream: reported C repro on 2026/10/30 02:36
Subsystems: spi usb
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+41172204e7323356ecdb@syzkaller.appspotmail.com
First crash: 23h46m, last: 20h56m
✨ AI-generated root cause summary:
In spi_controller_id_alloc() (drivers/spi/spi.c), idr_alloc() can return -ENOMEM when radix tree memory allocation fails under memory pressure or fault injection. The function inappropriately invokes WARN(id < 0, "couldn't get idr") on any failure rather than handling expected runtime allocation errors silently. In production builds without panic_on_warn, execution continues, locks are properly released, and the error is cleanly propagated and handled by callers without causing denial of service or memory corruption.
▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit c339f4010dea:
### Root Cause Analysis #### 1. Functions, Structs, and Files Involved - **File**: `drivers/spi/spi.c` - **Function**: `spi_controller_id_alloc()` (called from `spi_register_controller()`) - **Caller Context**: `msi2500_probe()` in `drivers/media/usb/msi2500/msi2500.c` #### 2. Mechanism and Trigger During device probing (in this report, when probing a `msi2500` USB device via `msi2500_probe()`), the driver attempts to register an SPI host controller by calling `spi_register_controller()`. To allocate a dynamic bus number, `spi_register_controller()` calls `spi_controller_id_alloc(ctlr, first_dynamic, 0)`: ```c static int spi_controller_id_alloc(struct spi_controller *ctlr, int start, int end) { int id; mutex_lock(&board_lock); id = idr_alloc(&spi_controller_idr, ctlr, start, end, GFP_KERNEL); mutex_unlock(&board_lock); if (WARN(id < 0, "couldn't get idr")) return id == -ENOSPC ? -EBUSY : id; ctlr->bus_num = id; return 0; } ``` When `idr_alloc()` requires internal radix tree node allocation (`radix_tree_node_alloc()`), the memory allocation can fail if the system is under memory pressure or when fault injection (`failslab`) is activated. In such cases, `idr_alloc()` returns `-ENOMEM` (observed as `0xfffffff4` in register `R14`). However, `spi_controller_id_alloc()` inappropriately uses `WARN(id < 0, "couldn't get idr")` for all negative return values. In the Linux kernel, memory allocation failures are expected runtime conditions that must be gracefully handled rather than triggering a kernel `WARNING`. Syzkaller's fault-injection engine intercepted this `WARN()` invocation. #### 3. Production Runtime Consequences - **Production behavior without sanitizers and without `panic_on_warn`**: - `board_lock` is unlocked before the `WARN` macro. - The function returns the error code: `id == -ENOSPC ? -EBUSY : id` (evaluating to `-ENOMEM`). - `spi_register_controller()` catches the non-zero status and aborts cleanly. - `msi2500_probe()` catches the failure and follows its error path (`err_put_controller:` -> `spi_controller_put()` -> `v4l2_device_unregister()` -> `kfree()`), unwinding all allocated state cleanly. - Execution continues normally; no kernel panic, hang, deadlock, or resource leak occurs. - **Memory Corruption**: `false`. The error path is well-defined and frees resources properly without double frees, dangling references, or corruptions. - **Information Leak**: `none`. No uninitialized memory or kernel addresses are leaked. - **Raw Denial of Service**: `false`. In a standard production build without `panic_on_warn`, a `WARN` macro does not halt execution, and the failure is handled gracefully by caller error recovery. - **Networking / KVM Candidate**: `false`. Neither networking nor KVM/virtualization subsystems are involved.
▶ ▼ ✨ AI Jobs (1)
ID Workflow Result Correct Bug Created Started Finished Revision
9e01ae4c assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ WARNING in spi_register_controller (2) 2026/10/29 15:41 2026/10/29 15:42 2026/10/29 16:28 2dbcf159
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [spi?] [usb?] WARNING in spi_register_controller (2) 0 (1) 2026/10/30 02:36
▶ ▼ Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream WARNING in spi_register_controller usb spi -1 syz, C 1848 2144d 2758d 19/29 fixed on 2021/03/10 01:48

Sample crash report:
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007fe4d0225fac R14: 00007fe4d0225fa0 R15: 00007fe4d0225fa0
 </TASK>
------------[ cut here ]------------
couldn't get idr
WARNING: drivers/spi/spi.c:3634 at spi_controller_id_alloc drivers/spi/spi.c:3634 [inline], CPU#0: syz.0.17/5588
WARNING: drivers/spi/spi.c:3634 at spi_register_controller+0x1261/0x1670 drivers/spi/spi.c:3697, CPU#0: syz.0.17/5588
Modules linked in:
CPU: 0 UID: 0 PID: 5588 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:spi_controller_id_alloc drivers/spi/spi.c:3634 [inline]
RIP: 0010:spi_register_controller+0x1261/0x1670 drivers/spi/spi.c:3697
Code: 8c e8 33 d5 79 fa e9 1e ff ff ff e8 a9 a6 16 fb 48 8d 3d 72 3f 18 0b 67 48 0f b9 3a eb 11 e8 96 a6 16 fb 48 8d 3d 6f 3f 18 0b <67> 48 0f b9 3a bf e4 ff ff ff 44 89 f6 e8 8d ab 16 fb 41 83 fe e4
RSP: 0018:ffffc90004de7878 EFLAGS: 00010293
RAX: ffffffff86b27e5a RBX: ffff888050e4a000 RCX: ffff888034fc4b00
RDX: 0000000000000000 RSI: 00000000fffffff4 RDI: ffffffff91cabdd0
RBP: 0000000000000000 R08: ffffc90004de7807 R09: 1ffff920009bcf00
R10: dffffc0000000000 R11: fffff520009bcf01 R12: 1ffff1100a1c9408
R13: dffffc0000000000 R14: 00000000fffffff4 R15: ffff888050e4a4d8
FS:  000055558743d500(0000) GS:ffff88808aa10000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fbfc3e0ca90 CR3: 0000000040ab8000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 msi2500_probe+0x4c6/0x9e0 drivers/media/usb/msi2500/msi2500.c:1249
 usb_probe_interface+0x751/0xe00 drivers/usb/core/driver.c:399
 call_driver_probe drivers/base/dd.c:-1 [inline]
 really_probe+0x254/0xae0 drivers/base/dd.c:707
 __driver_probe_device+0x1e8/0x360 drivers/base/dd.c:869
 driver_probe_device+0x4f/0x240 drivers/base/dd.c:899
 __device_attach_driver+0x270/0x410 drivers/base/dd.c:1027
 bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:503
 __device_attach+0x2bd/0x430 drivers/base/dd.c:1131
 proc_ioctl+0x409/0x660 drivers/usb/core/devio.c:2370
 proc_ioctl_default+0xc4/0x110 drivers/usb/core/devio.c:2405
 usbdev_do_ioctl drivers/usb/core/devio.c:2769 [inline]
 usbdev_ioctl+0x139d/0x21a0 drivers/usb/core/devio.c:2829
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe4cff9f559
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:00007ffc6b706298 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fe4d0225fa0 RCX: 00007fe4cff9f559
RDX: 0000200000000900 RSI: 00000000c0105512 RDI: 0000000000000004
RBP: 00007ffc6b706300 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007fe4d0225fac R14: 00007fe4d0225fa0 R15: 00007fe4d0225fa0
 </TASK>
----------------
Code disassembly (best guess):
   0:	8c e8                	mov    %gs,%eax
   2:	33 d5                	xor    %ebp,%edx
   4:	79 fa                	jns    0x0
   6:	e9 1e ff ff ff       	jmp    0xffffff29
   b:	e8 a9 a6 16 fb       	call   0xfb16a6b9
  10:	48 8d 3d 72 3f 18 0b 	lea    0xb183f72(%rip),%rdi        # 0xb183f89
  17:	67 48 0f b9 3a       	ud1    (%edx),%rdi
  1c:	eb 11                	jmp    0x2f
  1e:	e8 96 a6 16 fb       	call   0xfb16a6b9
  23:	48 8d 3d 6f 3f 18 0b 	lea    0xb183f6f(%rip),%rdi        # 0xb183f99
* 2a:	67 48 0f b9 3a       	ud1    (%edx),%rdi <-- trapping instruction
  2f:	bf e4 ff ff ff       	mov    $0xffffffe4,%edi
  34:	44 89 f6             	mov    %r14d,%esi
  37:	e8 8d ab 16 fb       	call   0xfb16abc9
  3c:	41 83 fe e4          	cmp    $0xffffffe4,%r14d

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/10/29 18:31 upstream c339f4010dea 4902417d .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root WARNING in spi_register_controller
2026/10/29 17:08 upstream c339f4010dea 4902417d .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root WARNING in spi_register_controller
2026/10/29 15:41 upstream c339f4010dea 4902417d .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root WARNING in spi_register_controller
* Struck through repros no longer work on HEAD.