From 79cd021451a50998b3cbaf961a10a8d8fc713b29 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 6 May 2016 17:13:11 +0200 Subject: [PATCH] Resolves: #1313404 Fix elf/tst-audit10 and elf/tst-audit4 failures --- glibc-rh1313404-1.patch | 264 ++++++++++++++++++++++++++++++++++++++++ glibc-rh1313404-2.patch | 39 ++++++ glibc-rh1313404-3.patch | 39 ++++++ glibc.spec | 7 ++ 4 files changed, 349 insertions(+) create mode 100644 glibc-rh1313404-1.patch create mode 100644 glibc-rh1313404-2.patch create mode 100644 glibc-rh1313404-3.patch diff --git a/glibc-rh1313404-1.patch b/glibc-rh1313404-1.patch new file mode 100644 index 0000000..d19f9c4 --- /dev/null +++ b/glibc-rh1313404-1.patch @@ -0,0 +1,264 @@ +commit 3c0f7407eedb524c9114bb675cd55b903c71daaa +Author: Florian Weimer +Date: Mon Mar 7 16:00:25 2016 +0100 + + tst-audit4, tst-audit10: Compile AVX/AVX-512 code separately [BZ #19269] + + This ensures that GCC will not use unsupported instructions before + the run-time check to ensure support. + +Index: b/sysdeps/x86_64/Makefile +=================================================================== +--- a/sysdeps/x86_64/Makefile ++++ b/sysdeps/x86_64/Makefile +@@ -49,7 +49,7 @@ $(objpfx)tst-audit3: $(objpfx)tst-auditm + $(objpfx)tst-audit3.out: $(objpfx)tst-auditmod3b.so + tst-audit3-ENV = LD_AUDIT=$(objpfx)tst-auditmod3b.so + +-$(objpfx)tst-audit4: $(objpfx)tst-auditmod4a.so ++$(objpfx)tst-audit4: $(objpfx)tst-audit4-aux.o $(objpfx)tst-auditmod4a.so + $(objpfx)tst-audit4.out: $(objpfx)tst-auditmod4b.so + tst-audit4-ENV = LD_AUDIT=$(objpfx)tst-auditmod4b.so + +@@ -66,7 +66,7 @@ $(objpfx)tst-audit7: $(objpfx)tst-auditm + $(objpfx)tst-audit7.out: $(objpfx)tst-auditmod7b.so + tst-audit7-ENV = LD_AUDIT=$(objpfx)tst-auditmod7b.so + +-$(objpfx)tst-audit10: $(objpfx)tst-auditmod10a.so ++$(objpfx)tst-audit10: $(objpfx)tst-audit10-aux.o $(objpfx)tst-auditmod10a.so + $(objpfx)tst-audit10.out: $(objpfx)tst-auditmod10b.so + tst-audit10-ENV = LD_AUDIT=$(objpfx)tst-auditmod10b.so + +@@ -75,7 +75,7 @@ AVX-CFLAGS=-mavx + ifeq (yes,$(config-cflags-novzeroupper)) + AVX-CFLAGS+=-mno-vzeroupper + endif +-CFLAGS-tst-audit4.c += $(AVX-CFLAGS) ++CFLAGS-tst-audit4-aux.c += $(AVX-CFLAGS) + CFLAGS-tst-auditmod4a.c += $(AVX-CFLAGS) + CFLAGS-tst-auditmod4b.c += $(AVX-CFLAGS) + CFLAGS-tst-auditmod6b.c += $(AVX-CFLAGS) +@@ -84,7 +84,7 @@ CFLAGS-tst-auditmod7b.c += $(AVX-CFLAGS) + endif + ifeq (yes,$(config-cflags-avx512)) + AVX512-CFLAGS = -mavx512f +-CFLAGS-tst-audit10.c += $(AVX512-CFLAGS) ++CFLAGS-tst-audit10-aux.c += $(AVX512-CFLAGS) + CFLAGS-tst-auditmod10a.c += $(AVX512-CFLAGS) + CFLAGS-tst-auditmod10b.c += $(AVX512-CFLAGS) + endif +Index: b/sysdeps/x86_64/tst-audit10-aux.c +=================================================================== +--- /dev/null ++++ b/sysdeps/x86_64/tst-audit10-aux.c +@@ -0,0 +1,41 @@ ++/* Test case for preserved AVX512 registers in dynamic linker, -mavx512f part. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++#include ++#include ++#include ++ ++extern __m512i audit_test (__m512i, __m512i, __m512i, __m512i, ++ __m512i, __m512i, __m512i, __m512i); ++ ++int ++tst_audit10_aux (void) ++{ ++#ifdef __AVX512F__ ++ __m512i zmm = _mm512_setzero_si512 (); ++ __m512i ret = audit_test (zmm, zmm, zmm, zmm, zmm, zmm, zmm, zmm); ++ ++ zmm = _mm512_set1_epi64 (0x12349876); ++ ++ if (memcmp (&zmm, &ret, sizeof (ret))) ++ abort (); ++ return 0; ++#else /* __AVX512F__ */ ++ return 77; ++#endif /* __AVX512F__ */ ++} +Index: b/sysdeps/x86_64/tst-audit10.c +=================================================================== +--- a/sysdeps/x86_64/tst-audit10.c ++++ b/sysdeps/x86_64/tst-audit10.c +@@ -15,13 +15,9 @@ + License along with the GNU C Library; if not, see + . */ + +-/* Test case for x86-64 preserved registers in dynamic linker. */ +- +-#ifdef __AVX512F__ +-#include +-#include + #include +-#include ++ ++int tst_audit10_aux (void); + + static int + avx512_enabled (void) +@@ -42,32 +38,15 @@ avx512_enabled (void) + return (eax & 0xe6) == 0xe6; + } + +- +-extern __m512i audit_test (__m512i, __m512i, __m512i, __m512i, +- __m512i, __m512i, __m512i, __m512i); + static int + do_test (void) + { + /* Run AVX512 test only if AVX512 is supported. */ + if (avx512_enabled ()) +- { +- __m512i zmm = _mm512_setzero_si512 (); +- __m512i ret = audit_test (zmm, zmm, zmm, zmm, zmm, zmm, zmm, zmm); +- +- zmm = _mm512_set1_epi64 (0x12349876); +- +- if (memcmp (&zmm, &ret, sizeof (ret))) +- abort (); +- } +- return 0; +-} +-#else +-static int +-do_test (void) +-{ +- return 0; ++ return tst_audit10_aux (); ++ else ++ return 77; + } +-#endif + + #define TEST_FUNCTION do_test () + #include "../../test-skeleton.c" +Index: b/sysdeps/x86_64/tst-audit4-aux.c +=================================================================== +--- /dev/null ++++ b/sysdeps/x86_64/tst-audit4-aux.c +@@ -0,0 +1,39 @@ ++/* Test case for preserved AVX registers in dynamic linker, -mavx part. ++ Copyright (C) 2009-2016 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++#include ++#include ++#include ++ ++extern __m256i audit_test (__m256i, __m256i, __m256i, __m256i, ++ __m256i, __m256i, __m256i, __m256i); ++ ++int ++tst_audit4_aux (void) ++{ ++#ifdef __AVX__ ++ __m256i ymm = _mm256_setzero_si256 (); ++ __m256i ret = audit_test (ymm, ymm, ymm, ymm, ymm, ymm, ymm, ymm); ++ ymm = _mm256_set1_epi32 (0x12349876); ++ if (memcmp (&ymm, &ret, sizeof (ret))) ++ abort (); ++ return 0; ++#else /* __AVX__ */ ++ return 77; ++#endif /* __AVX__ */ ++} +Index: b/sysdeps/x86_64/tst-audit4.c +=================================================================== +--- a/sysdeps/x86_64/tst-audit4.c ++++ b/sysdeps/x86_64/tst-audit4.c +@@ -1,11 +1,24 @@ +-/* Test case for x86-64 preserved registers in dynamic linker. */ ++/* Test case for preserved AVX registers in dynamic linker. ++ Copyright (C) 2009-2016 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ + +-#ifdef __AVX__ +-#include +-#include + #include +-#include + ++int tst_audit4_aux (void); + + static int + avx_enabled (void) +@@ -22,31 +35,15 @@ avx_enabled (void) + return (eax & 6) == 6; + } + +- +-extern __m256i audit_test (__m256i, __m256i, __m256i, __m256i, +- __m256i, __m256i, __m256i, __m256i); + static int + do_test (void) + { + /* Run AVX test only if AVX is supported. */ + if (avx_enabled ()) +- { +- __m256i ymm = _mm256_setzero_si256 (); +- __m256i ret = audit_test (ymm, ymm, ymm, ymm, ymm, ymm, ymm, ymm); +- +- ymm = _mm256_set1_epi32 (0x12349876); +- if (memcmp (&ymm, &ret, sizeof (ret))) +- abort (); +- } +- return 0; +-} +-#else +-static int +-do_test (void) +-{ +- return 0; ++ return tst_audit4_aux (); ++ else ++ return 77; + } +-#endif + + #define TEST_FUNCTION do_test () + #include "../../test-skeleton.c" diff --git a/glibc-rh1313404-2.patch b/glibc-rh1313404-2.patch new file mode 100644 index 0000000..e5232c0 --- /dev/null +++ b/glibc-rh1313404-2.patch @@ -0,0 +1,39 @@ +commit 3bd80c0de2f8e7ca8020d37739339636d169957e +Author: Roland McGrath +Date: Tue Mar 8 12:31:13 2016 -0800 + + Fix tst-audit10 build when -mavx512f is not supported. + +Index: b/sysdeps/x86_64/tst-audit10-aux.c +=================================================================== +--- a/sysdeps/x86_64/tst-audit10-aux.c ++++ b/sysdeps/x86_64/tst-audit10-aux.c +@@ -20,13 +20,13 @@ + #include + #include + +-extern __m512i audit_test (__m512i, __m512i, __m512i, __m512i, +- __m512i, __m512i, __m512i, __m512i); +- + int + tst_audit10_aux (void) + { + #ifdef __AVX512F__ ++ extern __m512i audit_test (__m512i, __m512i, __m512i, __m512i, ++ __m512i, __m512i, __m512i, __m512i); ++ + __m512i zmm = _mm512_setzero_si512 (); + __m512i ret = audit_test (zmm, zmm, zmm, zmm, zmm, zmm, zmm, zmm); + +Index: b/sysdeps/x86_64/tst-audit10.c +=================================================================== +--- a/sysdeps/x86_64/tst-audit10.c ++++ b/sysdeps/x86_64/tst-audit10.c +@@ -16,6 +16,7 @@ + . */ + + #include ++#include + + int tst_audit10_aux (void); + diff --git a/glibc-rh1313404-3.patch b/glibc-rh1313404-3.patch new file mode 100644 index 0000000..bac36f9 --- /dev/null +++ b/glibc-rh1313404-3.patch @@ -0,0 +1,39 @@ +commit f327f5b47be57bc05a4077344b381016c1bb2c11 +Author: Florian Weimer +Date: Fri Mar 25 11:11:42 2016 +0100 + + tst-audit10: Fix compilation on compilers without bit_AVX512F [BZ #19860] + + [BZ# 19860] + * sysdeps/x86_64/tst-audit10.c (avx512_enabled): Always return + zero if the compiler does not provide the AVX512F bit. + +Index: b/sysdeps/x86_64/tst-audit10.c +=================================================================== +--- a/sysdeps/x86_64/tst-audit10.c ++++ b/sysdeps/x86_64/tst-audit10.c +@@ -16,13 +16,13 @@ + . */ + + #include +-#include + + int tst_audit10_aux (void); + + static int + avx512_enabled (void) + { ++#ifdef bit_AVX512F + unsigned int eax, ebx, ecx, edx; + + if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0 +@@ -37,6 +37,9 @@ avx512_enabled (void) + + /* Verify that ZMM, YMM and XMM states are enabled. */ + return (eax & 0xe6) == 0xe6; ++#else ++ return 0; ++#endif + } + + static int diff --git a/glibc.spec b/glibc.spec index ec3d903..69be85b 100644 --- a/glibc.spec +++ b/glibc.spec @@ -231,6 +231,9 @@ Patch1008: glibc-rh1332914-2.patch Patch1009: glibc-rh1332914-3.patch Patch1010: glibc-rh1332914-4.patch Patch1011: glibc-rh1332914-5.patch +Patch1012: glibc-rh1313404-1.patch +Patch1013: glibc-rh1313404-2.patch +Patch1014: glibc-rh1313404-3.patch ############################################################################## # @@ -661,6 +664,9 @@ microbenchmark tests on the system. %patch1009 -p1 %patch1010 -p1 %patch1011 -p1 +%patch1012 -p1 +%patch1013 -p1 +%patch1014 -p1 %patch0059 -p1 ############################################################################## @@ -1885,6 +1891,7 @@ rm -f *.filelist* - Fix heap-based buffer overflow in get_txt_records (#1332912) - CVE-2016-3075: Stack overflow in _nss_dns_getnetbyname_r (#1321954) - April 2016 nss_dns hardening (#1332914) +- Fix elf/tst-audit10 and elf/tst-audit4 failures (#1313404) * Wed Mar 02 2016 Mike FABIAN - 2.22-11 - Add the C.UTF-8 locale