The patch titled Subject: watchdog/perf: optimize bytes copied and remove manual NUL-termination has been added to the -mm mm-nonmm-unstable branch. Its filename is watchdog-perf-optimize-bytes-copied-and-remove-manual-nul-termination.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/watchdog-perf-optimize-bytes-copied-and-remove-manual-nul-termination.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: Thorsten Blum <thorsten.blum@xxxxxxxxx> Subject: watchdog/perf: optimize bytes copied and remove manual NUL-termination Date: Thu, 13 Mar 2025 14:30:02 +0100 Currently, up to 23 bytes of the source string are copied to the destination buffer (including the comma and anything after it), only to then manually NUL-terminate the destination buffer again at index 'len' (where the comma was found). Fix this by calling strscpy() with 'len' instead of the destination buffer size to copy only as many bytes from the source string as needed. Change the length check to allow 'len' to be less than or equal to the destination buffer size to fill the whole buffer if needed. Remove the if-check for the return value of strscpy(), because calling strscpy() with 'len' always truncates the source string at the comma as expected and NUL-terminates the destination buffer at the corresponding index instead. Remove the manual NUL-termination. No functional changes intended. Link: https://lkml.kernel.org/r/20250313133004.36406-2-thorsten.blum@xxxxxxxxx Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx> Cc: Song Liu <song@xxxxxxxxxx> Cc: Thomas Gleinxer <tglx@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/watchdog_perf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/kernel/watchdog_perf.c~watchdog-perf-optimize-bytes-copied-and-remove-manual-nul-termination +++ a/kernel/watchdog_perf.c @@ -294,12 +294,10 @@ void __init hardlockup_config_perf_event } else { unsigned int len = comma - str; - if (len >= sizeof(buf)) + if (len > sizeof(buf)) return; - if (strscpy(buf, str, sizeof(buf)) < 0) - return; - buf[len] = 0; + strscpy(buf, str, len); if (kstrtoull(buf, 16, &config)) return; } _ Patches currently in -mm which might be from thorsten.blum@xxxxxxxxx are arm-pgtable-remove-duplicate-included-header-file.patch watchdog-perf-optimize-bytes-copied-and-remove-manual-nul-termination.patch