[COMMITTED] x86_64: Fix strncpy and strncat overflow calls without multiarch

Adhemerval Zanella adhemerval.zanella@linaro.org
Mon Nov 9 13:17:21 GMT 2026


The AVX2 and EVEX strncpy and strncat tail call the variant without
length when the size is too large.  With --disable-multi-arch, ISA
level 3 or 4 uses these as the default implementation and the call
issues the public symbol.

This adds a check-localplt regression (strcpy, stpcpy, strcat, wcscpy,
wcpcpy, and wcscat for libc.so) and linknamespace failures (for instance
strxfrm -> __strxfrm_l -> __stpncpy -> stpcpy).

Use the internal name of the default implementations or its hidden alias
(libc).

Checked on x86_64-linux-gnu with --disable-multi-arch and
-march=x86-64-v3.  With -march=x86-64-v4, only the build, check-localplt,
and the linknamespace tests were checked, since the other tests need
AVX-512 hardware.
---
 .../x86_64/multiarch/strncpy-or-cat-overflow-def.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/sysdeps/x86_64/multiarch/strncpy-or-cat-overflow-def.h b/sysdeps/x86_64/multiarch/strncpy-or-cat-overflow-def.h
index 2ac4ddb1e8a..b1f541378cd 100644
--- a/sysdeps/x86_64/multiarch/strncpy-or-cat-overflow-def.h
+++ b/sysdeps/x86_64/multiarch/strncpy-or-cat-overflow-def.h
@@ -39,7 +39,11 @@
 #    define ISA_EXT _evex512
 #  endif
 #else
-#  define UNDERSCORES
+#  if defined USE_AS_STPCPY || defined USE_AS_WCSCPY
+#    define UNDERSCORES __
+#  else
+#    define UNDERSCORES
+#  endif
 #  define ISA_EXT
 #endif
 
@@ -65,7 +69,13 @@
 #define PRIMITIVE_OF_NAMER(underscores, prefix, postfix, ext)                 \
   underscores##prefix##postfix##ext
 
-#define OF_NAMER(...) PRIMITIVE_OF_NAMER (__VA_ARGS__)
+#if IS_IN (libc) && !defined USE_MULTIARCH
+#  define OF_JUMPTARGET(...) HIDDEN_JUMPTARGET (__VA_ARGS__)
+#else
+#  define OF_JUMPTARGET(...) __VA_ARGS__
+#endif
+
+#define OF_NAMER(...) OF_JUMPTARGET (PRIMITIVE_OF_NAMER (__VA_ARGS__))
 
 #ifndef OVERFLOW_STRCPY
 #  define OVERFLOW_STRCPY                                                     \
-- 
2.53.0



More information about the Libc-alpha mailing list