From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118492 invoked by alias); 25 May 2016 13:11:56 -0000 Mailing-List: contact libc-stable-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: List-Archive: Sender: libc-stable-owner@sourceware.org Received: (qmail 118391 invoked by uid 89); 25 May 2016 13:11:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.1 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.9 required=5.0 tests=AWL,BAYES_05,KAM_LAZY_DOMAIN_SECURITY,MSGID_FROM_MTA_HEADER,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=H*m:pphosted, H*RU:sk:mx0a-00, Hx-spam-relays-external:sk:mx0a-00, HX-Proofpoint-Spam-Details:sk:outboun X-Spam-Status: No, score=1.9 required=5.0 tests=AWL,BAYES_05,KAM_LAZY_DOMAIN_SECURITY,MSGID_FROM_MTA_HEADER,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: * X-HELO: mx0a-001b2d01.pphosted.com Message-Id: <201605251311.u4PD4i2s001802@mx0a-001b2d01.pphosted.com> X-IBM-Helo: d24dlp02.br.ibm.com X-IBM-MailFrom: gftg@linux.vnet.ibm.com X-IBM-RcptTo: libc-stable@sourceware.org From: "Gabriel F. T. Gomes" To: libc-stable@sourceware.org Subject: [COMMITTED 2.20] CVE-2016-3075: Stack overflow in _nss_dns_getnetbyname_r [BZ #19879] Date: Fri, 01 Jan 2016 00:00:00 -0000 X-Mailer: git-send-email 2.4.11 In-Reply-To: <1464181904-28722-1-git-send-email-gftg@linux.vnet.ibm.com> References: <1464181904-28722-1-git-send-email-gftg@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16052513-0020-0000-0000-00000208B58C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16052513-0021-0000-0000-00002FC4EDDA X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-05-25_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=13 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1605250162 X-SW-Source: 2016-05/txt/msg00045.txt.bz2 From: Florian Weimer The defensive copy is not needed because the name may not alias the output buffer. (cherry picked from commit 317b199b4aff8cfa27f2302ab404d2bb5032b9a4) (cherry picked from commit f5b3338d70a7a2c626331ac4589b6deb2f610432) --- ChangeLog | 7 +++++++ NEWS | 4 ++++ resolv/nss_dns/dns-network.c | 5 +---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3652d5f..4b5cd01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2016-05-24 Florian Weimer + + [BZ #19879] + CVE-2016-3075 + * resolv/nss_dns/dns-network.c (_nss_dns_getnetbyname_r): Do not + copy name. + 2016-05-24 Paul Pluzhnikov [BZ #17905] diff --git a/NEWS b/NEWS index e6a5207..dc8679f 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,10 @@ Version 2.20.1 called with the GLOB_ALTDIRFUNC flag and encountered a long file name. Reported by Alexander Cherepanov. (CVE-2016-1234) +* An unnecessary stack copy in _nss_dns_getnetbyname_r was removed. It + could result in a stack overflow when getnetbyname was called with an + overly long name. (CVE-2016-3075) + * Previously, getaddrinfo copied large amounts of address data to the stack, even after the fix for CVE-2013-4458 has been applied, potentially resulting in a stack overflow. getaddrinfo now uses a heap allocation diff --git a/resolv/nss_dns/dns-network.c b/resolv/nss_dns/dns-network.c index 08cf0a6..335604a 100644 --- a/resolv/nss_dns/dns-network.c +++ b/resolv/nss_dns/dns-network.c @@ -118,17 +118,14 @@ _nss_dns_getnetbyname_r (const char *name, struct netent *result, } net_buffer; querybuf *orig_net_buffer; int anslen; - char *qbuf; enum nss_status status; if (__res_maybe_init (&_res, 0) == -1) return NSS_STATUS_UNAVAIL; - qbuf = strdupa (name); - net_buffer.buf = orig_net_buffer = (querybuf *) alloca (1024); - anslen = __libc_res_nsearch (&_res, qbuf, C_IN, T_PTR, net_buffer.buf->buf, + anslen = __libc_res_nsearch (&_res, name, C_IN, T_PTR, net_buffer.buf->buf, 1024, &net_buffer.ptr, NULL, NULL, NULL, NULL); if (anslen < 0) { -- 2.4.11