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=1796389439; b=i6TmWsU9TS8UbR6ySEfbHHZp+PBnB3wUC2RxDaR6OUyczHj/vxgms/nzuOoFkioS9p+e AQYH2kwdwm/JwSCjlJB/m+CpfJ9hEN2ISHeStNxfXKT610/9SiKcYjl45AuOvZuEUF8Hm 3FL4xJHB8hT6+6DF1Y/UY+QBCrm+qrOHA+/nq9wIShhV9l6JMrXQi0Itpj2qL72ir4DeQ s563PT08BNaUChPWTmLIr54nxSfw7xckn1oBoMSgS+YjuxbWK4ZwtiJKTvCcDVbT5xGT6 hQMpCGsu8xrxpGn/jcVC+a95XnmdPMPkwHzH6S1rJU5WL/d8swRsMoeCrxshoo26Q/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389439; 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=mU66PXFOKmFr7e+fsSvtUb4Azj7Gb2CgrgHPtk/s+mU=; b=mIg3PkhqfFEHomB5BXnZxZcTtQA4FE3Jcb4eTEpl5Y8m/bxGg/6LJs30PdRNm75MRQNm rnQQTWfiTRDFH+AKJd8owlRI9ykz+VGIb59NL/efEO4tsqieTF2SnoFOGJ+GCebKSy3NE 3nXiqh3/ARhPritPSaZ5kJ9dJ/vkZ+cNFeFLUCxb//J8hIpRFjcwG0DjvMyXihh36/vCu ijz/j3WdIDEYpSR22bcBpeqhXpiIma+6tv76PjBYBvy5b72CjXyS/AIZ/Vm07iqdeXDSU hhciQCsOGI0xkT76oh0/A7PqQWVy7Zk60ddPEex0Nbieju4bf39S8F62m4fm5VNVt9A== 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=wSgXGTS+; 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 64122606A33C; Fri, 4 Dec 2026 13:03:59 +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=wSgXGTS+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7C631F00A0C; Fri, 4 Dec 2026 13:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389439; bh=mU66PXFOKmFr7e+fsSvtUb4Azj7Gb2CgrgHPtk/s+mU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wSgXGTS+RmrOBuISGTWDIv/bYw+4nFm/Xt4ZNX6D9xCMN7lKmXLPSwc8SjknqJOaY gBQZnrUqw7bFoFD1biEL2vizb+oOzWrcPKFtPF9Rdy+NvJaRQqkA0jNPbEVY+RUZMq fuXRW0IW3S4boywDzda5gRabD8jFKskIkaayAH7c= 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.1 0975/1059] powerpc/eeh: NUL-terminate force recovery input Date: Fri, 4 Dec 2026 19:08:26 +0900 Message-ID: <20261204100709.265384602@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 @@ -1647,10 +1647,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;