[PATCH v2 1/4] CVE-2024-33599: nscd: Stack-based buffer overflow in netgroup cache (bug 31677)

Florian Weimer fweimer@redhat.com
Wed Apr 24 20:54:27 GMT 2024


Using alloca matches what other caches do.  The request length is
bounded by MAXKEYLEN.
---
v2: Added the comment Sid requested.  CVE assignment.
 nscd/netgroupcache.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
index 0c6e46f15c..f227dc7fa2 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,

base-commit: f4724843ada64a51d66f65d3199fe431f9d4c254
-- 
2.44.0




More information about the Libc-alpha mailing list