]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86: Remove arch-specific strncpy() implementation
authorKees Cook <kees@kernel.org>
Mon, 23 Mar 2026 01:17:59 +0000 (01:17 +0000)
committerKees Cook <kees@kernel.org>
Thu, 18 Jun 2026 23:37:13 +0000 (16:37 -0700)
strncpy() has no remaining callers in the kernel[1]. Remove the
x86-32-specific inline assembly implementation and __HAVE_ARCH_STRNCPY
define, falling back to the generic version in lib/string.c.

Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Kees Cook <kees@kernel.org>
arch/x86/include/asm/string_32.h
arch/x86/lib/string_32.c

index e9cce169bb4cd1196897e90399afadd944947ac3..43ab6806ab5393c9235864bcc7027e6551f133bf 100644 (file)
@@ -9,9 +9,6 @@
 #define __HAVE_ARCH_STRCPY
 extern char *strcpy(char *dest, const char *src);
 
-#define __HAVE_ARCH_STRNCPY
-extern char *strncpy(char *dest, const char *src, size_t count);
-
 #define __HAVE_ARCH_STRCAT
 extern char *strcat(char *dest, const char *src);
 
index f87ec24fa5790d799059b05bdd12ec6704c06da2..a9480d73c4f08d459e5ed462b19c81a119efdd87 100644 (file)
@@ -30,25 +30,6 @@ char *strcpy(char *dest, const char *src)
 EXPORT_SYMBOL(strcpy);
 #endif
 
-#ifdef __HAVE_ARCH_STRNCPY
-char *strncpy(char *dest, const char *src, size_t count)
-{
-       int d0, d1, d2, d3;
-       asm volatile("1:\tdecl %2\n\t"
-               "js 2f\n\t"
-               "lodsb\n\t"
-               "stosb\n\t"
-               "testb %%al,%%al\n\t"
-               "jne 1b\n\t"
-               "rep stosb\n"
-               "2:"
-               : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3)
-               : "0" (src), "1" (dest), "2" (count) : "memory");
-       return dest;
-}
-EXPORT_SYMBOL(strncpy);
-#endif
-
 #ifdef __HAVE_ARCH_STRCAT
 char *strcat(char *dest, const char *src)
 {