Skip to contentSkip to conversation

CVE-2021-47467: kunit: fix reference count leak in kfree_at_end

DISCUSSION Greg Kroah-Hartman 1 participant 1 message May 22, 2024

lore
Share & tools
lore
#0 lore raw

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

kunit: fix reference count leak in kfree_at_end

The reference counting issue happens in the normal path of kfree_at_end(). When kunit_alloc_and_get_resource() is invoked, the function forgets to handle the returned resource object, whose refcount increased inside, causing a refcount leak.

Fix this issue by calling kunit_alloc_resource() instead of kunit_alloc_and_get_resource().

Fixed the following when applying:
Shuah Khan <[email protected]>

CHECK: Alignment should match open parenthesis
+ kunit_alloc_resource(test, NULL, kfree_res_free, GFP_KERNEL,
(void *)to_free);

The Linux kernel CVE team has assigned CVE-2021-47467 to this issue.

Affected and fixed versions
===========================

	Fixed in 5.14.15 with commit bbdd158b40b6
	Fixed in 5.15 with commit f62314b1ced2

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-2021-47467

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:
lib/kunit/executor_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/bbdd158b40b66a9403391a517f24ef6613573446
	https://git.kernel.org/stable/c/f62314b1ced25c58b86e044fc951cd6a1ea234cf