]> www.infradead.org Git - users/jedix/linux-maple.git/commit
tracing/branch-profiler: Replace deprecated strncpy with strscpy
authorJustin Stitt <justinstitt@google.com>
Mon, 26 Aug 2024 17:40:49 +0000 (10:40 -0700)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 8 Oct 2024 19:24:38 +0000 (15:24 -0400)
commit2aa746ec0240dcbe70aef10f40fb1518f6dfb137
treefdb6be362c539ecb7e7c6ec2cb7b6567327aa0ad
parente32540b1e4b37fd720b59f8a504d7592fc3483bf
tracing/branch-profiler: 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.

Both of these fields want to be NUL-terminated as per their use in
printk:

    F_printk("%u:%s:%s (%u)%s",
      __entry->line,
      __entry->func, __entry->file, __entry->correct,
      __entry->constant ? " CONSTANT" : "")

Use strscpy() as it NUL-terminates the destination buffer, so it doesn't
have to be done manually.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Kees Cook <kees@kernel.org>
Link: https://lore.kernel.org/20240826-strncpy-kernel-trace-trace_branch-c-v1-1-b2c14f2e9e84@google.com
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_branch.c