Unverified Commit dde9f113 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!14241 sunrpc: fix one UAF issue caused by sunrpc kernel tcp socket

parents d42c1711 108dd893
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1474,6 +1474,11 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv,
	newlen = error;

	if (protocol == IPPROTO_TCP) {
		sock->sk->sk_net_refcnt = 1;
		get_net(net);
#ifdef CONFIG_PROC_FS
		this_cpu_add(*net->core.sock_inuse, 1);
#endif
		if ((error = kernel_listen(sock, 64)) < 0)
			goto bummer;
	}
+7 −0
Original line number Diff line number Diff line
@@ -1857,6 +1857,13 @@ static struct socket *xs_create_sock(struct rpc_xprt *xprt,
		goto out;
	}

	if (protocol == IPPROTO_TCP) {
		sock->sk->sk_net_refcnt = 1;
		get_net(xprt->xprt_net);
#ifdef CONFIG_PROC_FS
		this_cpu_add(*xprt->xprt_net->core.sock_inuse, 1);
#endif
	}
	filp = sock_alloc_file(sock, O_NONBLOCK, NULL);
	if (IS_ERR(filp))
		return ERR_CAST(filp);