diff options
| author | Niklas Schnelle <schnelle@linux.ibm.com> | 2024-11-14 16:46:02 +0100 |
|---|---|---|
| committer | Heiko Carstens <hca@linux.ibm.com> | 2024-11-21 12:44:06 +0100 |
| commit | 897614f90f7cd9fd7f5b7acca24dfb55b6c0c4ae (patch) | |
| tree | 7baf745fa0dd91f20c111d7e197fd0c702371790 /arch/s390/include/asm/debug.h | |
| parent | Merge tag 'sched-core-2024-11-18' of git://git.kernel.org/pub/scm/linux/kerne... (diff) | |
| download | linux-897614f90f7cd9fd7f5b7acca24dfb55b6c0c4ae.tar.gz linux-897614f90f7cd9fd7f5b7acca24dfb55b6c0c4ae.zip | |
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>
Diffstat (limited to 'arch/s390/include/asm/debug.h')
| -rw-r--r-- | arch/s390/include/asm/debug.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/s390/include/asm/debug.h b/arch/s390/include/asm/debug.h index ccd4e148b5ed..a7f7bdc9e19c 100644 --- a/arch/s390/include/asm/debug.h +++ b/arch/s390/include/asm/debug.h @@ -66,14 +66,15 @@ typedef int (debug_header_proc_t) (debug_info_t *id, struct debug_view *view, int area, debug_entry_t *entry, - char *out_buf); + char *out_buf, size_t out_buf_size); typedef int (debug_format_proc_t) (debug_info_t *id, struct debug_view *view, char *out_buf, + size_t out_buf_size, const char *in_buf); typedef int (debug_prolog_proc_t) (debug_info_t *id, struct debug_view *view, - char *out_buf); + char *out_buf, size_t out_buf_size); typedef int (debug_input_proc_t) (debug_info_t *id, struct debug_view *view, struct file *file, @@ -81,7 +82,8 @@ typedef int (debug_input_proc_t) (debug_info_t *id, size_t in_buf_size, loff_t *offset); int debug_dflt_header_fn(debug_info_t *id, struct debug_view *view, - int area, debug_entry_t *entry, char *out_buf); + int area, debug_entry_t *entry, + char *out_buf, size_t out_buf_size); struct debug_view { char name[DEBUG_MAX_NAME_LEN]; |
