Skip to contentSkip to conversation

test_hexdump-avoid-string-truncation-warning.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Apr 26, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: test_hexdump: avoid string truncation warning
has been removed from the -mm tree. Its filename was
test_hexdump-avoid-string-truncation-warning.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Arnd Bergmann <[email protected]>
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().

Cc Alexey Starikovskiy <[email protected]>
Cc Bob Moore <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Len Brown <[email protected]>
Cc Lin Ming <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Nicolas Schier <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Cc "Richard Russon (FlatCap)" <[email protected]>
Cc Steven Rostedt <[email protected]>

---

 lib/test_hexdump.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_hexdump.c renamed from lib/test_hexdump.c~test_hexdump-avoid-string-truncation-warning +1 -1
@@ -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 [email protected] are

kbuild-turn-on-wextra-by-default.patch kbuild-remove-redundant-extra-warning-flags.patch kbuild-turn-on-wrestrict-by-default.patch kbuild-enable-wformat-truncation-on-clang.patch kbuild-enable-wcast-function-type-strict-unconditionally.patch