CVE-2026-105415: Out-of-bounds write via unchecked channel index in ESP32 MCPWM PWM driver set_cycles syscall
The Espressif MCPWM PWM driver (drivers/pwm/pwmmcesp32.c) indexed its per-channel configuration array config->channelconfig[] with the caller-supplied channelidx in mcpwmesp32setcycles() without any bounds check; the existing if (!channel) test can never fail. The driver then wrote channel->freq, channel->duty and channel->inverted through the out-of-bounds element and used out-of-bounds timerid/operatorid/generatorid values to index MCPWM hardware registers.
pwmsetcycles() is a system call, and neither zvrfypwmsetcycles() nor zimplpwmsetcycles() validates the channel. With CONFIGUSERSPACE enabled on an Espressif RISC-V SoC with PMP (ESP32-C6, and ESP32-C5 in later code), an unprivileged user-mode thread that has been granted access to the MCPWM device can pass an arbitrary channel number and cause the kernel-mode driver to write outside the array.
The configuration object is a writable static in kernel RAM, so this gives a user thread a partially controlled kernel memory write (and stray peripheral register writes), which can crash the system and may be leveraged for privilege escalation. Builds without CONFIGUSERSPACE are not affected in a security sense, since only trusted code can call the driver. The fix adds a channel bounds check to mcpwmesp32setcycles().
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
Add a bounds check for channel_idx in mcpwm_esp32_set_cycles() before indexing config->channel_config[].
Event History
Frequently Asked Questions
Which deployments are meaningfully exposed to this issue?
Security exposure requires CONFIG_USERSPACE on an Espressif RISC-V SoC with PMP, identified as ESP32-C6 and ESP32-C5 in later code. An unprivileged user-mode thread must also have been granted access to the MCPWM device.
What must an attacker be able to do?
The attacker needs to run an unprivileged user-mode thread with MCPWM device access and invoke pwm_set_cycles() with an arbitrary channel number. No user interaction is required.
What could successful exploitation cause?
The unchecked channel value can produce a partially controlled write to kernel RAM and unintended MCPWM peripheral-register writes. This can crash the system and may be leveraged for privilege escalation.
Are builds without userspace affected as a security boundary issue?
Builds without CONFIG_USERSPACE are not affected in a security sense, because there is no unprivileged user-mode caller crossing into the kernel-mode driver.
How can I assess whether a device is exposed?
Check whether CONFIG_USERSPACE is enabled, whether the target is an affected Espressif RISC-V SoC with PMP, and whether unprivileged threads have access to an MCPWM device. All of these conditions are needed for the described security impact.