CVE-2025-38274: fpga: fix potential null pointer deref in fpga_mgr_test_img_load_sgt()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
fpga: fix potential null pointer deref in fpga_mgr_test_img_load_sgt()
fpga_mgr_test_img_load_sgt() allocates memory for sgt using kunit_kzalloc() however it does not check if the allocation failed. It then passes sgt to sg_alloc_table(), which passes it to __sg_alloc_table(). This function calls memset() on sgt in an attempt to zero it out. If the allocation fails then sgt will be NULL and the memset will trigger a NULL pointer dereference.
Fix this by checking the allocation with KUNIT_ASSERT_NOT_ERR_OR_NULL().
The Linux kernel CVE team has assigned CVE-2025-38274 to this issue.
Affected and fixed versions
===========================
Issue introduced in 6.6 with commit ccbc1c302115d8125d6a96296ba52702c6de0ade and fixed in 6.6.94 with commit e69e2cfd8b38d9463a250e153ef4963a604d61e9 Issue introduced in 6.6 with commit ccbc1c302115d8125d6a96296ba52702c6de0ade and fixed in 6.12.34 with commit 8b2230ac7ff0aeb2441132df638a82ab124f8624 Issue introduced in 6.6 with commit ccbc1c302115d8125d6a96296ba52702c6de0ade and fixed in 6.15.3 with commit eb4c74eaa6e2d15f3bbd32941c9d2a25b29a718d Issue introduced in 6.6 with commit ccbc1c302115d8125d6a96296ba52702c6de0ade and fixed in 6.16-rc1 with commit 6ebf1982038af12f3588417e4fd0417d2551da28
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-38274
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/fpga/tests/fpga-mgr-test.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/e69e2cfd8b38d9463a250e153ef4963a604d61e9 https://git.kernel.org/stable/c/8b2230ac7ff0aeb2441132df638a82ab124f8624 https://git.kernel.org/stable/c/eb4c74eaa6e2d15f3bbd32941c9d2a25b29a718d https://git.kernel.org/stable/c/6ebf1982038af12f3588417e4fd0417d2551da28