Skip to contentSkip to conversation

FAILED: patch "[PATCH] s390/debug: Reject zero-length input before trimming a" failed to apply to 6.1-stable tree

PATCH Applied [email protected] 3 participants 3 messages May 12 – May 24

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x c366a7b5ed7564e41345c380285bd3f6cb98971b
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026051255-outsider-irk-67c3@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From c366a7b5ed7564e41345c380285bd3f6cb98971b Mon Sep 17 00:00:00 2001
From: Pengpeng Hou <[email protected]>
Date: Fri, 17 Apr 2026 15:35:30 +0800
Subject: [PATCH] s390/debug: Reject zero-length input before trimming a
newline

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.

arch/s390/kernel/debug.c +3 -0
index 31430e9bcfdd..2612f634e826 100644
@@ -1414,6 +1414,9 @@ static inline char *debug_get_user_string(const char __user *user_buf,
 {
 	char *buffer;
 
+	if (!user_len)
+		return ERR_PTR(-EINVAL);
+
 	buffer = memdup_user_nul(user_buf, user_len);
 	if (IS_ERR(buffer))
 		return buffer;
#1 lore raw

PATCH 1/1 s390/debug: Reject zero-length input before trimming a newline

[ Upstream commit c366a7b5ed7564e41345c380285bd3f6cb98971b ]

debug_get_user_string() copies the userspace buffer into a newly allocated NUL-terminated buffer 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.

---
 arch/s390/kernel/debug.c | 3 +++
 1 file changed, 3 insertions(+)
arch/s390/kernel/debug.c +3 -0
index d7a8206..2d01b7a 100644
@@ -1268,6 +1268,9 @@ static inline char *debug_get_user_string(const char __user *user_buf,
 {
 	char *buffer;
 
+	if (!user_len)
+		return ERR_PTR(-EINVAL);
+
 	buffer = kmalloc(user_len + 1, GFP_KERNEL);
 	if (!buffer)
 		return ERR_PTR(-ENOMEM);
Signature · 1 line
2.50.1 (Apple Git-155)
maintainer Applied
#2 lore raw

Re: [PATCH 6.1.y] s390/debug: Reject zero-length input before trimming a newline

Queued for 6.1, thanks.

Signature · 2 lines
Thanks,
Sasha