linux/kernel/module
Justin Stitt 086437d94a kallsyms: replace deprecated strncpy with strscpy
strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces. The goal is to remove its use completely [2].

namebuf is eventually cleaned of any trailing llvm suffixes using
strstr(). This hints that namebuf should be NUL-terminated.

static void cleanup_symbol_name(char *s)
{
	char *res;
	...
	res = strstr(s, ".llvm.");
	...
}

Due to this, use strscpy() over strncpy() as it guarantees
NUL-termination on the destination buffer. Drop the -1 from the length
calculation as it is no longer needed to ensure NUL-termination.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90 [2]
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
2024-05-14 00:31:43 -07:00
..
debug_kmemleak.c
decompress.c module/decompress: use kvmalloc() consistently 2023-11-02 07:35:39 -10:00
dups.c module: Remove redundant TASK_UNINTERRUPTIBLE 2023-12-19 13:30:28 -08:00
internal.h module: Don't ignore errors from set_memory_XX() 2024-02-16 11:30:43 -08:00
kallsyms.c kallsyms: replace deprecated strncpy with strscpy 2024-05-14 00:31:43 -07:00
Kconfig module: allow UNUSED_KSYMS_WHITELIST to be relative against objtree. 2024-05-14 00:31:43 -07:00
kdb.c module: replace module_layout with module_memory 2023-03-09 12:55:15 -08:00
kmod.c module: add debugging auto-load duplicate module support 2023-04-19 17:26:01 -07:00
livepatch.c livepatch: fix ELF typos 2023-03-09 11:08:24 +01:00
main.c - Sumanth Korikkar has taught s390 to allocate hotplug-time page frames 2024-03-14 17:43:30 -07:00
Makefile module: add debugging auto-load duplicate module support 2023-04-19 17:26:01 -07:00
procfs.c module: replace module_layout with module_memory 2023-03-09 12:55:15 -08:00
signing.c
stats.c module: Fix comment typo 2023-11-01 13:07:08 -07:00
strict_rwx.c module: Don't ignore errors from set_memory_XX() 2024-02-16 11:30:43 -08:00
sysfs.c module: Annotate struct module_notes_attrs with __counted_by 2023-11-01 13:07:32 -07:00
tracking.c module: add debug stats to help identify memory pressure 2023-04-18 11:15:24 -07:00
tree_lookup.c module: replace module_layout with module_memory 2023-03-09 12:55:15 -08:00
version.c