[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1021426: bullseye-pu: package glibc/2.31-13+deb11u5



Package: release.debian.org
Severity: normal
Tags: bullseye
User: release.debian.org@packages.debian.org
Usertags: pu
X-Debbugs-Cc: debian-glibc@lists.debian.org

[ Reason ]
The glibc/2.31-13+deb11u4 update introduced a regression (bug #1019855)
on some early Intel Haswell processors which expose the AVX2
instructions, but lack the BMI2 instructions. On such systems the memchr
and strlen related functions fails with SIGILL, rendering them unusable.

The issue is that some of the backported commits to fix the overflow
bugs in the AVX2 implementation of wmemchr and wcslen that went in the
upstream 2.31 branch, started to use BMI2 instructions in addition to
the AVX2 instructions, without checking for the availability of those
instructions. This was done in another commit that hasn't been
backported.

It happens that a microcode update for the affected CPUs (either through
the BIOS/firmware or from a package) fixes this, so it went barely
noticed up to now, especially given other distributions usually install
firmware updates by default.

[ Impact ]
While the number of affected systems is probably small, this bug makes
them unusable.

[ Tests ]
This has been tested, by replacing all BMI2 instructions in the glibc
source code by the UD2 x86 instruction. This triggered the same issue
than the reported one in bug#1019855. Then the detection of BMI2
instructions has been disabled in the source code, and the resulting
glibc was working as expected without generating SIGILL.

[ Risks ]
The change is intentionally minimal, smaller than the upstream one, and
only targets the runtime execution. Some tests of the testsuite will
still fail on affected systems. This part can be fixed later in a point
release. This way the risks should be minimal.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
The change is very simple and consists in adding a check for BMI2
instructions in the ifunc selector that selects the AVX2 optimized code.

[ Other info ]
Given the severity of the bug, it might be a good idea to release it
through stable-updates.
diff --git a/debian/changelog b/debian/changelog
index 7952bf8b..f127d64d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+glibc (2.31-13+deb11u5) bullseye; urgency=medium
+
+  * debian/patches/local-require-bmi-in-avx2-ifunc.diff: new patch extracted
+    from an upstream commit, to change the AVX2 ifunc selector to require the
+    BMI2 feature. It happened that the wmemchr and wcslen changes backported
+    in 2.31-13+deb11u4 relied on that commit which got forgotten.
+    Closes: #1019855.
+
+ -- Aurelien Jarno <aurel32@debian.org>  Sat, 08 Oct 2022 11:25:58 +0200
+
 glibc (2.31-13+deb11u4) bullseye; urgency=medium
 
   [ Aurelien Jarno ]
diff --git a/debian/patches/amd64/local-require-bmi-in-avx2-ifunc.diff b/debian/patches/amd64/local-require-bmi-in-avx2-ifunc.diff
new file mode 100644
index 00000000..936f89ae
--- /dev/null
+++ b/debian/patches/amd64/local-require-bmi-in-avx2-ifunc.diff
@@ -0,0 +1,38 @@
+This patch is extracted from upstream commit 83c5b368226c ("x86-64: Require
+BMI2 for strchr-avx2.S"). It changes the common ifunc AVX2 selector to require
+the BMI2 instructions, and the backported fixes for memchr and strlen rely on
+that change.
+
+--- a/sysdeps/x86_64/multiarch/ifunc-avx2.h
++++ b/sysdeps/x86_64/multiarch/ifunc-avx2.h
+@@ -21,28 +21,28 @@ IFUNC_SELECTOR (void)
+ 
+ extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2) attribute_hidden;
+ extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden;
+ extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_rtm) attribute_hidden;
+ extern __typeof (REDIRECT_NAME) OPTIMIZE (evex) attribute_hidden;
+ 
+ static inline void *
+ IFUNC_SELECTOR (void)
+ {
+   const struct cpu_features* cpu_features = __get_cpu_features ();
+ 
+   if (CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable)
++      && CPU_FEATURES_CPU_P (cpu_features, BMI2)
+       && CPU_FEATURES_ARCH_P (cpu_features, AVX_Fast_Unaligned_Load))
+     {
+       if (CPU_FEATURES_ARCH_P (cpu_features, AVX512VL_Usable)
+-	  && CPU_FEATURES_ARCH_P (cpu_features, AVX512BW_Usable)
+-	  && CPU_FEATURES_CPU_P (cpu_features, BMI2))
++	  && CPU_FEATURES_ARCH_P (cpu_features, AVX512BW_Usable))
+ 	return OPTIMIZE (evex);
+ 
+       if (CPU_FEATURES_CPU_P (cpu_features, RTM))
+ 	return OPTIMIZE (avx2_rtm);
+ 
+       if (!CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_VZEROUPPER))
+ 	return OPTIMIZE (avx2);
+     }
+ 
+   return OPTIMIZE (sse2);
+ }
diff --git a/debian/patches/series b/debian/patches/series
index 02bd18e7..c72ebf30 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -22,6 +22,8 @@ alpha/local-string-functions.diff
 alpha/submitted-fts64.diff
 alpha/submitted-makecontext.diff
 
+amd64/local-require-bmi-in-avx2-ifunc.diff
+
 arm/local-sigaction.diff
 arm/unsubmitted-ldconfig-cache-abi.diff
 arm/local-soname-hack.diff

Reply to: