Skip to content

Commit

Permalink
Mandeepsplaha/patch cves against gdb (microsoft#6338)
Browse files Browse the repository at this point in the history
* Patch CVE-2023-4911 in glibc
* Update all specs that build require glibc-static
  • Loading branch information
mandeepsplaha authored Oct 3, 2023
1 parent 9f738e0 commit 115ecc7
Show file tree
Hide file tree
Showing 17 changed files with 239 additions and 55 deletions.
7 changes: 5 additions & 2 deletions SPECS-EXTENDED/buildah/buildah.spec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Summary: A command line tool used for creating OCI Images
Name: buildah
Version: 1.18.0
Release: 17%{?dist}
Release: 18%{?dist}
License: ASL 2.0
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -32,7 +32,7 @@ BuildRequires: btrfs-progs-devel
BuildRequires: device-mapper-devel
BuildRequires: git
BuildRequires: glib2-devel
BuildRequires: glibc-static >= 2.35-4%{?dist}
BuildRequires: glibc-static >= 2.35-5%{?dist}
BuildRequires: go-md2man
BuildRequires: go-rpm-macros
BuildRequires: golang
Expand Down Expand Up @@ -123,6 +123,9 @@ cp imgtype %{buildroot}/%{_bindir}/%{name}-imgtype
%{_datadir}/%{name}/test

%changelog
* Tue Oct 03 2023 Mandeep Plaha <[email protected]> - 1.18.0-18
- Bump release to rebuild against glibc 2.35-5

* Tue Sep 05 2023 Brian Fjeldstad <[email protected]> - 1.18.0-17
- Address CVE-2022-2990

Expand Down
7 changes: 5 additions & 2 deletions SPECS-EXTENDED/catatonit/catatonit.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Distribution: Mariner

Name: catatonit
Version: 0.1.7
Release: 7%{?dist}
Release: 8%{?dist}
Summary: A signal-forwarding process manager for containers
License: GPLv3+
URL: https://github.com/openSUSE/catatonit
Expand All @@ -13,7 +13,7 @@ BuildRequires: automake
BuildRequires: file
BuildRequires: gcc
BuildRequires: git
BuildRequires: glibc-static >= 2.35-4%{?dist}
BuildRequires: glibc-static >= 2.35-5%{?dist}
BuildRequires: libtool
BuildRequires: make

Expand Down Expand Up @@ -61,6 +61,9 @@ ln -s %{_libexecdir}/%{name}/%{name} %{buildroot}%{_libexecdir}/podman/%{name}
%{_libexecdir}/podman/%{name}

%changelog
* Tue Oct 03 2023 Mandeep Plaha <[email protected]> - 0.1.7-8
- Bump release to rebuild against glibc 2.35-5

* Wed Jul 05 2023 Andrew Phelps <[email protected]> - 0.1.7-7
- Bump release to rebuild against glibc 2.35-4

Expand Down
7 changes: 5 additions & 2 deletions SPECS-EXTENDED/dyninst/dyninst.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Summary: An API for Run-time Code Generation
License: LGPLv2+
Name: dyninst
Release: 9%{?dist}
Release: 10%{?dist}
Vendor: Microsoft Corporation
Distribution: Mariner
URL: http://www.dyninst.org
Expand Down Expand Up @@ -31,7 +31,7 @@ BuildRequires: tbb tbb-devel

# Extra requires just for the testsuite
BuildRequires: gcc-gfortran libstdc++-static libxml2-devel
BuildRequires: glibc-static >= 2.35-4%{?dist}
BuildRequires: glibc-static >= 2.35-5%{?dist}

# Testsuite files should not provide/require anything
%{?filter_setup:
Expand Down Expand Up @@ -194,6 +194,9 @@ echo "%{_libdir}/dyninst" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf
%attr(644,root,root) %{_libdir}/dyninst/testsuite/*.a

%changelog
* Tue Oct 03 2023 Mandeep Plaha <[email protected]> - 10.1.0-10
- Bump release to rebuild against glibc 2.35-5

* Wed Jul 05 2023 Andrew Phelps <[email protected]> - 10.1.0-9
- Bump release to rebuild against glibc 2.35-4

Expand Down
7 changes: 5 additions & 2 deletions SPECS-EXTENDED/podman/podman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

Name: podman
Version: 4.1.1
Release: 14%{?dist}
Release: 15%{?dist}
License: ASL 2.0 and BSD and ISC and MIT and MPLv2.0
Summary: Manage Pods, Containers and Container Images
Vendor: Microsoft Corporation
Expand All @@ -51,7 +51,7 @@ BuildRequires: go-md2man
BuildRequires: golang
BuildRequires: gcc
BuildRequires: glib2-devel
BuildRequires: glibc-static >= 2.35-4%{?dist}
BuildRequires: glibc-static >= 2.35-5%{?dist}
BuildRequires: git
BuildRequires: go-rpm-macros
BuildRequires: gpgme-devel
Expand Down Expand Up @@ -387,6 +387,9 @@ cp -pav test/system %{buildroot}/%{_datadir}/%{name}/test/

# rhcontainerbot account currently managed by lsm5
%changelog
* Tue Oct 03 2023 Mandeep Plaha <[email protected]> - 4.1.1-15
- Bump release to rebuild against glibc 2.35-5

* Mon Aug 07 2023 CBL-Mariner Servicing Account <[email protected]> - 4.1.1-14
- Bump release to rebuild with go 1.19.12

Expand Down
7 changes: 5 additions & 2 deletions SPECS/busybox/busybox.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Summary: Statically linked binary providing simplified versions of system commands
Name: busybox
Version: 1.35.0
Release: 6%{?dist}
Release: 7%{?dist}
License: GPLv2
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -16,7 +16,7 @@ Patch3: CVE-2022-30065.patch
Patch4: ash-fix-use-after-free-in-pattern-substituon-code.patch
Patch5: ash-fix-use-after-free-in-bash-pattern-substitution.patch
BuildRequires: gcc
BuildRequires: glibc-static >= 2.35-4%{?dist}
BuildRequires: glibc-static >= 2.35-5%{?dist}
BuildRequires: libselinux-devel >= 1.27.7-2
BuildRequires: libsepol-devel
# libbb/hash_md5_sha.c
Expand Down Expand Up @@ -94,6 +94,9 @@ install -m 644 docs/busybox.petitboot.1 %{buildroot}/%{_mandir}/man1/busybox.pet
%{_mandir}/man1/busybox.petitboot.1.gz

%changelog
* Tue Oct 03 2023 Mandeep Plaha <[email protected]> - 1.35.0-7
- Bump release to rebuild against glibc 2.35-5

* Wed Sep 20 2023 Jon Slobodzian <[email protected]> - 1.35.0-6
- Recompile with stack-protection fixed gcc version (CVE-2023-4039)

Expand Down
7 changes: 5 additions & 2 deletions SPECS/flannel/flannel.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Summary: Simple and easy way to configure a layer 3 network fabric designed for Kubernetes
Name: flannel
Version: 0.14.0
Release: 16%{?dist}
Release: 17%{?dist}
License: ASL 2.0
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -15,7 +15,7 @@ Source0: %{name}-%{version}.tar.gz

BuildRequires: gcc
BuildRequires: glibc-devel
BuildRequires: glibc-static >= 2.35-4%{?dist}
BuildRequires: glibc-static >= 2.35-5%{?dist}
BuildRequires: golang >= 1.18.5
BuildRequires: kernel-headers

Expand Down Expand Up @@ -48,6 +48,9 @@ install -p -m 755 -t %{buildroot}%{_bindir} ./dist/flanneld
%{_bindir}/flanneld

%changelog
* Tue Oct 03 2023 Mandeep Plaha <[email protected]> - 0.14.0-17
- Bump release to rebuild against glibc 2.35-5

* Mon Aug 07 2023 CBL-Mariner Servicing Account <[email protected]> - 0.14.0-16
- Bump release to rebuild with go 1.19.12

Expand Down
147 changes: 147 additions & 0 deletions SPECS/glibc/CVE-2023-4911.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
From 1056e5b4c3f2d90ed2b4a55f96add28da2f4c8fa Mon Sep 17 00:00:00 2001
From: Siddhesh Poyarekar <[email protected]>
Date: Tue, 19 Sep 2023 18:39:32 -0400
Subject: [PATCH] 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 <[email protected]>
Reviewed-by: Carlos O'Donell <[email protected]>

diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index 8e7ee9d..76cf8b9 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -187,11 +187,7 @@ parse_tunables (char *tunestr, char *valstring)
/* 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 *valstring)
}
}

- 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

diff --git a/elf/tst-env-setuid-tunables.c b/elf/tst-env-setuid-tunables.c
index 88182b7..0e77584 100644
--- a/elf/tst-env-setuid-tunables.c
+++ b/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",
+ "",
"",
"",
"",
@@ -84,11 +88,18 @@ test_child (int off)
const char *val = getenv ("GLIBC_TUNABLES");

#if HAVE_TUNABLES
+ printf (" [%d] GLIBC_TUNABLES is %s\n", off, val);
+ fflush (stdout);
if (val != NULL && strcmp (val, resultstrings[off]) == 0)
return 0;

if (val != NULL)
- printf ("[%d] Unexpected GLIBC_TUNABLES VALUE %s\n", off, val);
+ printf (" [%d] Unexpected GLIBC_TUNABLES VALUE %s, expected %s\n",
+ off, val, resultstrings[off]);
+ else
+ printf (" [%d] GLIBC_TUNABLES environment variable absent\n", off);
+
+ fflush (stdout);

return 1;
#else
@@ -118,30 +129,40 @@ do_test (int argc, char **argv)
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);

/* Bail out early if unsupported. */
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;
}
}

6 changes: 5 additions & 1 deletion SPECS/glibc/glibc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Summary: Main C library
Name: glibc
Version: 2.35
Release: 4%{?dist}
Release: 5%{?dist}
License: BSD AND GPLv2+ AND Inner-Net AND ISC AND LGPLv2+ AND MIT
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -27,6 +27,7 @@ Patch3: CVE-2020-1751.nopatch
# Rationale: Exploit requires crafted pattern in regex compiler meant only for trusted content
Patch4: CVE-2018-20796.nopatch
Patch5: glibc-2.34_pthread_cond_wait.patch
Patch6: CVE-2023-4911.patch
BuildRequires: bison
BuildRequires: gawk
BuildRequires: gettext
Expand Down Expand Up @@ -319,6 +320,9 @@ grep "^FAIL: nptl/tst-eintr1" tests.sum >/dev/null && n=$((n+1)) ||:
%defattr(-,root,root)

%changelog
* Tue Oct 03 2023 Mandeep Plaha <[email protected]> - 2.35-5
- Patch CVE-2023-4911

* Fri Jun 30 2023 Andrew Phelps <[email protected]> - 2.35-4
- Restore glibc-debuginfo package

Expand Down
7 changes: 5 additions & 2 deletions SPECS/kubevirt/kubevirt.spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Summary: Container native virtualization
Name: kubevirt
Version: 0.59.0
Release: 7%{?dist}
Release: 8%{?dist}
License: ASL 2.0
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -34,7 +34,7 @@ Patch1: Allocate-2-cpu-for-the-emulator-thread.patch
Patch2: Hotplug_detach_grace_period.patch
%global debug_package %{nil}
BuildRequires: glibc-devel
BuildRequires: glibc-static >= 2.35-4%{?dist}
BuildRequires: glibc-static >= 2.35-5%{?dist}
BuildRequires: golang
BuildRequires: golang-packaging
BuildRequires: pkgconfig
Expand Down Expand Up @@ -211,6 +211,9 @@ install -p -m 0644 cmd/virt-handler/nsswitch.conf %{buildroot}%{_datadir}/kube-v
%{_bindir}/virt-tests

%changelog
* Tue Oct 03 2023 Mandeep Plaha <[email protected]> - 0.59.0-8
- Bump release to rebuild against glibc 2.35-5

* Mon Aug 07 2023 CBL-Mariner Servicing Account <[email protected]> - 0.59.0-7
- Bump release to rebuild with go 1.19.12

Expand Down
7 changes: 5 additions & 2 deletions SPECS/libguestfs/libguestfs.spec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Summary: Access and modify virtual machine disk images
Name: libguestfs
Version: 1.44.0
Release: 15%{?dist}
Release: 16%{?dist}
License: LGPLv2+
Vendor: Microsoft Corporation
Distribution: Mariner
Expand Down Expand Up @@ -89,7 +89,7 @@ BuildRequires: gcc-c++
BuildRequires: gdisk
BuildRequires: genisoimage
BuildRequires: gfs2-utils
BuildRequires: glibc-static >= 2.35-4%{?dist}
BuildRequires: glibc-static >= 2.35-5%{?dist}
BuildRequires: gobject-introspection-devel
BuildRequires: gperf
BuildRequires: grep
Expand Down Expand Up @@ -1236,6 +1236,9 @@ rm ocaml/html/.gitignore
%endif

%changelog
* Tue Oct 03 2023 Mandeep Plaha <[email protected]> - 1.44.0-16
- Bump release to rebuild against glibc 2.35-5

* Wed Sep 20 2023 Jon Slobodzian <[email protected]> - 1.44.0-15
- Recompile with stack-protection fixed gcc version (CVE-2023-4039)

Expand Down
Loading

0 comments on commit 115ecc7

Please sign in to comment.