Commit 7eda356658cb for kernel

commit 7eda356658cbfba9aea48bddd12b97e562c21188
Author: Kees Cook <kees@kernel.org>
Date:   Mon Mar 23 01:17:19 2026 +0000

    powerpc: Remove arch-specific strncpy() implementation

    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 [1]
    Signed-off-by: Kees Cook <kees@kernel.org>

diff --git a/arch/powerpc/boot/string.S b/arch/powerpc/boot/string.S
index d2a2dbf1eefc..76801eb6d937 100644
--- a/arch/powerpc/boot/string.S
+++ b/arch/powerpc/boot/string.S
@@ -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
diff --git a/arch/powerpc/boot/string.h b/arch/powerpc/boot/string.h
index 8c2ec0c05e4e..2b28d185343c 100644
--- a/arch/powerpc/boot/string.h
+++ b/arch/powerpc/boot/string.h
@@ -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);
diff --git a/arch/powerpc/include/asm/string.h b/arch/powerpc/include/asm/string.h
index 60ba22770f51..1981bd4036b5 100644
--- a/arch/powerpc/include/asm/string.h
+++ b/arch/powerpc/include/asm/string.h
@@ -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);
diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S
index daa72061dc0c..c3f5e7d31ee7 100644
--- a/arch/powerpc/lib/string.S
+++ b/arch/powerpc/lib/string.S
@@ -10,28 +10,6 @@

 	.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