linux/drivers/misc/lkdtm
Kees Cook 079a028d63 string: Remove strncpy() from the kernel
strncpy() has been a persistent source of bugs due to its ambiguous
intended usage and frequently counter-intuitive semantics: it may not
NUL-terminate the destination, and it unconditionally zero-pads to the
full length, which isn't always needed. All former callers have been
migrated[1] to:

  - strscpy()        for NUL-terminated destinations
  - strscpy_pad()    for NUL-terminated destinations needing zero-padding
  - strtomem_pad()   for non-NUL-terminated fixed-width fields
  - memcpy_and_pad() for bounded copies with explicit padding
  - memcpy()         for known-length copies

Remove the generic implementation, its declaration, the FORTIFY_SOURCE
wrapper, and associated tests.

Link: https://github.com/KSPP/linux/issues/90 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
2026-06-18 16:39:31 -07:00
..
bugs.c lkdtm: Add case to provoke a crash in EFI runtime services 2026-05-21 03:19:47 -07:00
cfi.c kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI 2025-09-24 14:29:14 -07:00
core.c lkdtm/powerpc: add PPC_RADIX_TLBIEL test for radix MCE validation 2026-05-21 03:21:01 -07:00
fortify.c string: Remove strncpy() from the kernel 2026-06-18 16:39:31 -07:00
heap.c lkdtm: use SLAB_NO_MERGE instead of an empty constructor 2025-04-28 10:32:43 -07:00
kstack_erase.c stackleak: Rename STACKLEAK to KSTACK_ERASE 2025-07-21 21:35:01 -07:00
lkdtm.h lkdtm: Move crashtype definitions into each category 2022-04-12 16:16:48 -07:00
Makefile lkdtm/powerpc: add PPC_RADIX_TLBIEL test for radix MCE validation 2026-05-21 03:21:01 -07:00
perms.c objtool: Validate kCFI calls 2025-08-18 14:23:09 +02:00
powerpc.c lkdtm/powerpc: add PPC_RADIX_TLBIEL test for radix MCE validation 2026-05-21 03:21:01 -07:00
refcount.c refcount: Report UAF for refcount_sub_and_test(0) when counter==0 2024-08-05 14:34:23 -07:00
rodata.c lkdtm: don't move ctors to .rodata 2020-12-09 15:51:14 +01:00
usercopy.c treewide: Drop function_nocfi 2022-09-26 10:13:14 -07:00