1 From bdce95930e1d9a7d013d1ba78740243491262879 Mon Sep 17 00:00:00 2001
2 From: Florian Weimer <fweimer@redhat.com>
3 Date: Mon, 23 May 2016 20:18:34 +0200
4 Subject: [PATCH] CVE-2016-4429: sunrpc: Do not use alloca in clntudp_call [BZ
7 The call is technically in a loop, and under certain circumstances
8 (which are quite difficult to reproduce in a test case), alloca
9 can be invoked repeatedly during a single call to clntudp_call.
10 As a result, the available stack space can be exhausted (even
11 though individual alloca sizes are bounded implicitly by what
12 can fit into a UDP packet, as a side effect of the earlier
13 successful send operation).
15 (cherry picked from commit bc779a1a5b3035133024b21e2f339fe4219fb11c)
19 sunrpc/clnt_udp.c | 10 +++++++++-
20 3 files changed, 20 insertions(+), 1 deletion(-)
22 diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c
23 index a6cf5f1..4d9acb1 100644
24 --- a/sunrpc/clnt_udp.c
25 +++ b/sunrpc/clnt_udp.c
26 @@ -388,9 +388,15 @@ send_again:
27 struct sock_extended_err *e;
28 struct sockaddr_in err_addr;
30 - char *cbuf = (char *) alloca (outlen + 256);
31 + char *cbuf = malloc (outlen + 256);
36 + cu->cu_error.re_errno = errno;
37 + return (cu->cu_error.re_status = RPC_CANTRECV);
40 iov.iov_base = cbuf + 256;
42 msg.msg_name = (void *) &err_addr;
43 @@ -415,10 +421,12 @@ send_again:
44 cmsg = CMSG_NXTHDR (&msg, cmsg))
45 if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
48 e = (struct sock_extended_err *) CMSG_DATA(cmsg);
49 cu->cu_error.re_errno = e->ee_errno;
50 return (cu->cu_error.re_status = RPC_CANTRECV);