INFO: trying to register non-static key in devres_for_each_res

Status: moderation: reported on 2026/11/09 03:10
Subsystems: driver-core
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+5eec79c475cc9560c8ac@syzkaller.appspotmail.com
First crash: 1h47m, last: 1h47m
✨ AI-generated root cause summary:

During power management hibernation preparation triggered by snapshot_open(), fw_pm_notify() calls device_cache_fw_images(), which iterates across all registered devices on dpm_list using dpm_for_each_dev(). For each device, devres_for_each_res() is invoked to search for firmware cache resources, attempting to acquire &dev->devres_lock and traverse &dev->devres_head via list_for_each_entry_safe_reverse(). A device on dpm_list had uninitialized/zeroed devres_lock and devres_head fields, causing lockdep to warn on the unregistered lock key and devres_for_each_res() to read dev->devres_head.prev as NULL. Attempting to evaluate list_prev_entry() on the resulting NULL devres_node dereferenced offset 0x8, triggering a fatal NULL-pointer dereference (KASAN: null-ptr-deref).

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 58c1eb84e977:

Technical Analysis and Root Cause Investigation

1. Crash Site and Call Path

The failure occurs when opening /dev/snapshot (snapshot_open() in kernel/power/user.c), which invokes the power management notification chain:

snapshot_open()
  pm_notifier_call_chain_robust(PM_HIBERNATION_PREPARE)
    notifier_call_chain_robust()
      fw_pm_notify() (drivers/base/firmware_loader/main.c:1618)
        device_cache_fw_images() (drivers/base/firmware_loader/main.c:1568)
          dpm_for_each_dev(NULL, dev_cache_fw_image) (drivers/base/power/main.c:2429)
            dev_cache_fw_image(dev, NULL) (drivers/base/firmware_loader/main.c:1498)
              devres_for_each_res(dev, fw_name_devm_release, ...) (drivers/base/devres.c:223-224)

In devres_for_each_res() (drivers/base/devres.c):

223:	guard(spinlock_irqsave)(&dev->devres_lock);
224:	list_for_each_entry_safe_reverse(node, tmp,
225:			&dev->devres_head, entry) {

2. Detailed Disassembly and State at Crash

From the register state and disassembly:

  • x19 (0xffff0000c94427d8) is the target struct device *dev.
  • x28 (0xffff0000c9442c60) corresponds exactly to &dev->devres_head (offsetof(struct device, devres_head) == 0x488).
  • x20 (0xffff0000c9442c68) is &dev->devres_head.prev (x28 + 8).
  • x22 loaded from [x20] is 0x0 (NULL).

Prior to the crash, acquiring &dev->devres_lock triggered:

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?

This indicates that dev->devres_lock was all zeroes (its lockdep_map.key was 0 and unregistered).

Following lock acquisition, list_for_each_entry_safe_reverse() expands to:

pos = list_last_entry(head, typeof(*pos), member); // container_of(head->prev, ...)
n = list_prev_entry(pos, member);                   // pos->entry.prev

Because dev->devres_head.prev is 0x0 (NULL), pos becomes NULL (since devres_node.entry is at offset 0). The macro then calculates n = pos->entry.prev, dereferencing offset 0x8 (*(NULL + 8)). On an arm64 KASAN-instrumented kernel, reading address 0x8 accesses KASAN shadow address 0xdfff800000000000 + (0x8 >> 3) = 0xdfff800000000001, producing: KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] followed by an unhandled translation fault (kernel Oops).

3. Invariants Checked and Object Lifecycle Findings

  • device_initialize() vs. device_add() Invariants: In drivers/base/core.c, device_initialize() initializes dev->devres_lock, INIT_LIST_HEAD(&dev->devres_head), dev->mutex, and calls device_pm_init(dev). Furthermore, device_add() acquires dev->mutex and calls device_pm_check_callbacks(dev) (which locks dev->power.lock). Had device_initialize() not been called before device_add(), lockdep warnings would have triggered earlier during device_add().
  • Error unwinding in device_add(): In device_add(), device_pm_add(dev) adds the device to dpm_list. Any subsequent failure in device_add() jumps to DevAttrError, which properly calls device_pm_remove(dev) to unlink the device from dpm_list.
  • Uninitialized Structure Handling in devres: Unlike devres_release_all() (drivers/base/devres.c:565), which explicitly guards against uninitialized devices (if (WARN_ON(dev->devres_head.next == NULL)) return -ENODEV;), devres_for_each_res() performs no sanity check on dev->devres_head or dev->devres_lock.
  • Dangling / Zeroed Object on dpm_list: Because KASAN did not report a slab use-after-free upon accessing dev->devres_lock or dev->devres_head, the memory backing x19 is currently valid/allocated in KASAN shadow memory, yet its device fields are zeroed. This demonstrates that a struct device linked in dpm_list either:
    1. Had its memory zeroed/overwritten in-place while still linked in dpm_list, or
    2. Was freed without being unregistered (device_del() / device_pm_remove()), leaving a dangling power.entry on dpm_list, and the slab memory was subsequently reallocated (e.g., via kzalloc()) and zeroed before dpm_for_each_dev() was invoked.
▶ ▼ ✨ AI Jobs (1)
ID Workflow Result Correct Bug Created Started Finished Revision
3ad718ed assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ INFO: trying to register non-static key in devres_for_each_res 2026/11/09 02:37 2026/11/09 02:37 2026/11/09 03:06 5cecaf1f
▶ ▼ Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 INFO: trying to register non-static key in devres_for_each_res -1 1 2373d 2373d 0/1 auto-closed as invalid on 2020/09/07 23:32
linux-4.19 INFO: trying to register non-static key in devres_for_each_res -1 1 1762d 1762d 0/1 auto-closed as invalid on 2022/05/11 23:24

Sample crash report:
random: crng reseeded on system resumption
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: 6639 Comm: syz.7.332 Tainted: G   M                syzkaller #0 PREEMPT 
Tainted: [M]=MACHINE_CHECK
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
Call trace:
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:499 (C)
 __dump_stack+0x30/0x40 lib/dump_stack.c:94
 dump_stack_lvl+0xd8/0x12c lib/dump_stack.c:120
 dump_stack+0x1c/0x28 lib/dump_stack.c:129
 assign_lock_key+0xcc/0xdc kernel/locking/lockdep.c:1028
 register_lock_class+0xf8/0x31c kernel/locking/lockdep.c:1343
 __lock_acquire+0x140/0x2b08 kernel/locking/lockdep.c:5162
 lock_acquire+0x13c/0x320 kernel/locking/lockdep.c:5942
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:155 [inline]
 _raw_spin_lock_irqsave+0x5c/0x7c kernel/locking/spinlock.c:181
 class_spinlock_irqsave_constructor include/linux/spinlock.h:643 [inline]
 devres_for_each_res+0x54/0x1a8 drivers/base/devres.c:223
 dev_cache_fw_image+0xe4/0x3c0 drivers/base/firmware_loader/main.c:1498
 dpm_for_each_dev+0x60/0xc0 drivers/base/power/main.c:2429
 device_cache_fw_images drivers/base/firmware_loader/main.c:1568 [inline]
 fw_pm_notify+0x208/0x2b8 drivers/base/firmware_loader/main.c:1618
 notifier_call_chain+0x1a4/0x4cc kernel/notifier.c:86
 notifier_call_chain_robust+0x54/0xc4 kernel/notifier.c:121
 blocking_notifier_call_chain_robust+0x74/0xa8 kernel/notifier.c:398
 pm_notifier_call_chain_robust+0x34/0x60 kernel/power/main.c:172
 snapshot_open+0x11c/0x270 kernel/power/user.c:87
 misc_open+0x2dc/0x338 drivers/char/misc.c:163
 chrdev_open+0x398/0x3e8 fs/char_dev.c:413
 do_dentry_open+0x5bc/0xfb4 fs/open.c:1000
 vfs_open_consume+0x54/0x2ec fs/open.c:1131
 do_open fs/namei.c:4851 [inline]
 path_openat+0x1098/0x1910 fs/namei.c:5016
 do_file_open+0x1c8/0x2e8 fs/namei.c:5045
 do_sys_openat2+0x114/0x1ec fs/open.c:1442
 do_sys_open+0xb0/0xe0 fs/open.c:1448
 __do_sys_openat fs/open.c:1464 [inline]
 __se_sys_openat fs/open.c:1459 [inline]
 __arm64_sys_openat+0xa8/0xc4 fs/open.c:1459
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606
Unable to handle kernel paging request at virtual address dfff800000000001
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
Mem abort info:
  ESR = 0x0000000096000005
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x05: level 1 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
  CM = 0, WnR = 0, TnD = 0, TagAccess = 0
  GCS = 0, Overlay = 0, DirtyBit = 0
[dfff800000000001] address between user and kernel address ranges
Internal error: Oops: 0000000096000005 [#1]  SMP
Modules linked in:
CPU: 0 UID: 0 PID: 6639 Comm: syz.7.332 Tainted: G   M                syzkaller #0 PREEMPT 
Tainted: [M]=MACHINE_CHECK
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
pstate: 034000c5 (nzcv daIF +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : devres_for_each_res+0x94/0x1a8 drivers/base/devres.c:224
lr : class_spinlock_irqsave_constructor include/linux/spinlock.h:643 [inline]
lr : devres_for_each_res+0x54/0x1a8 drivers/base/devres.c:223
sp : ffff800098c07360
x29: ffff800098c07380 x28: ffff0000c9442c60 x27: dfff800000000000
x26: ffff80008f852650 x25: ffff80008259ffd8 x24: ffff8000825d8d0c
x23: ffff8000825d9c6c x22: 0000000000000000 x21: ffff8000825d9ccc
x20: ffff0000c9442c68 x19: ffff0000c94427d8 x18: 1fffe000359cf228
x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
x14: 0000000000000e68 x13: 0000000000000001 x12: 0000000000000004
x11: ffff700013180e50 x10: ffff700013180e50 x9 : 3eb6a59f390f4600
x8 : 0000000000000001 x7 : 0000000000000000 x6 : ffff8000804a0a1c
x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff80008047ebe8
x2 : 0000000000000001 x1 : 0000000000000000 x0 : 0000000000000000
Call trace:
 devres_for_each_res+0x94/0x1a8 drivers/base/devres.c:224 (P)
 dev_cache_fw_image+0xe4/0x3c0 drivers/base/firmware_loader/main.c:1498
 dpm_for_each_dev+0x60/0xc0 drivers/base/power/main.c:2429
 device_cache_fw_images drivers/base/firmware_loader/main.c:1568 [inline]
 fw_pm_notify+0x208/0x2b8 drivers/base/firmware_loader/main.c:1618
 notifier_call_chain+0x1a4/0x4cc kernel/notifier.c:86
 notifier_call_chain_robust+0x54/0xc4 kernel/notifier.c:121
 blocking_notifier_call_chain_robust+0x74/0xa8 kernel/notifier.c:398
 pm_notifier_call_chain_robust+0x34/0x60 kernel/power/main.c:172
 snapshot_open+0x11c/0x270 kernel/power/user.c:87
 misc_open+0x2dc/0x338 drivers/char/misc.c:163
 chrdev_open+0x398/0x3e8 fs/char_dev.c:413
 do_dentry_open+0x5bc/0xfb4 fs/open.c:1000
 vfs_open_consume+0x54/0x2ec fs/open.c:1131
 do_open fs/namei.c:4851 [inline]
 path_openat+0x1098/0x1910 fs/namei.c:5016
 do_file_open+0x1c8/0x2e8 fs/namei.c:5045
 do_sys_openat2+0x114/0x1ec fs/open.c:1442
 do_sys_open+0xb0/0xe0 fs/open.c:1448
 __do_sys_openat fs/open.c:1464 [inline]
 __se_sys_openat fs/open.c:1459 [inline]
 __arm64_sys_openat+0xa8/0xc4 fs/open.c:1459
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606
Code: 90000019 913f6339 910022c8 d343fd08 (387b6908) 
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
   0:	90000019 	adrp	x25, 0x0
   4:	913f6339 	add	x25, x25, #0xfd8
   8:	910022c8 	add	x8, x22, #0x8
   c:	d343fd08 	lsr	x8, x8, #3
* 10:	387b6908 	ldrb	w8, [x8, x27] <-- trapping instruction

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/09 02:31 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 58c1eb84e977 5cecaf1f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 INFO: trying to register non-static key in devres_for_each_res
* Struck through repros no longer work on HEAD.