CVE-2022-50046: net/sunrpc: fix potential memory leaks in rpc_sysfs_xprt_state_change()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
net/sunrpc: fix potential memory leaks in rpc_sysfs_xprt_state_change()
The issue happens on some error handling paths. When the function fails to grab the object xprt, it simply returns 0, forgetting to decrease the reference count of another object xps, which is increased by rpc_sysfs_xprt_kobj_get_xprt_switch(), causing refcount leaks. Also, the function forgets to check whether xps is valid before using it, which may result in NULL-dereferencing issues.
Fix it by adding proper error handling code when either xprt or xps is NULL.
The Linux kernel CVE team has assigned CVE-2022-50046 to this issue.
Affected and fixed versions
===========================
Issue introduced in 5.14 with commit 5b7eb78486cd9ac58bfbd6d84ea0fe2d9fead03b and fixed in 5.15.63 with commit c0434f0e058648649250b8ed6078b66d773de723 Issue introduced in 5.14 with commit 5b7eb78486cd9ac58bfbd6d84ea0fe2d9fead03b and fixed in 5.19.4 with commit 76fbeb1662b1c56514325118a07fba74dc4c79fe Issue introduced in 5.14 with commit 5b7eb78486cd9ac58bfbd6d84ea0fe2d9fead03b and fixed in 6.0 with commit bfc48f1b0505ffcb03a6d749139b7577d6b81ae0
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-50046
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/sunrpc/sysfs.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/c0434f0e058648649250b8ed6078b66d773de723 https://git.kernel.org/stable/c/76fbeb1662b1c56514325118a07fba74dc4c79fe https://git.kernel.org/stable/c/bfc48f1b0505ffcb03a6d749139b7577d6b81ae0