The patch titled Subject: test_hexdump: avoid string truncation warning has been added to the -mm mm-nonmm-unstable branch. Its filename is test_hexdump-avoid-string-truncation-warning.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/test_hexdump-avoid-string-truncation-warning.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: test_hexdump: avoid string truncation warning Date: Tue, 9 Apr 2024 16:00:54 +0200 gcc can warn when a string is too long to fit into the strncpy() destination buffer, as it is here depending on the function arguments: inlined from 'test_hexdump_prepare_test.constprop' at /home/arnd/arm-soc/lib/test_hexdump.c:116:3: include/linux/fortify-string.h:108:33: error: '__builtin_strncpy' output truncated copying between 0 and 32 bytes from a string of length 32 [-Werror=stringop-truncation] 108 | #define __underlying_strncpy __builtin_strncpy | ^ include/linux/fortify-string.h:187:16: note: in expansion of macro '__underlying_strncpy' 187 | return __underlying_strncpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~~ The intention here is to copy exactly 'l' bytes without any padding or NUL-termination, so the most logical change is to use memcpy(), just as a previous change adapted the other output from strncpy() to memcpy(). Link: https://lkml.kernel.org/r/20240409140059.3806717-2-arnd@xxxxxxxxxx Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx> Cc: Justin Stitt <justinstitt@xxxxxxxxxx> 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> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/test_hexdump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/lib/test_hexdump.c~test_hexdump-avoid-string-truncation-warning +++ a/lib/test_hexdump.c @@ -113,7 +113,7 @@ static void __init test_hexdump_prepare_ *p++ = ' '; } while (p < test + rs * 2 + rs / gs + 1); - strncpy(p, data_a, l); + memcpy(p, data_a, l); p += l; } _ 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