GNU bug report logs

#66348 [PATCH RFC] gnu: glibc: Fix CVE-2023-4911.

PackageSource(s)Maintainer(s)
guix-patches PTS Buildd Popcon
Full log

Message #5 received at submit@debbugs.gnu.org (full text, mbox, reply):

Received: (at submit) by debbugs.gnu.org; 4 Oct 2023 20:26:09 +0000
From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 04 16:26:09 2023
Received: from localhost ([127.0.0.1]:45440 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1qo8Rd-0002pQ-1i
	for submit@debbugs.gnu.org; Wed, 04 Oct 2023 16:26:09 -0400
Received: from lists.gnu.org ([2001:470:142::17]:48920)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <liliana.prikler@gmail.com>) id 1qo8Ra-0002on-8Q
 for submit@debbugs.gnu.org; Wed, 04 Oct 2023 16:26:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <liliana.prikler@gmail.com>)
 id 1qo8RC-0003IZ-6B
 for guix-patches@gnu.org; Wed, 04 Oct 2023 16:25:42 -0400
Received: from mail-ej1-x642.google.com ([2a00:1450:4864:20::642])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <liliana.prikler@gmail.com>)
 id 1qo8R9-0005ly-PU; Wed, 04 Oct 2023 16:25:41 -0400
Received: by mail-ej1-x642.google.com with SMTP id
 a640c23a62f3a-9b27bc8b65eso42384766b.0; 
 Wed, 04 Oct 2023 13:25:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1696451134; x=1697055934; darn=gnu.org;
 h=mime-version:cc:to:subject:date:from:message-id:from:to:cc:subject
 :date:message-id:reply-to;
 bh=k/KnvnTjbP+jXOO7ur+FIk5JXBx+ynXq3ljG0kspxuA=;
 b=RrMrfrUqjaOt/9kauxiSAWui1siJrfrdlurCjcqq4QMnMRadVW0tOarkUCV7X7fC62
 3oOHQf4I6TpqantAwIIv+xFhUAHzqDehln2c2ynl3eYzSCw08QGtDPpF51uSkyK6whG9
 0WmRUpb92GfnswdjQgnkRhWnavzrg/m42lJOn4mTu6NsQxdVfB6nJxqgw5VT7JeSHpUT
 crZrIqxWVKkJ4QG0N5y1yF+Ks2tKLnncvbXQpjgA3EKl3JeO+wSwL1ETWip9Y23+PuzB
 2geql4dLl1LZoJgVeADup2au0lfEueFNJNS538J8lfYJ45ZcZ4XfE8m7GAszOEB5IRsC
 JzKg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1696451134; x=1697055934;
 h=mime-version:cc:to:subject:date:from:message-id:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=k/KnvnTjbP+jXOO7ur+FIk5JXBx+ynXq3ljG0kspxuA=;
 b=VvuSPBu9ix2C8EFQeWB76VhIWZuQuOrr8WTFdaczB/EYyNl9478DY5CTf11d3s+/wh
 QJ42itQAyNtw6EAkb0CwxuEhhbBimvVd25eHf5p2PycFWBnASISkqVVVpbw5+YpeisgD
 1gVOeAKN4vWIOXm/GpFMUMSLnLO+MTQvf7MCWbkQ8t3a1ghvE9WbXjI4tB7JPqtiyzHO
 kOGcvwBZmLeSIj7DqawPPWDXrIEruxIfZudMxQMDjgNumB7wT/xIkCrLkAaVas6+WHcJ
 NK18lKIqljsTQp6nxDVWIcEpdV3uXiB98wQ9BNasBTSZsgCL1aFcBvyYxlTuQNZKMCag
 Ri1A==
X-Gm-Message-State: AOJu0YzLUlIyyaRs+CrNLSS5HH08+JniU2cqTto39ydKUsRg/4wL5c9P
 ytAG+8Wstg1iPbXS7aBEmqI7SVYv/yosqA==
X-Google-Smtp-Source: AGHT+IGj377do5SANNF66i1dwKFL0uxblEWGWAKClJ48Ww/nwwSFlVZUPPB2HIUD3+vjLoMYBpIzbg==
X-Received: by 2002:a17:906:cc49:b0:9a1:b967:aca9 with SMTP id
 mm9-20020a170906cc4900b009a1b967aca9mr2705568ejb.63.1696451134276; 
 Wed, 04 Oct 2023 13:25:34 -0700 (PDT)
Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at.
 [85.127.52.93]) by smtp.gmail.com with ESMTPSA id
 g13-20020a170906348d00b0099bd453357esm3325087ejb.41.2023.10.04.13.25.32
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 04 Oct 2023 13:25:33 -0700 (PDT)
Message-ID: <b4b918de4fce8ab839b51740f2758dc13f9884d5.1696450898.git.liliana.prikler@gmail.com>
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
Date: Wed, 4 Oct 2023 21:27:13 +0200
Subject: [PATCH RFC] gnu: glibc: Fix CVE-2023-4911.
to: guix-patches@gnu.org
MIME-Version: 1.0
Received-SPF: pass client-ip=2a00:1450:4864:20::642;
 envelope-from=liliana.prikler@gmail.com; helo=mail-ej1-x642.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
Cc: Ludovic Courtès <ludo@gnu.org>
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request@debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit@debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request@debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request@debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces@debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
X-Spam-Score: -0.0 (/)
* gnu/packages/patches/glibc-2.35-CVE-2023-4911.patch: New file.
* gnu/local.mk: Register it here.
* gnu/packages/base.scm (glibc/fixed): New variable.
(glibc): Use it as replacement.
---
Hi folks,

you might have heard about a little bad boi called CVE-2023-4911.
Stirred up some news recently.  I've "backported" the fix that's
currently sleeping on glibc master to our current glibc; only a test
needed adjusting.  I still have to verify that it works in a vm, but
it appears to be rebuilding more than I anticipated, so that might take
me some time.

Anyway, have at it in the meantime.

Cheers

 gnu/local.mk                                  |   1 +
 gnu/packages/base.scm                         |  10 ++
 .../patches/glibc-2.35-CVE-2023-4911.patch    | 160 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 gnu/packages/patches/glibc-2.35-CVE-2023-4911.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 83b5268c7e..4a2c635ce6 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1275,6 +1275,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/glibc-CVE-2019-7309.patch		\
   %D%/packages/patches/glibc-CVE-2019-9169.patch		\
   %D%/packages/patches/glibc-CVE-2019-19126.patch		\
+  %D%/packages/patches/glibc-2.35-CVE-2023-4911.patch	\
   %D%/packages/patches/glibc-allow-kernel-2.6.32.patch		\
   %D%/packages/patches/glibc-boot-2.16.0.patch			\
   %D%/packages/patches/glibc-boot-2.2.5.patch			\
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index c0813f7de0..2d8e9143cd 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -793,6 +793,7 @@ (define-public glibc
   (package
    (name "glibc")
    (version "2.35")
+   (replacement glibc/fixed)
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
@@ -1062,6 +1063,15 @@ (define-public glibc
    (license lgpl2.0+)
    (home-page "https://www.gnu.org/software/libc/")))
 
+(define glibc/fixed
+  (package
+    (inherit glibc)
+    (source
+     (origin (inherit (package-source glibc))
+             (patches
+              (append (search-patches "glibc-2.35-CVE-2023-4911.patch")
+                      (origin-patches (package-source glibc))))))))
+
 ;; Define a variation of glibc which uses the default /etc/ld.so.cache, useful
 ;; in FHS containers.
 (define-public glibc-for-fhs
diff --git a/gnu/packages/patches/glibc-2.35-CVE-2023-4911.patch b/gnu/packages/patches/glibc-2.35-CVE-2023-4911.patch
new file mode 100644
index 0000000000..d8044f064d
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.35-CVE-2023-4911.patch
@@ -0,0 +1,160 @@
+From 1056e5b4c3f2d90ed2b4a55f96add28da2f4c8fa Mon Sep 17 00:00:00 2001
+From: Siddhesh Poyarekar <siddhesh@sourceware.org>
+Date: Tue, 19 Sep 2023 18:39:32 -0400
+Subject: [PATCH 1/1] tunables: Terminate if end of input is reached
+ (CVE-2023-4911)
+
+The string parsing routine may end up writing beyond bounds of tunestr
+if the input tunable string is malformed, of the form name=name=val.
+This gets processed twice, first as name=name=val and next as name=val,
+resulting in tunestr being name=name=val:name=val, thus overflowing
+tunestr.
+
+Terminate the parsing loop at the first instance itself so that tunestr
+does not overflow.
+
+This also fixes up tst-env-setuid-tunables to actually handle failures
+correct and add new tests to validate the fix for this CVE.
+
+Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
+Reviewed-by: Carlos O'Donell <carlos@redhat.com>
+---
+Backported to 2.35 by Liliana Marie Prikler <liliana.prikler@gmail.com>
+
+ NEWS                          |  5 +++++
+ elf/dl-tunables.c             | 17 +++++++++-------
+ elf/tst-env-setuid-tunables.c | 37 +++++++++++++++++++++++++++--------
+ 3 files changed, 44 insertions(+), 15 deletions(-)
+
+Index: glibc-2.35/NEWS
+===================================================================
+--- glibc-2.35.orig/NEWS
++++ glibc-2.35/NEWS
+@@ -199,6 +199,11 @@ Security related changes:
+   corresponds to the / directory through an unprivileged mount
+   namespace.  Reported by Qualys.
+ 
++  CVE-2023-4911: If a tunable of the form NAME=NAME=VAL is passed in the
++  environment of a setuid program and NAME is valid, it may result in a
++  buffer overflow, which could be exploited to achieve escalated
++  privileges.  This flaw was introduced in glibc 2.34.
++
+ The following bugs are resolved with this release:
+ 
+   [12889] nptl: Race condition in pthread_kill
+Index: glibc-2.35/elf/dl-tunables.c
+===================================================================
+--- glibc-2.35.orig/elf/dl-tunables.c
++++ glibc-2.35/elf/dl-tunables.c
+@@ -187,11 +187,7 @@ parse_tunables (char *tunestr, char *val
+       /* If we reach the end of the string before getting a valid name-value
+ 	 pair, bail out.  */
+       if (p[len] == '\0')
+-	{
+-	  if (__libc_enable_secure)
+-	    tunestr[off] = '\0';
+-	  return;
+-	}
++	break;
+ 
+       /* We did not find a valid name-value pair before encountering the
+ 	 colon.  */
+@@ -251,9 +247,16 @@ parse_tunables (char *tunestr, char *val
+ 	    }
+ 	}
+ 
+-      if (p[len] != '\0')
+-	p += len + 1;
++      /* We reached the end while processing the tunable string.  */
++      if (p[len] == '\0')
++	break;
++
++      p += len + 1;
+     }
++
++  /* Terminate tunestr before we leave.  */
++  if (__libc_enable_secure)
++    tunestr[off] = '\0';
+ }
+ #endif
+ 
+Index: glibc-2.35/elf/tst-env-setuid-tunables.c
+===================================================================
+--- glibc-2.35.orig/elf/tst-env-setuid-tunables.c
++++ glibc-2.35/elf/tst-env-setuid-tunables.c
+@@ -52,6 +52,8 @@ const char *teststrings[] =
+   "glibc.malloc.perturb=0x800:not_valid.malloc.check=2:glibc.malloc.mmap_threshold=4096",
+   "glibc.not_valid.check=2:glibc.malloc.mmap_threshold=4096",
+   "not_valid.malloc.check=2:glibc.malloc.mmap_threshold=4096",
++  "glibc.malloc.mmap_threshold=glibc.malloc.mmap_threshold=4096",
++  "glibc.malloc.check=2",
+   "glibc.malloc.garbage=2:glibc.maoc.mmap_threshold=4096:glibc.malloc.check=2",
+   "glibc.malloc.check=4:glibc.malloc.garbage=2:glibc.maoc.mmap_threshold=4096",
+   ":glibc.malloc.garbage=2:glibc.malloc.check=1",
+@@ -70,6 +72,8 @@ const char *resultstrings[] =
+   "glibc.malloc.perturb=0x800:glibc.malloc.mmap_threshold=4096",
+   "glibc.malloc.mmap_threshold=4096",
+   "glibc.malloc.mmap_threshold=4096",
++  "glibc.malloc.mmap_threshold=glibc.malloc.mmap_threshold=4096",
++  "",
+   "",
+   "",
+   "",
+@@ -89,6 +93,8 @@ test_child (int off)
+ 
+   if (val != NULL)
+     printf ("[%d] Unexpected GLIBC_TUNABLES VALUE %s\n", off, val);
++  else
++    printf ("[%d] GLIBC_TUNABLES environment variable absent\n", off);
+ 
+   return 1;
+ #else
+@@ -117,21 +123,26 @@ do_test (int argc, char **argv)
+       if (ret != 0)
+ 	exit (1);
+ 
+-      exit (EXIT_SUCCESS);
++      /* Special return code to make sure that the child executed all the way
++	 through.  */
++      exit (42);
+     }
+   else
+     {
+-      int ret = 0;
+-
+       /* Spawn tests.  */
+       for (int i = 0; i < array_length (teststrings); i++)
+ 	{
+ 	  char buf[INT_BUFSIZE_BOUND (int)];
+ 
+-	  printf ("Spawned test for %s (%d)\n", teststrings[i], i);
++	  printf ("[%d] Spawned test for %s\n", i, teststrings[i]);
+ 	  snprintf (buf, sizeof (buf), "%d\n", i);
++	  fflush (stdout);
+ 	  if (setenv ("GLIBC_TUNABLES", teststrings[i], 1) != 0)
+-	    exit (1);
++	    {
++	      printf ("    [%d] Failed to set GLIBC_TUNABLES: %m", i);
++	      support_record_failure ();
++	      continue;
++	    }
+ 
+ 	  int status = support_capture_subprogram_self_sgid (buf);
+ 
+@@ -139,9 +150,14 @@ do_test (int argc, char **argv)
+ 	  if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
+ 	    return EXIT_UNSUPPORTED;
+ 
+-	  ret |= status;
++	  if (WEXITSTATUS (status) != 42)
++	    {
++	      printf ("    [%d] child failed with status %d\n", i,
++		      WEXITSTATUS (status));
++	      support_record_failure ();
++	    }
+ 	}
+-      return ret;
++      return 0;
+     }
+ }
+ 

base-commit: e71864793021051cff35597abd59bb2d5649977d
-- 
2.41.0





Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Sun Dec 22 02:24:30 2024; Machine Name: wallace-server

GNU bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.