aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
authorKees Cook <kees@kernel.org>2026-03-23 01:17:19 +0000
committerKees Cook <kees@kernel.org>2026-06-18 16:37:13 -0700
commit7eda356658cbfba9aea48bddd12b97e562c21188 (patch)
tree7ddeb6a1ca758b24696912a15508e714b079068d /arch
parentad3242a9acaa01cc9ecc6e483341697ca4f77461 (diff)
downloadath-7eda356658cbfba9aea48bddd12b97e562c21188.tar.gz
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>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/boot/string.S13
-rw-r--r--arch/powerpc/boot/string.h1
-rw-r--r--arch/powerpc/include/asm/string.h2
-rw-r--r--arch/powerpc/lib/string.S22
4 files changed, 0 insertions, 38 deletions
diff --git a/arch/powerpc/boot/string.S b/arch/powerpc/boot/string.S
index d2a2dbf1eefc3..76801eb6d9378 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 8c2ec0c05e4e0..2b28d185343ca 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 60ba22770f51c..1981bd4036b54 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 daa72061dc0c7..c3f5e7d31ee71 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