Subject: CVE-2021-47624: net/sunrpc: fix reference count leaks in rpc_sysfs_xprt_state_change

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

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

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

net/sunrpc: fix reference count leaks in rpc_sysfs_xprt_state_change

The refcount leak issues take place in an error handling path. When the
3rd argument buf doesn't match with "offline", "online" or "remove", the
function simply returns -EINVAL and forgets to decrease the reference
count of a rpc_xprt object and a rpc_xprt_switch object increased by
rpc_sysfs_xprt_kobj_get_xprt() and
rpc_sysfs_xprt_kobj_get_xprt_switch(), causing reference count leaks of
both unused objects.

Fix this issue by jumping to the error handling path labelled with
out_put when buf matches none of "offline", "online" or "remove".

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

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

	Fixed in 5.15.24 with commit 4b22aa42bd4d
	Fixed in 5.16.10 with commit 5f6024c05a2c
	Fixed in 5.17 with commit 776d794f28c9

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-47624
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/4b22aa42bd4d2d630ef1854c139275c3532937cb
	https://git.kernel.org/stable/c/5f6024c05a2c0fdd180b29395aaf686d25af3a0f
	https://git.kernel.org/stable/c/776d794f28c95051bc70405a7b1fa40115658a18