Skip to content

Commit d4163b5

Browse files
Vasily Gorbikgregkh
authored andcommitted
s390/debug: Reject zero-length input in debug_input_flush_fn()
commit e14622a upstream. debug_input_flush_fn() always copies one byte from the userspace buffer with copy_from_user() regardless of the supplied write length. A zero-length write therefore reads one byte beyond the caller's buffer. If the stale byte happens to be '-' or a digit the debug log is silently flushed. With an unmapped buffer the call returns -EFAULT. Reject zero-length writes before copying from userspace. Cc: stable@vger.kernel.org # v5.10+ Acked-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fcf6a83 commit d4163b5

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

arch/s390/kernel/debug.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,11 @@ static int debug_input_flush_fn(debug_info_t *id, struct debug_view *view,
14321432
char input_buf[1];
14331433
int rc = user_len;
14341434

1435+
if (!user_len) {
1436+
rc = -EINVAL;
1437+
goto out;
1438+
}
1439+
14351440
if (user_len > 0x10000)
14361441
user_len = 0x10000;
14371442
if (*offset != 0) {

0 commit comments

Comments
 (0)