Skip to contentSkip to conversation

blktrace-convert-strncpy-to-strscpy_pad.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: blktrace: convert strncpy() to strscpy_pad()
has been removed from the -mm tree. Its filename was
blktrace-convert-strncpy-to-strscpy_pad.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: 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.

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]>

---

 kernel/trace/blktrace.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/trace/blktrace.c renamed from kernel/trace/blktrace.c~blktrace-convert-strncpy-to-strscpy_pad +1 -2
@@ -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 [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