CVE-2016-4429: stack overflow in Sun RPC clntudp_call
This commit is contained in:
Florian Weimer 2016-06-02 12:47:32 +02:00
parent 0b01e9c2eb
commit 2d5168f40a
2 changed files with 54 additions and 1 deletions

48
glibc-rh1337140.patch Normal file
View File

@ -0,0 +1,48 @@
commit bc779a1a5b3035133024b21e2f339fe4219fb11c
Author: Florian Weimer <fweimer@redhat.com>
Date: Mon May 23 20:18:34 2016 +0200
CVE-2016-4429: sunrpc: Do not use alloca in clntudp_call [BZ #20112]
The call is technically in a loop, and under certain circumstances
(which are quite difficult to reproduce in a test case), alloca
can be invoked repeatedly during a single call to clntudp_call.
As a result, the available stack space can be exhausted (even
though individual alloca sizes are bounded implicitly by what
can fit into a UDP packet, as a side effect of the earlier
successful send operation).
Index: b/sunrpc/clnt_udp.c
===================================================================
--- a/sunrpc/clnt_udp.c
+++ b/sunrpc/clnt_udp.c
@@ -420,9 +420,15 @@ send_again:
struct sock_extended_err *e;
struct sockaddr_in err_addr;
struct iovec iov;
- char *cbuf = (char *) alloca (outlen + 256);
+ char *cbuf = malloc (outlen + 256);
int ret;
+ if (cbuf == NULL)
+ {
+ cu->cu_error.re_errno = errno;
+ return (cu->cu_error.re_status = RPC_CANTRECV);
+ }
+
iov.iov_base = cbuf + 256;
iov.iov_len = outlen;
msg.msg_name = (void *) &err_addr;
@@ -447,10 +453,12 @@ send_again:
cmsg = CMSG_NXTHDR (&msg, cmsg))
if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
{
+ free (cbuf);
e = (struct sock_extended_err *) CMSG_DATA(cmsg);
cu->cu_error.re_errno = e->ee_errno;
return (cu->cu_error.re_status = RPC_CANTRECV);
}
+ free (cbuf);
}
#endif
do

View File

@ -1,6 +1,6 @@
%define glibcsrcdir glibc-2.22
%define glibcversion 2.22
%define glibcrelease 16%{?dist}
%define glibcrelease 17%{?dist}
# Pre-release tarballs are pulled in from git using a command that is
# effectively:
#
@ -267,6 +267,7 @@ Patch1046: glibc-rh1288740.patch
Patch1047: glibc-rh1330888.patch
Patch1048: glibc-rh1204521.patch
Patch1049: glibc-rh1282011.patch
Patch1050: glibc-rh1337140.patch
##############################################################################
#
@ -733,6 +734,7 @@ microbenchmark tests on the system.
%patch1047 -p1
%patch1048 -p1
%patch1049 -p1
%patch1050 -p1
%patch0059 -p1
##############################################################################
@ -1953,6 +1955,9 @@ rm -f *.filelist*
%endif
%changelog
* Thu Jun 2 2016 Florian Weimer <fweimer@redhat.com> - 2.22-17
- CVE-2016-4429: stack overflow in Sun RPC clntudp_call (#1337140)
* Wed May 11 2016 Florian Weimer <fweimer@redhat.com> - 2.22-16
- Back out dlsym (RTLD_NEXT)/dlerror change (#1333945)
because it reveals an ASAN bug (#1335011)