42eb238e49
* Tue Mar 15 2022 Florian Weimer <fweimer@redhat.com> - 2.34-29 - Sync with upstream branch release/2.34/master, commit 224d8c1890b6c57c7e4e8ddbb792dd9552086704: - debug: Synchronize feature guards in fortified functions [BZ #28746] - debug: Autogenerate _FORTIFY_SOURCE tests - Enable _FORTIFY_SOURCE=3 for gcc 12 and above - fortify: Fix spurious warning with realpath - __glibc_unsafe_len: Fix comment - debug: Add tests for _FORTIFY_SOURCE=3 - Make sure that the fortified function conditionals are constant - Don't add access size hints to fortifiable functions - nss: Protect against errno changes in function lookup (bug 28953) - nss: Do not mention NSS test modules in <gnu/lib-names.h> - io: Add fsync call in tst-stat - hppa: Fix warnings from _dl_lookup_address - nptl: Fix cleanups for stack grows up [BZ# 28899] - hppa: Revise gettext trampoline design - hppa: Fix swapcontext - Fix elf/tst-audit2 on hppa - localedef: Handle symbolic links when generating locale-archive - NEWS: Add a bug fix entry for BZ #28896 - x86: Fix TEST_NAME to make it a string in tst-strncmp-rtm.c - x86: Test wcscmp RTM in the wcsncmp overflow case [BZ #28896] - x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896] - string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] - linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865] - Add reference to BZ#28860 on NEWS - linux: Fix missing __convert_scm_timestamps (BZ #28860) Resolves: #2063230 Resolves: #2033683 Resolves: #2063041 Resolves: #2063142
140 lines
4.3 KiB
Diff
140 lines
4.3 KiB
Diff
commit d093b677c36ef4b360bf30483b68b95d9f0ad1d2
|
|
Author: Noah Goldstein <goldstein.w.n@gmail.com>
|
|
Date: Fri Feb 18 14:19:15 2022 -0600
|
|
|
|
x86: Test wcscmp RTM in the wcsncmp overflow case [BZ #28896]
|
|
|
|
In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
|
|
call strcmp-avx2 and wcscmp-avx2 respectively. This would have
|
|
not checks around vzeroupper and would trigger spurious
|
|
aborts. This commit fixes that.
|
|
|
|
test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass on
|
|
AVX2 machines with and without RTM.
|
|
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
|
|
|
|
(cherry picked from commit 7835d611af0854e69a0c71e3806f8fe379282d6f)
|
|
|
|
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
|
|
index af934d6ccf1fa337..cd94e683afd5b4a4 100644
|
|
--- a/sysdeps/x86/Makefile
|
|
+++ b/sysdeps/x86/Makefile
|
|
@@ -95,7 +95,9 @@ tests += \
|
|
tst-strcpy-rtm \
|
|
tst-strlen-rtm \
|
|
tst-strncmp-rtm \
|
|
- tst-strrchr-rtm
|
|
+ tst-strrchr-rtm \
|
|
+ tst-wcsncmp-rtm \
|
|
+# tests
|
|
|
|
CFLAGS-tst-memchr-rtm.c += -mrtm
|
|
CFLAGS-tst-memcmp-rtm.c += -mrtm
|
|
@@ -107,6 +109,7 @@ CFLAGS-tst-strcpy-rtm.c += -mrtm
|
|
CFLAGS-tst-strlen-rtm.c += -mrtm
|
|
CFLAGS-tst-strncmp-rtm.c += -mrtm -Wno-error
|
|
CFLAGS-tst-strrchr-rtm.c += -mrtm
|
|
+CFLAGS-tst-wcsncmp-rtm.c += -mrtm -Wno-error
|
|
endif
|
|
|
|
ifneq ($(enable-cet),no)
|
|
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
|
|
index 4d0004b58aae428d..4e9f094f39c72f67 100644
|
|
--- a/sysdeps/x86/tst-strncmp-rtm.c
|
|
+++ b/sysdeps/x86/tst-strncmp-rtm.c
|
|
@@ -19,18 +19,32 @@
|
|
#include <stdint.h>
|
|
#include <tst-string-rtm.h>
|
|
|
|
+#ifdef WIDE
|
|
+# define CHAR wchar_t
|
|
+# define MEMSET wmemset
|
|
+# define STRNCMP wcsncmp
|
|
+# define TEST_NAME wcsncmp
|
|
+#else /* !WIDE */
|
|
+# define CHAR char
|
|
+# define MEMSET memset
|
|
+# define STRNCMP strncmp
|
|
+# define TEST_NAME strncmp
|
|
+#endif /* !WIDE */
|
|
+
|
|
+
|
|
+
|
|
#define LOOP 3000
|
|
#define STRING_SIZE 1024
|
|
-char string1[STRING_SIZE];
|
|
-char string2[STRING_SIZE];
|
|
+CHAR string1[STRING_SIZE];
|
|
+CHAR string2[STRING_SIZE];
|
|
|
|
__attribute__ ((noinline, noclone))
|
|
static int
|
|
prepare (void)
|
|
{
|
|
- memset (string1, 'a', STRING_SIZE - 1);
|
|
- memset (string2, 'a', STRING_SIZE - 1);
|
|
- if (strncmp (string1, string2, STRING_SIZE) == 0)
|
|
+ MEMSET (string1, 'a', STRING_SIZE - 1);
|
|
+ MEMSET (string2, 'a', STRING_SIZE - 1);
|
|
+ if (STRNCMP (string1, string2, STRING_SIZE) == 0)
|
|
return EXIT_SUCCESS;
|
|
else
|
|
return EXIT_FAILURE;
|
|
@@ -40,7 +54,7 @@ __attribute__ ((noinline, noclone))
|
|
static int
|
|
function (void)
|
|
{
|
|
- if (strncmp (string1, string2, STRING_SIZE) == 0)
|
|
+ if (STRNCMP (string1, string2, STRING_SIZE) == 0)
|
|
return 0;
|
|
else
|
|
return 1;
|
|
@@ -50,7 +64,7 @@ __attribute__ ((noinline, noclone))
|
|
static int
|
|
function_overflow (void)
|
|
{
|
|
- if (strncmp (string1, string2, SIZE_MAX) == 0)
|
|
+ if (STRNCMP (string1, string2, SIZE_MAX) == 0)
|
|
return 0;
|
|
else
|
|
return 1;
|
|
@@ -59,9 +73,9 @@ function_overflow (void)
|
|
static int
|
|
do_test (void)
|
|
{
|
|
- int status = do_test_1 ("strncmp", LOOP, prepare, function);
|
|
+ int status = do_test_1 (TEST_NAME, LOOP, prepare, function);
|
|
if (status != EXIT_SUCCESS)
|
|
return status;
|
|
- status = do_test_1 ("strncmp", LOOP, prepare, function_overflow);
|
|
+ status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow);
|
|
return status;
|
|
}
|
|
diff --git a/sysdeps/x86/tst-wcsncmp-rtm.c b/sysdeps/x86/tst-wcsncmp-rtm.c
|
|
new file mode 100644
|
|
index 0000000000000000..bad3b863782c5e56
|
|
--- /dev/null
|
|
+++ b/sysdeps/x86/tst-wcsncmp-rtm.c
|
|
@@ -0,0 +1,21 @@
|
|
+/* Test case for wcsncmp inside a transactionally executing RTM region.
|
|
+ Copyright (C) 2022 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
|
|
+ <https://www.gnu.org/licenses/>. */
|
|
+
|
|
+#define WIDE 1
|
|
+#include <wchar.h>
|
|
+#include "tst-strncmp-rtm.c"
|