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 7A721175A6B; Sat, 30 May 2026 18:13:44 +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=1780164825; cv=none; b=pvrjmk2Wo6RXUuzhyPkqsxWhYScArNonEFYIJvRpcffeC//G9bsvPAWStvWDvZK3lAC6+bvU7z57DOZJQNE5XCTbwV5ErNrgSG7kXGtpdgnM/188ZidrSQWLahab12g73zxejX9C2kJrGDPklfR7rEJvbXq26wJ4uUSfcOpAyKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164825; c=relaxed/simple; bh=UAwSrLZn6knZZ1FAJyG4u4+XW+5NVGaoSQ5zjGfpGvM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bJHhuTNvviKznqnzx2ktHIiKjx6c6GtWQsh1b4AfCEFyqaF4JmWconKyPU2gsOg/pJMfx22d9mRBatQUDSAb3VJqLB+9qZFqsCApqupKRqzf4QoGfzfsh2kr/CfF407Xlf/INbp4g8r420P/NnBQkUrYY4xjcjXB5UvE2qQoWNs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Rnnmh6LN; 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="Rnnmh6LN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD5C11F00893; Sat, 30 May 2026 18:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780164824; bh=5CGIUSmvHf2ttTDkOQXE9QcBzo5ErPPLC5Uw2odlWdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Rnnmh6LNJNeVuLDfJkRnEqo2Ig5nYydBkAXIu9xL7Ud3Yhml3o8z1+n/xH5MSXDpX ngIzC9Hux1EAmZFUU/OtLxYdXCT9XiD0vtSDy8hQEqkoiFGIdhpSn3A0AcwhiIWnCd iTSRTwm843aJsfE77YzTMzasLGEQ4oepsDRBEaog= 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 5.15 670/776] s390/debug: Reject zero-length input before trimming a newline Date: Sat, 30 May 2026 18:06:24 +0200 Message-ID: <20260530160257.192441767@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-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 089d91a3cf5a1..1d7b619acdf30 100644 --- a/arch/s390/kernel/debug.c +++ b/arch/s390/kernel/debug.c @@ -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); -- 2.53.0