Skip to content

Commit 45bcdfe

Browse files
committed
net/sunrpc: fix reference count leaks in rpc_sysfs_xprt_state_change
jira LE-1907 cve CVE-2021-47624 Rebuild_History Non-Buildable kernel-4.18.0-553.16.1.el8_10 commit-author Xiyu Yang <xiyuyang19@fudan.edu.cn> commit 776d794 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". Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn> Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> (cherry picked from commit 776d794) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 334e257 commit 45bcdfe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/sunrpc/sysfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,10 @@ static ssize_t rpc_sysfs_xprt_state_change(struct kobject *kobj,
299299
online = 1;
300300
else if (!strncmp(buf, "remove", 6))
301301
remove = 1;
302-
else
303-
return -EINVAL;
302+
else {
303+
count = -EINVAL;
304+
goto out_put;
305+
}
304306

305307
if (wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE)) {
306308
count = -EINTR;

0 commit comments

Comments
 (0)