CVE-2026-139782: comedi: addi_apci_3xxx: fix subdevice count underallocation
In the Linux kernel, the following vulnerability has been resolved:
comedi: addiapci3xxx: fix subdevice count underallocation
In apci3xxxautoattach(), the number of subdevices is computed with
nsubdevices = (board->ainchan ? 0 : 1) + board->hasao + ...
The ternary is inverted: when the board has analog input channels (ainchan != 0), it counts 0 instead of 1, so the AI subdevice that is actually created is not accounted for. As a result comediallocsubdevices() allocates one entry too few, and the later subdevice initialization (notably the TTL Digital I/O subdevice, which is populated last) writes past the end of the allocated array, causing a slab out-of-bounds write.
Flip the ternary to count 1 when ainchan is non-zero and 0 otherwise, matching the subdevice creation order in the function.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.10.275 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.15.226 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.1.193 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.6.163 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.119 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.65 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.6 - Compensating control
In apci3xxx_auto_attach(), change the n_subdevices ternary to count 1 when ai_n_chan is non-zero and 0 otherwise, matching the subdevice creation order.
Event History
Frequently Asked Questions
Which systems are affected by this flaw?
Systems using the Linux kernel comedi addi_apci_3xxx driver with a supported board that has analog input channels are affected when the driver attaches the board. The analog-input subdevice is created but omitted from the allocated subdevice count.
What is the security impact during driver initialization?
The underallocation causes later subdevice initialization, notably the TTL Digital I/O subdevice, to write beyond the allocated subdevice array. This results in a slab out-of-bounds write.
What is the remediation?
Update to a Linux kernel release containing the correction that counts one analog-input subdevice when ai_n_chan is non-zero. The provided stable references identify commits carrying the fix, but no affected or fixed version ranges are specified.