From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 1E3D8384B000; Thu, 25 Apr 2024 13:40:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E3D8384B000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1714052426; bh=7pOc5b9WiW7nP2lczFgFSztRHdM1D2ap6naNoIDkYls=; h=From:To:Subject:Date:From; b=narnny7QL6I7KI88OXrYOppnFnsk5+V9Tt9PeuDxhhVNXYpFbogPADwCy3IXYRZyM 5lIDwftFA663ruB/HdgPz5YqtmcBVW4xM5Iz83vcxUmVpQ7ybxZVeOoWdWlpwFmAQQ u7th8MRaXeMmFCVPSF/N9YsfKERYvbixT+MeyeLk= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc/release/2.38/master] CVE-2024-33599: nscd: Stack-based buffer overflow in netgroup cache (bug 31677) X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/release/2.38/master X-Git-Oldrev: 29e20bd1222cb69dcc6827e899ce7181090052dc X-Git-Newrev: 5968aebb86164034b8f8421b4abab2f837a5bdaf Message-Id: <20240425134026.1E3D8384B000@sourceware.org> Date: Thu, 25 Apr 2024 13:40:25 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5968aebb86164034b8f8421b4abab2f837a5bdaf commit 5968aebb86164034b8f8421b4abab2f837a5bdaf Author: Florian Weimer Date: Thu Apr 25 15:00:45 2024 +0200 CVE-2024-33599: nscd: Stack-based buffer overflow in netgroup cache (bug 31677) Using alloca matches what other caches do. The request length is bounded by MAXKEYLEN. Reviewed-by: Carlos O'Donell (cherry picked from commit 87801a8fd06db1d654eea3e4f7626ff476a9bdaa) Diff: --- nscd/netgroupcache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c index 06b7d7b6ca..31b721bbee 100644 --- a/nscd/netgroupcache.c +++ b/nscd/netgroupcache.c @@ -502,12 +502,13 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req, = (struct indataset *) mempool_alloc (db, sizeof (*dataset) + req->key_len, 1); - struct indataset dataset_mem; bool cacheable = true; if (__glibc_unlikely (dataset == NULL)) { cacheable = false; - dataset = &dataset_mem; + /* The alloca is safe because nscd_run_worker verfies that + key_len is not larger than MAXKEYLEN. */ + dataset = alloca (sizeof (*dataset) + req->key_len); } datahead_init_pos (&dataset->head, sizeof (*dataset) + req->key_len,