package/musl: add upstream security patches for CVE-2026-40200
commit: https://gitlab.com/buildroot.org/buildroot/-/commit/646954350f9d1a6bcf3badd31b8f76c7d716b857
branch: https://gitlab.com/buildroot.org/buildroot/-/tree/2025.02.x
Fixes CVE-2026-40200: musl libc: stack corruption in qsort with sufficiently large inputs
https://www.openwall.com/lists/musl/2026/04/10/3
Signed-off-by Fiona Klute <[email protected]>
Signed-off-by Julien Olivain <[email protected]>
(cherry picked from commit e96e63dc0edfc08ccd2ec1bf67d5235b995e9379)
Signed-off-by Thomas Perale <[email protected]>
--- ...eonardo-heap-corruption-from-bug-in-doubl.patch | 48 +++++++++++ ...preclude-oob-array-writes-independent-of-.patch | 97 ++++++++++++++++++++++ .../0006-qsort-fix-shift-UB-in-shl-and-shr.patch | 43 ++++++++++ package/musl/musl.mk | 5 ++ 4 files changed, 193 insertions(+)
package/musl/0004-qsort-fix-leonardo-heap-corruption-from-bug-in-doubl.patch new file +48 -0
@@ -0,0 +1,48 @@ +From 228da39e38c1cae13cbe637e771412c1984dba5d Mon Sep 17 00:00:00 2001 +From: Rich Felker <[email protected]> +Date: Thu, 9 Apr 2026 22:51:30 -0400 +Subject: [PATCH] qsort: fix leonardo heap corruption from bug in doubleword + ctz primitive + +the pntz function, implementing a "count trailing zeros" variant for a +bit vector consisting of two size_t words, erroneously returned zero +rather than the number of bits in the low word when the first bit set +was the low bit of the high word. + +as a result, a loop in the trinkle function which should have a +guaranteed small bound on the number of iterations, could run +unboundedly, thereby overflowing a stack-based working-space array +which was sized for the bound. + +CVE-2026-40200 has been assigned for this issue. + +CVE: CVE-2026-40200 +Upstream: https://git.musl-libc.org/cgit/musl/commit/?id=228da39e38c1cae13cbe637e771412c1984dba5d +Signed-off-by: Fiona Klute <[email protected]> +--- + src/stdlib/qsort.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/stdlib/qsort.c b/src/stdlib/qsort.c +index ab79dc6f..13219ab3 100644 +--- a/src/stdlib/qsort.c ++++ b/src/stdlib/qsort.c +@@ -34,11 +34,11 @@ + + typedef int (*cmpfun)(const void *, const void *, void *); + ++/* returns index of first bit set, excluding the low bit assumed to always ++ * be set, starting from low bit of p[0] up through high bit of p[1] */ + static inline int pntz(size_t p[2]) { +- int r = ntz(p[0] - 1); +- if(r != 0 || (r = 8*sizeof(size_t) + ntz(p[1])) != 8*sizeof(size_t)) { +- return r; +- } ++ if (p[0] != 1) return ntz(p[0] - 1); ++ if (p[1]) return 8*sizeof(size_t) + ntz(p[1]); + return 0; + } + +-- +2.53.0 +
package/musl/0005-qsort-hard-preclude-oob-array-writes-independent-of-.patch new file +97 -0
97 lines not on this page · raw message
package/musl/0006-qsort-fix-shift-UB-in-shl-and-shr.patch new file +43 -0
43 lines not on this page · raw message
package/musl/musl.mk +5 -0
@@ -29,6 +29,11 @@ MUSL_INSTALL_STAGING = YES # 0003-fix-pathological-slowness-incorrect-mappings-in-icon.patch MUSL_IGNORE_CVES += CVE-2026-6042 +# 0004-qsort-fix-leonardo-heap-corruption-from-bug-in-doubl.patch +# 0005-qsort-hard-preclude-oob-array-writes-independent-of-.patch +# 0006-qsort-fix-shift-UB-in-shl-and-shr.patch +MUSL_IGNORE_CVES += CVE-2026-40200 + # musl does not build with LTO, so explicitly disable it # when using a compiler that may have support for LTO ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_7),y)
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot