Skip to contentSkip to conversation

CVE-2022-50170: kunit: executor: Fix a memory leak on failure in kunit_filter_tests

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Jun 18, 2025

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

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

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

kunit: executor: Fix a memory leak on failure in kunit_filter_tests

It's possible that memory allocation for 'filtered' will fail, but for the copy of the suite to succeed. In this case, the copy could be leaked.

Properly free 'copy' in the error case for the allocation of 'filtered' failing.

Note that there may also have been a similar issue in kunit_filter_subsuites, before it was removed in "kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites".

This was reported by clang-analyzer via the kernel test robot, here:
https://lore.kernel.org/all/[email protected]/

And by smatch via Dan Carpenter and the kernel test robot:
https://lore.kernel.org/all/[email protected]/

The Linux kernel CVE team has assigned CVE-2022-50170 to this issue.

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

	Issue introduced in 5.18.3 with commit bd8b222a0002872bb229f6c755672a093ef93ea4 and fixed in 5.18.18 with commit a8a7e3ced362b88b659ab54239990196ff975982
	Issue introduced in 5.19 with commit a02353f491622e49c7ddedc6a6dc4f1d6ed2150a and fixed in 5.19.2 with commit 7d69764fa3442c7615a75c6b5c02eaa1f274bccf
	Issue introduced in 5.19 with commit a02353f491622e49c7ddedc6a6dc4f1d6ed2150a and fixed in 6.0 with commit 94681e289bf5d10c9db9db143d1a22d8717205c5
	Issue introduced in 5.17.14 with commit 80cf4932c2545bc231e933d869511008c36af1e0

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-2022-50170

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.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/a8a7e3ced362b88b659ab54239990196ff975982
	https://git.kernel.org/stable/c/7d69764fa3442c7615a75c6b5c02eaa1f274bccf
	https://git.kernel.org/stable/c/94681e289bf5d10c9db9db143d1a22d8717205c5