* [PATCH] powerpc/eeh: NUL-terminate force recovery input
@ 2026-10-29 5:29 Jiale Yao
2026-10-30 0:41 ` Ritesh Harjani
0 siblings, 1 reply; 2+ messages in thread
From: Jiale Yao @ 2026-10-29 5:29 UTC (permalink / raw)
To: Mahesh J Salgaonkar, Oliver O'Halloran, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM),
Shrikanth Hegde, linuxppc-dev, linux-kernel
Cc: stable
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 <yaojiale02@163.com>
---
arch/powerpc/kernel/eeh.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index bb836f02101c..2d7898ef6b8c 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1728,10 +1728,12 @@ static ssize_t eeh_force_recover_write(struct file *filp,
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;
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] powerpc/eeh: NUL-terminate force recovery input
2026-10-29 5:29 [PATCH] powerpc/eeh: NUL-terminate force recovery input Jiale Yao
@ 2026-10-30 0:41 ` Ritesh Harjani
0 siblings, 0 replies; 2+ messages in thread
From: Ritesh Harjani @ 2026-10-30 0:41 UTC (permalink / raw)
To: Jiale Yao, Mahesh J Salgaonkar, Oliver O'Halloran,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP),
Shrikanth Hegde, linuxppc-dev, linux-kernel
Cc: stable
Jiale Yao <yaojiale02@163.com> writes:
> 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 <yaojiale02@163.com>
> ---
> arch/powerpc/kernel/eeh.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
Nice catch! Thanks for fixing it.
LGTM, so please feel free to add:
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-30 0:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-29 5:29 [PATCH] powerpc/eeh: NUL-terminate force recovery input Jiale Yao
2026-10-30 0:41 ` Ritesh Harjani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®