CVE-2022-50007: xfrm: fix refcount leak in __xfrm_policy_check()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
xfrm: fix refcount leak in __xfrm_policy_check()
The issue happens on an error path in __xfrm_policy_check(). When the fetching process of the object pols[1] fails, the function simply returns 0, forgetting to decrement the reference count of pols[0], which is incremented earlier by either xfrm_sk_policy_lookup() or xfrm_policy_lookup(). This may result in memory leaks.
Fix it by decreasing the reference count of pols[0] in that path.
The Linux kernel CVE team has assigned CVE-2022-50007 to this issue.
Affected and fixed versions
===========================
Issue introduced in 2.6.19 with commit 134b0fc544ba062498451611cb6f3e4454221b3d and fixed in 4.9.327 with commit 18e6b6e2555c93f5ca09f2b85ef1fa025c8accea Issue introduced in 2.6.19 with commit 134b0fc544ba062498451611cb6f3e4454221b3d and fixed in 4.14.292 with commit 8f94b933103ee1bda119543369cc18a1be5536db Issue introduced in 2.6.19 with commit 134b0fc544ba062498451611cb6f3e4454221b3d and fixed in 4.19.257 with commit 0769491a8acd3e85ca4c3f65080eac2c824262df Issue introduced in 2.6.19 with commit 134b0fc544ba062498451611cb6f3e4454221b3d and fixed in 5.4.212 with commit 63da7a2bbf3f28094920e0b8a17d2571a9bd842d Issue introduced in 2.6.19 with commit 134b0fc544ba062498451611cb6f3e4454221b3d and fixed in 5.10.140 with commit 1305d7d4f35ca6f214a2d23b075aa6a924cff3be Issue introduced in 2.6.19 with commit 134b0fc544ba062498451611cb6f3e4454221b3d and fixed in 5.15.64 with commit 26ad2398fe4984f4f6f930bcb3bc9047fa77265b Issue introduced in 2.6.19 with commit 134b0fc544ba062498451611cb6f3e4454221b3d and fixed in 5.19.6 with commit d66c052879791313f90c0584420f196a038fb8b8 Issue introduced in 2.6.19 with commit 134b0fc544ba062498451611cb6f3e4454221b3d and fixed in 6.0 with commit 9c9cb23e00ddf45679b21b4dacc11d1ae7961ebe
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-50007
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:
net/xfrm/xfrm_policy.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/18e6b6e2555c93f5ca09f2b85ef1fa025c8accea https://git.kernel.org/stable/c/8f94b933103ee1bda119543369cc18a1be5536db https://git.kernel.org/stable/c/0769491a8acd3e85ca4c3f65080eac2c824262df https://git.kernel.org/stable/c/63da7a2bbf3f28094920e0b8a17d2571a9bd842d https://git.kernel.org/stable/c/1305d7d4f35ca6f214a2d23b075aa6a924cff3be https://git.kernel.org/stable/c/26ad2398fe4984f4f6f930bcb3bc9047fa77265b https://git.kernel.org/stable/c/d66c052879791313f90c0584420f196a038fb8b8 https://git.kernel.org/stable/c/9c9cb23e00ddf45679b21b4dacc11d1ae7961ebe