s390/debug: Pass in and enforce output buffer size for format handlers
authorNiklas Schnelle <schnelle@linux.ibm.com>
Thu, 14 Nov 2024 15:46:02 +0000 (16:46 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Thu, 21 Nov 2024 11:44:06 +0000 (12:44 +0100)
commit897614f90f7cd9fd7f5b7acca24dfb55b6c0c4ae
tree7baf745fa0dd91f20c111d7e197fd0c702371790
parent3f020399e4f1c690ce87b4c472f75b1fc89e07d5
s390/debug: Pass in and enforce output buffer size for format handlers

The s390dbf format handler rely on being passed an output buffer sized
such that their output will always fit and then use plain sprintf() to
write to it. While only supplied data from other kernel components this
still potentially allows buffer overwrite if callers are not careful.
Instead just pass in the size of the output buffer and use scnprintf()
instead of sprintf() and strscpy() instead of strcpy(). The latter also
allows us to get rid of a separate strlen() call.

Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/include/asm/debug.h
arch/s390/kernel/debug.c