local-CVE-2024-33599-nscd
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Tue, 30 Apr 2024 21:07:28 +0000 (23:07 +0200)
committerAurelien Jarno <aurel32@debian.org>
Tue, 30 Apr 2024 21:07:28 +0000 (23:07 +0200)
commit caa3151ca460bdd9330adeedd68c3112d97bffe4
Author: Florian Weimer <fweimer@redhat.com>
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 <carlos@redhat.com>
    (cherry picked from commit 87801a8fd06db1d654eea3e4f7626ff476a9bdaa)

Gbp-Pq: Topic any
Gbp-Pq: Name local-CVE-2024-33599-nscd.diff

nscd/netgroupcache.c

index 85977521a64715d61bc760e3268286910e0fb8c8..f0de064368a0d12f083462179fb7cca040d116b5 100644 (file)
@@ -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,