From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382558; b=xpk0p2V5IQi5RYMPxS175Tf5FBzSu0HnUQ7urvXOe8iLWkbRbOBl2K1/R3p+ZyvtRqSi a2ohqrLFB2o0jmWVkf7gjXSuDnJAQEI9fXG7LD1eMjrs7EufDsy0EtCpVDl+sd/3jPIV9 Z9qlQBzDHg+JFQ5W+MDexTid7wRr7Zm6d3QvSUuABIJGdF+0WKZpMYR04QzAPue/o4hx/ 72CDFc6yQU+q3/U3kNrXSHrr1P/oMdq8b+YlKg+C5eykK3cRkf31TLybPuJL8szoAkF9l oKLTAxb36PyZCJnp/722PzWc6G+F+5HJe/tLe1SbGDC1uE+slDEdkC3QBkJ+eGzGMhQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382558; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=bHYTbE83oofrp3xh5fHtiJDVsTqijWMOTVkrk9de5Zw=; b=Qhen64fvOZQelDyku/+YrLga1//0eKDLJdKUwcg7z8y93P58RvPWbPPlCHXJRd/0XvK0 aSZPGpaXTUvFZEPgG+lju8lkF8n10D15ZkU/gTUPZyOeICFlea34kQJX1SoOhH/8Q+ivj Yh7EGqhyS1WRrfjwRmY1QviBZv7dE6Jnn2+SeXI1HfNgqIf7eWVWFA6DFmqKCIMeNHiNj ylcRI+Qab0Aoit0nb7GqnSBf2c6BylDeVD0r+/YNQ/at6iT1tvwyuBoODkEPiMXPOGaW+ CtRki+ejPQOY+mxlyNRslL1lW0JIfIV896qbzHsjKYKnxOGs4h6d1w4l/60t0eJLyTw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ck9YLq5e; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10B88606A322; Fri, 4 Dec 2026 11:09:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ck9YLq5e Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42A851F000C2; Fri, 4 Dec 2026 11:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382557; bh=bHYTbE83oofrp3xh5fHtiJDVsTqijWMOTVkrk9de5Zw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ck9YLq5eWzY3kYofRmZvTGEVu5hxHYtzZ9inX6XtiJp4yYBzerSDkSlV/v4KwhyWG h9RZQK5kOqVEmjPfxNWGXOFcCAjqLOxARtGAPFByj51RJ3mUKffIAn96nIvqdXei9O Vs2NakRYPBjGO6QA9At1MRc2NIU0iW27KLfspyV8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiale Yao , "Ritesh Harjani (IBM)" , Madhavan Srinivasan Subject: [PATCH 6.18 506/703] powerpc/eeh: NUL-terminate force recovery input Date: Fri, 4 Dec 2026 19:06:45 +0900 Message-ID: <20261204100641.259194279@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiale Yao commit f294ebd827e7a2b831b1eef4aaf437f07b2c235e upstream. eeh_force_recover_write() can fill its entire stack buffer from userspace and then pass the unterminated data to strncmp() and sscanf(). This can make the string helpers read beyond the buffer. Reserve the last byte and initialize the buffer so every accepted input is NUL-terminated. Propagate copy errors before parsing as well. Fixes: 954bd99435b8 ("powerpc/eeh: Add eeh_force_recover to debugfs") Cc: stable@vger.kernel.org Signed-off-by: Jiale Yao Reviewed-by: Ritesh Harjani (IBM) Signed-off-by: Madhavan Srinivasan Link: https://patch.msgid.link/20261029052948.2525048-1-yaojiale02@163.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/eeh.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/arch/powerpc/kernel/eeh.c +++ b/arch/powerpc/kernel/eeh.c @@ -1728,10 +1728,12 @@ static ssize_t eeh_force_recover_write(s struct pci_controller *hose; uint32_t phbid, pe_no; struct eeh_pe *pe; - char buf[20]; + char buf[20] = {}; int ret; - ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count); + ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); + if (ret < 0) + return ret; if (!ret) return -EFAULT;