From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 078F7384AB45; Thu, 25 Apr 2024 14:11:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 078F7384AB45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1714054314; bh=5auoc15kyYWU7ImUm/Gc9tDeVtH3aSC/tGtD8Mczx2o=; h=From:To:Subject:Date:From; b=VtFD1WvBrem5u1cYMIcsC6ZCgL8rTm+nGpdCedmIbD6tvM4JyCcSX/FHnDrnrQrta cQRvTSqwdIuMWiOt5OfZfSt07CntqN6H35UkHo5NYBafrvwTMTUkx/SDk9tkbAaDIL RZeDfx9yIZIgp9MkjRL9Ish3cQbTvrjQhoMw9DNk= 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.32/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.32/master X-Git-Oldrev: 682ad4c8623e611a971839990ceef00346289cc9 X-Git-Newrev: a77064893bfe8a701770e2f53a4d33805bc47a5a Message-Id: <20240425141154.078F7384AB45@sourceware.org> Date: Thu, 25 Apr 2024 14:11:53 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a77064893bfe8a701770e2f53a4d33805bc47a5a commit a77064893bfe8a701770e2f53a4d33805bc47a5a 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 381aa721ef..a833ef039e 100644 --- a/nscd/netgroupcache.c +++ b/nscd/netgroupcache.c @@ -503,12 +503,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,