CVE-2026-102957: PWM capture syscall leaves callback armed on a dead kernel stack frame when called with K_NO_WAIT
zimplpwmcapturecycles() in drivers/pwm/pwmcapture.c stores its capture context (struct zpwmcapturecbdata, including a struct ksem) on its own stack and registers a pointer to it as the driver capture callback's userdata. When called with a KNOWAIT timeout, ksemtake() returns -EBUSY, which the function did not handle: it fell through, returned the uninitialized status field, copied uninitialized period/pulse values to the caller when that status happened to be zero, and returned without disabling the capture or clearing the callback.
pwmcapturecycles() is a system call, and zvrfypwmcapturecycles() passes the caller's timeout through unchanged. With CONFIGUSERSPACE and CONFIGPWMCAPTURE enabled, an unprivileged user-mode thread that has been granted access to a capture-capable PWM device can pass KNOWAIT to trigger the defect. Without userspace the function is only reachable from trusted application code.
The uninitialized values come from the thread's privileged (kernel) stack, so a user-mode caller can read up to 8 bytes of stale kernel stack memory per call. More seriously, when the capture later completes, the driver ISR invokes zpwmcapturecyclescallback() with the dangling pointer. The callback writes into the expired kernel stack region and calls ksemgive() on whatever memory now occupies it, which can corrupt live kernel stack frames and make the scheduler walk a forged wait queue. The result is kernel memory corruption from interrupt context, leading at least to a crash and possibly to privilege escalation out of the userspace sandbox. The fix rejects KNOWAIT with -EINVAL before any capture is configured.
Affected Software
Event History
Frequently Asked Questions
Which deployments are exposed to unprivileged exploitation?
Unprivileged exploitation requires both CONFIG_USERSPACE and CONFIG_PWM_CAPTURE, plus a user-mode thread that has been granted access to a PWM device capable of capture. Without userspace, the syscall is reachable only from trusted application code.
What must an attacker do to trigger the issue?
The caller must invoke pwm_capture_cycles() with a K_NO_WAIT timeout. This causes k_sem_take() to return -EBUSY, after which the capture callback can remain registered with user_data pointing to a stack frame that has already returned.
What can a successful trigger expose or affect?
A user-mode caller may receive up to 8 bytes of stale privileged kernel-stack memory per call through uninitialized period and pulse values. A later capture completion also causes the driver ISR to invoke a callback using the stale stack-backed context.
What can be done if an update cannot be applied immediately?
Do not grant unprivileged user-mode threads access to capture-capable PWM devices, and avoid calling the capture syscall with K_NO_WAIT. Systems without CONFIG_USERSPACE do not expose this path to unprivileged callers.