CVE-2025-38481: comedi: Fail COMEDI_INSNLIST ioctl if n_insns is too large
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
comedi: Fail COMEDI_INSNLIST ioctl if n_insns is too large
The handling of the COMEDI_INSNLIST ioctl allocates a kernel buffer to hold the array of struct comedi_insn, getting the length from the n_insns member of the struct comedi_insnlist supplied by the user. The allocation will fail with a WARNING and a stack dump if it is too large.
Avoid that by failing with an -EINVAL error if the supplied n_insns value is unreasonable.
Define the limit on the n_insns value in the MAX_INSNS macro. Set this to the same value as MAX_SAMPLES (65536), which is the maximum allowed sum of the values of the member n in the array of struct comedi_insn, and sensible comedi instructions will have an n of at least 1.
The Linux kernel CVE team has assigned CVE-2025-38481 to this issue.
Affected and fixed versions
===========================
Issue introduced in 2.6.29 with commit ed9eccbe8970f6eedc1b978c157caf1251a896d4 and fixed in 6.1.147 with commit d4c73ce13f5b5a0fe0319f1f352ff602f0ace8e3 Issue introduced in 2.6.29 with commit ed9eccbe8970f6eedc1b978c157caf1251a896d4 and fixed in 6.6.100 with commit c9d3d9667443caafa804cd07940aeaef8e53aa90 Issue introduced in 2.6.29 with commit ed9eccbe8970f6eedc1b978c157caf1251a896d4 and fixed in 6.12.40 with commit 992d600f284e719242a434166e86c1999649b71c Issue introduced in 2.6.29 with commit ed9eccbe8970f6eedc1b978c157caf1251a896d4 and fixed in 6.15.8 with commit e3b8322cc8081d142ee4c1a43e1d702bdba1ed76 Issue introduced in 2.6.29 with commit ed9eccbe8970f6eedc1b978c157caf1251a896d4 and fixed in 6.16 with commit 08ae4b20f5e82101d77326ecab9089e110f224cc
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2025-38481
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/comedi/comedi_fops.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/d4c73ce13f5b5a0fe0319f1f352ff602f0ace8e3 https://git.kernel.org/stable/c/c9d3d9667443caafa804cd07940aeaef8e53aa90 https://git.kernel.org/stable/c/992d600f284e719242a434166e86c1999649b71c https://git.kernel.org/stable/c/e3b8322cc8081d142ee4c1a43e1d702bdba1ed76 https://git.kernel.org/stable/c/08ae4b20f5e82101d77326ecab9089e110f224cc