Skip to content

Commit cf90a96

Browse files
neosys007gregkh
authored andcommitted
s390/debug: Reject zero-length input before trimming a newline
commit c366a7b upstream. debug_get_user_string() duplicates the userspace buffer with memdup_user_nul() and then unconditionally looks at buffer[user_len - 1] to strip a trailing newline. A zero-length write reaches this helper unchanged, so the newline trim reads before the start of the allocated buffer. Reject empty writes before accessing the last input byte. Fixes: 66a464d ("[PATCH] s390: debug feature changes") Cc: stable@vger.kernel.org Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Reviewed-by: Benjamin Block <bblock@linux.ibm.com> Reviewed-by: Vasily Gorbik <gor@linux.ibm.com> Tested-by: Vasily Gorbik <gor@linux.ibm.com> Link: https://lore.kernel.org/r/20260417073530.96002-1-pengpeng@iscas.ac.cn 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 e3eee7e commit cf90a96

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

arch/s390/kernel/debug.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,9 @@ static inline char *debug_get_user_string(const char __user *user_buf,
14161416
{
14171417
char *buffer;
14181418

1419+
if (!user_len)
1420+
return ERR_PTR(-EINVAL);
1421+
14191422
buffer = memdup_user_nul(user_buf, user_len);
14201423
if (IS_ERR(buffer))
14211424
return buffer;

0 commit comments

Comments
 (0)