* [PATCH v2] riscv: hwprobe: Avoid uninitialized read in hwprobe_get_cpus()
@ 2026-07-14 0:30 ` Mark Harris
0 siblings, 0 replies; 4+ messages in thread
From: Mark Harris @ 2026-07-14 0:30 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou
Cc: Alexandre Ghiti, Mark Harris, Nam Cao, Michael Ellerman,
linux-riscv, linux-kernel
When cpusetsize < cpumask_size(), hwprobe_get_cpus() did not fully
initialize its copy of the cpu mask, which could cause non-deterministic
results from the riscv_hwprobe syscall on a system with more than 8 CPUs
when the supplied cpu mask is empty. Address this by fully initializing
the cpu mask.
Fixes: e178bf146e4b ("RISC-V: hwprobe: Introduce which-cpus flag")
Signed-off-by: Mark Harris <mark.hsj@gmail.com>
Reviewed-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Michael Ellerman <mpe@kernel.org>
---
v2: Add Fixes: and Reviewed-by: tags
arch/riscv/kernel/sys_hwprobe.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index 1659d31fd288..caf6762427c8 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -450,6 +450,7 @@ static int hwprobe_get_cpus(struct riscv_hwprobe __user *pairs,
if (cpusetsize > cpumask_size())
cpusetsize = cpumask_size();
+ cpumask_clear(&cpus);
ret = copy_from_user(&cpus, cpus_user, cpusetsize);
if (ret)
return -EFAULT;
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] riscv: hwprobe: Avoid uninitialized read in hwprobe_get_cpus()
@ 2026-07-14 0:30 ` Mark Harris
0 siblings, 0 replies; 4+ messages in thread
From: Mark Harris @ 2026-07-14 0:30 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou
Cc: Alexandre Ghiti, Mark Harris, Nam Cao, Michael Ellerman,
linux-riscv, linux-kernel
When cpusetsize < cpumask_size(), hwprobe_get_cpus() did not fully
initialize its copy of the cpu mask, which could cause non-deterministic
results from the riscv_hwprobe syscall on a system with more than 8 CPUs
when the supplied cpu mask is empty. Address this by fully initializing
the cpu mask.
Fixes: e178bf146e4b ("RISC-V: hwprobe: Introduce which-cpus flag")
Signed-off-by: Mark Harris <mark.hsj@gmail.com>
Reviewed-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Michael Ellerman <mpe@kernel.org>
---
v2: Add Fixes: and Reviewed-by: tags
arch/riscv/kernel/sys_hwprobe.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index 1659d31fd288..caf6762427c8 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -450,6 +450,7 @@ static int hwprobe_get_cpus(struct riscv_hwprobe __user *pairs,
if (cpusetsize > cpumask_size())
cpusetsize = cpumask_size();
+ cpumask_clear(&cpus);
ret = copy_from_user(&cpus, cpus_user, cpusetsize);
if (ret)
return -EFAULT;
--
2.55.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] riscv: hwprobe: Avoid uninitialized read in hwprobe_get_cpus()
2026-07-14 0:30 ` Mark Harris
@ 2026-07-15 17:14 ` Paul Walmsley
-1 siblings, 0 replies; 4+ messages in thread
From: Paul Walmsley @ 2026-07-15 17:14 UTC (permalink / raw)
To: Mark Harris
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nam Cao, Michael Ellerman, linux-riscv, linux-kernel
On Mon, 13 Jul 2026, Mark Harris wrote:
> When cpusetsize < cpumask_size(), hwprobe_get_cpus() did not fully
> initialize its copy of the cpu mask, which could cause non-deterministic
> results from the riscv_hwprobe syscall on a system with more than 8 CPUs
> when the supplied cpu mask is empty. Address this by fully initializing
> the cpu mask.
>
> Fixes: e178bf146e4b ("RISC-V: hwprobe: Introduce which-cpus flag")
> Signed-off-by: Mark Harris <mark.hsj@gmail.com>
> Reviewed-by: Nam Cao <namcao@linutronix.de>
> Reviewed-by: Michael Ellerman <mpe@kernel.org>
Thanks, queued for v7.2-rc.
- Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] riscv: hwprobe: Avoid uninitialized read in hwprobe_get_cpus()
@ 2026-07-15 17:14 ` Paul Walmsley
0 siblings, 0 replies; 4+ messages in thread
From: Paul Walmsley @ 2026-07-15 17:14 UTC (permalink / raw)
To: Mark Harris
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nam Cao, Michael Ellerman, linux-riscv, linux-kernel
On Mon, 13 Jul 2026, Mark Harris wrote:
> When cpusetsize < cpumask_size(), hwprobe_get_cpus() did not fully
> initialize its copy of the cpu mask, which could cause non-deterministic
> results from the riscv_hwprobe syscall on a system with more than 8 CPUs
> when the supplied cpu mask is empty. Address this by fully initializing
> the cpu mask.
>
> Fixes: e178bf146e4b ("RISC-V: hwprobe: Introduce which-cpus flag")
> Signed-off-by: Mark Harris <mark.hsj@gmail.com>
> Reviewed-by: Nam Cao <namcao@linutronix.de>
> Reviewed-by: Michael Ellerman <mpe@kernel.org>
Thanks, queued for v7.2-rc.
- Paul
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-15 17:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14 0:30 [PATCH v2] riscv: hwprobe: Avoid uninitialized read in hwprobe_get_cpus() Mark Harris
2026-07-14 0:30 ` Mark Harris
2026-07-15 17:14 ` Paul Walmsley
2026-07-15 17:14 ` Paul Walmsley
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.