CVE-2024-56662: acpi: nfit: vmalloc-out-of-bounds Read in acpi_nfit_ctl
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
acpi: nfit: vmalloc-out-of-bounds Read in acpi_nfit_ctl
Fix an issue detected by syzbot with KASAN:
BUG: KASAN: vmalloc-out-of-bounds in cmd_to_func drivers/acpi/nfit/ core.c:416 [inline] BUG: KASAN: vmalloc-out-of-bounds in acpi_nfit_ctl+0x20e8/0x24a0
drivers/acpi/nfit/core.c:459
The issue occurs in cmd_to_func when the call_pkg->nd_reserved2 array is accessed without verifying that call_pkg points to a buffer that is appropriately sized as a struct nd_cmd_pkg. This can lead to out-of-bounds access and undefined behavior if the buffer does not have sufficient space.
To address this, a check was added in acpi_nfit_ctl() to ensure that buf is not NULL and that buf_len is less than sizeof(*call_pkg) before accessing it. This ensures safe access to the members of call_pkg, including the nd_reserved2 array.
The Linux kernel CVE team has assigned CVE-2024-56662 to this issue.
Affected and fixed versions
===========================
Issue introduced in 5.1 with commit ebe9f6f19d80d8978d16078dff3d5bd93ad8d102 and fixed in 5.10.232 with commit 616aa5f3c86e0479bcbb81e41c08c43ff32af637 Issue introduced in 5.1 with commit ebe9f6f19d80d8978d16078dff3d5bd93ad8d102 and fixed in 5.15.175 with commit bbdb3307f609ec4dc9558770f464ede01fe52aed Issue introduced in 5.1 with commit ebe9f6f19d80d8978d16078dff3d5bd93ad8d102 and fixed in 6.1.121 with commit 143f723e9eb4f0302ffb7adfdc7ef77eab3f68e0 Issue introduced in 5.1 with commit ebe9f6f19d80d8978d16078dff3d5bd93ad8d102 and fixed in 6.6.67 with commit e08dc2dc3c3f7938df0e4476fe3e6fdec5583c1d Issue introduced in 5.1 with commit ebe9f6f19d80d8978d16078dff3d5bd93ad8d102 and fixed in 6.12.6 with commit 212846fafb753a48e869e2a342fc1e24048da771 Issue introduced in 5.1 with commit ebe9f6f19d80d8978d16078dff3d5bd93ad8d102 and fixed in 6.13-rc3 with commit 265e98f72bac6c41a4492d3e30a8e5fd22fe0779 Issue introduced in 4.14.176 with commit 63108f2a408abea7ecab063efa0f398da4d0d14b Issue introduced in 4.19.31 with commit f5878c4f084dc6b1386dad03970bb61ad5e9dc4b Issue introduced in 5.0.4 with commit 0c79794474895dbbc3c52225f7e9f73cfecbb7dd
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-2024-56662
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/acpi/nfit/core.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/616aa5f3c86e0479bcbb81e41c08c43ff32af637 https://git.kernel.org/stable/c/bbdb3307f609ec4dc9558770f464ede01fe52aed https://git.kernel.org/stable/c/143f723e9eb4f0302ffb7adfdc7ef77eab3f68e0 https://git.kernel.org/stable/c/e08dc2dc3c3f7938df0e4476fe3e6fdec5583c1d https://git.kernel.org/stable/c/212846fafb753a48e869e2a342fc1e24048da771 https://git.kernel.org/stable/c/265e98f72bac6c41a4492d3e30a8e5fd22fe0779