From: Josephine Pfeiffer Date: Wed, 1 Oct 2025 16:36:22 +0000 (+0200) Subject: s390/cmm: Replace sprintf() with scnprintf() for buffer safety X-Git-Tag: v6.19-rc1~206^2~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd7d1d34ae484ba2caed8e01e03bdc4c263b1442;p=thirdparty%2Flinux.git s390/cmm: Replace sprintf() with scnprintf() for buffer safety Replace sprintf() with scnprintf() in cmm_timeout_handler() to prevent potential buffer overflow. The scnprintf() function ensures we don't write beyond the buffer size and provides safer string formatting. Signed-off-by: Josephine Pfeiffer Signed-off-by: Heiko Carstens --- diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c index e2a6eb92420fc..eb7ef63fab1e5 100644 --- a/arch/s390/mm/cmm.c +++ b/arch/s390/mm/cmm.c @@ -321,8 +321,8 @@ static int cmm_timeout_handler(const struct ctl_table *ctl, int write, cmm_set_timeout(nr, seconds); *ppos += *lenp; } else { - len = sprintf(buf, "%ld %ld\n", - cmm_timeout_pages, cmm_timeout_seconds); + len = scnprintf(buf, sizeof(buf), "%ld %ld\n", + cmm_timeout_pages, cmm_timeout_seconds); if (len > *lenp) len = *lenp; memcpy(buffer, buf, len);