From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8022023394D; Thu, 28 May 2026 20:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780001160; cv=none; b=oGV/qJe3xxJNiflZmfG5uxpJGPPEx0uiGlS7xkXf+BFaWmg5I+PC0nThxPpJe/owH2ydK+KMdKNJJwtGZlscFcwrlQN8U5d4nLkJMyRErNvxmTctVpj/ivh70DwCru6ukUToLiS/iXSMr08rN3YX/0d3lrwsINbOfL87Hxlhfp8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780001160; c=relaxed/simple; bh=447xHg9bm5DCjAjVELZBF2GcwWPg/7hukhqJg+jyAho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KBuKQ9S0J9VN8JQJnvo5GlWcHQRjCBxtX32gq5NCwETXTHBbDubCM3uJGJeS77VioxVUqkP52Hu5LNxjs0YmbiMX8Z0sbty9Boy48BEmZRnp4IgbdjBIMyPXO+XnqyRKe3Y7SQ3AnXDUU3a2+q8+Tu0jq24COPKUnp7QNpz3Mp8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eCxp6P0d; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eCxp6P0d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1C651F000E9; Thu, 28 May 2026 20:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780001159; bh=7OhEVpfkNbBpg85BrY2owl7bkONjA6TH947zZ6rUkH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eCxp6P0dkinNyurVpz06EVMDBc49tjiHUFcY9mwb1zV2+MgR1CPrkzvrREZOvF9UQ Tb6reUvvBmOM3JqmiQGAobclow9DD+a1Z/+2F/BgpJDQuyJTcrrKxFRwkwa3kOQorz lbbot0vAy8mORL3Lv/r7bFL7mA5n4DA7Tpj3li+g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pengpeng Hou , Benjamin Block , Vasily Gorbik , Alexander Gordeev , Sasha Levin Subject: [PATCH 6.6 008/186] s390/debug: Reject zero-length input before trimming a newline Date: Thu, 28 May 2026 21:48:08 +0200 Message-ID: <20260528194929.175225883@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528194928.941004471@linuxfoundation.org> References: <20260528194928.941004471@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pengpeng Hou [ 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. Fixes: 66a464dbc8e0 ("[PATCH] s390: debug feature changes") Cc: stable@vger.kernel.org Signed-off-by: Pengpeng Hou Reviewed-by: Benjamin Block Reviewed-by: Vasily Gorbik Tested-by: Vasily Gorbik Link: https://lore.kernel.org/r/20260417073530.96002-1-pengpeng@iscas.ac.cn Signed-off-by: Vasily Gorbik Signed-off-by: Alexander Gordeev Signed-off-by: Sasha Levin --- arch/s390/kernel/debug.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c index cbe209fe0df15..893c35aeb746a 100644 --- a/arch/s390/kernel/debug.c +++ b/arch/s390/kernel/debug.c @@ -1258,6 +1258,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); -- 2.53.0