]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/sysinfo: Replace sprintf() with snprintf() for buffer safety
authorJosephine Pfeiffer <hi@josie.lol>
Wed, 1 Oct 2025 17:41:04 +0000 (19:41 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Tue, 21 Oct 2025 08:17:29 +0000 (10:17 +0200)
Replace sprintf() with snprintf() when formatting symlink target name
to prevent potential buffer overflow. The link_to buffer is only 10
bytes, and using snprintf() ensures proper bounds checking if the
topology nesting limit value is unexpectedly large.

Signed-off-by: Josephine Pfeiffer <hi@josie.lol>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/kernel/sysinfo.c

index 1ea84e942bd4220a1c1a84dbb8de885a4952cc01..33ca3e47a0e6f8b7726603e0289d22cadf7bfe3a 100644 (file)
@@ -526,7 +526,7 @@ static __init int stsi_init_debugfs(void)
        if (IS_ENABLED(CONFIG_SCHED_TOPOLOGY) && cpu_has_topology()) {
                char link_to[10];
 
-               sprintf(link_to, "15_1_%d", topology_mnest_limit());
+               snprintf(link_to, sizeof(link_to), "15_1_%d", topology_mnest_limit());
                debugfs_create_symlink("topology", stsi_root, link_to);
        }
        return 0;