The patch titled Subject: blktrace: convert strncpy() to strscpy_pad() has been added to the -mm mm-nonmm-unstable branch. Its filename is blktrace-convert-strncpy-to-strscpy_pad.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/blktrace-convert-strncpy-to-strscpy_pad.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Arnd Bergmann <arnd@xxxxxxxx> Subject: blktrace: convert strncpy() to strscpy_pad() Date: Tue, 9 Apr 2024 16:00:57 +0200 gcc-9 warns about a possibly non-terminated string copy: kernel/trace/blktrace.c: In function 'do_blk_trace_setup': kernel/trace/blktrace.c:527:2: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation] Newer versions are fine here because they see the following explicit nul-termination. Using strscpy_pad() avoids the warning and simplifies the code a little. The padding helps give a clean buffer to userspace. Link: https://lkml.kernel.org/r/20240409140059.3806717-5-arnd@xxxxxxxxxx Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx> Cc: Alexey Starikovskiy <astarikovskiy@xxxxxxx> Cc: Bob Moore <robert.moore@xxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Len Brown <lenb@xxxxxxxxxx> Cc: Lin Ming <ming.m.lin@xxxxxxxxx> Cc: Masahiro Yamada <masahiroy@xxxxxxxxxx> Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx> Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> Cc: Nathan Chancellor <nathan@xxxxxxxxxx> Cc: Nicolas Schier <nicolas@xxxxxxxxx> Cc: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx> Cc: "Richard Russon (FlatCap)" <ldm@xxxxxxxxxxx> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx> Cc: Justin Stitt <justinstitt@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/trace/blktrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/kernel/trace/blktrace.c~blktrace-convert-strncpy-to-strscpy_pad +++ a/kernel/trace/blktrace.c @@ -524,8 +524,7 @@ static int do_blk_trace_setup(struct req if (!buts->buf_size || !buts->buf_nr) return -EINVAL; - strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); - buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0'; + strscpy_pad(buts->name, name, BLKTRACE_BDEV_SIZE); /* * some device names have larger paths - convert the slashes _ Patches currently in -mm which might be from arnd@xxxxxxxx are fix-missing-vmalloch-includes-fix-5.patch kcov-avoid-clang-out-of-range-warning.patch test_hexdump-avoid-string-truncation-warning.patch block-partitions-ldm-convert-strncpy-to-strscpy.patch blktrace-convert-strncpy-to-strscpy_pad.patch