]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
powerpc: Remove arch-specific strncpy() implementation
authorKees Cook <kees@kernel.org>
Mon, 23 Mar 2026 01:17:19 +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
powerpc-specific assembly implementation from both the kernel
(arch/powerpc/lib/string.S) and the boot wrapper
(arch/powerpc/boot/string.S), along with the __HAVE_ARCH_STRNCPY
define and declaration, falling back to the generic version in
lib/string.c.

The boot wrapper's strncpy had no callers in arch/powerpc/boot/.

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

index d2a2dbf1eefc3d781d441d17d8160c8b96449093..76801eb6d93788b1abd6138f5e1f9e4177067486 100644 (file)
@@ -18,19 +18,6 @@ strcpy:
        bne     1b
        blr
 
-       .globl  strncpy
-strncpy:
-       cmpwi   0,r5,0
-       beqlr
-       mtctr   r5
-       addi    r6,r3,-1
-       addi    r4,r4,-1
-1:     lbzu    r0,1(r4)
-       cmpwi   0,r0,0
-       stbu    r0,1(r6)
-       bdnzf   2,1b            /* dec ctr, branch if ctr != 0 && !cr0.eq */
-       blr
-
        .globl  strcat
 strcat:
        addi    r5,r3,-1
index 8c2ec0c05e4e064d53371163d6a374a76984a47a..2b28d185343ca69e8ec9c1849945944a621adf97 100644 (file)
@@ -4,7 +4,6 @@
 #include <stddef.h>
 
 extern char *strcpy(char *dest, const char *src);
-extern char *strncpy(char *dest, const char *src, size_t n);
 extern char *strcat(char *dest, const char *src);
 extern char *strchr(const char *s, int c);
 extern char *strrchr(const char *s, int c);
index 60ba22770f51c867d50c3bbba32e192292c0b916..1981bd4036b5488efc393c040b10c34a5bf360ce 100644 (file)
@@ -5,7 +5,6 @@
 #ifdef __KERNEL__
 
 #ifndef CONFIG_KASAN
-#define __HAVE_ARCH_STRNCPY
 #define __HAVE_ARCH_STRNCMP
 #define __HAVE_ARCH_MEMCHR
 #define __HAVE_ARCH_MEMCMP
@@ -18,7 +17,6 @@
 #define __HAVE_ARCH_MEMCPY_FLUSHCACHE
 
 extern char * strcpy(char *,const char *);
-extern char * strncpy(char *,const char *, __kernel_size_t);
 extern __kernel_size_t strlen(const char *);
 extern int strcmp(const char *,const char *);
 extern int strncmp(const char *, const char *, __kernel_size_t);
index daa72061dc0c79c6977eeb50518c262affd743f7..c3f5e7d31ee71fe472413bb814319530a59e29b0 100644 (file)
 
        .text
        
-/* This clears out any unused part of the destination buffer,
-   just as the libc version does.  -- paulus */
-_GLOBAL(strncpy)
-       PPC_LCMPI 0,r5,0
-       beqlr
-       mtctr   r5
-       addi    r6,r3,-1
-       addi    r4,r4,-1
-       .balign IFETCH_ALIGN_BYTES
-1:     lbzu    r0,1(r4)
-       cmpwi   0,r0,0
-       stbu    r0,1(r6)
-       bdnzf   2,1b            /* dec ctr, branch if ctr != 0 && !cr0.eq */
-       bnelr                   /* if we didn't hit a null char, we're done */
-       mfctr   r5
-       PPC_LCMPI 0,r5,0        /* any space left in destination buffer? */
-       beqlr                   /* we know r0 == 0 here */
-2:     stbu    r0,1(r6)        /* clear it out if so */
-       bdnz    2b
-       blr
-EXPORT_SYMBOL(strncpy)
-
 _GLOBAL(strncmp)
        PPC_LCMPI 0,r5,0
        beq-    2f