Skip to content

Commit 5caae1d

Browse files
mark4oPaul Walmsley
authored andcommitted
riscv: hwprobe: Avoid uninitialized read in hwprobe_get_cpus()
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: e178bf1 ("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> Link: https://patch.msgid.link/20260714003056.73707-1-mark.hsj@gmail.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent e4bf6eb commit 5caae1d

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

arch/riscv/kernel/sys_hwprobe.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ static int hwprobe_get_cpus(struct riscv_hwprobe __user *pairs,
450450
if (cpusetsize > cpumask_size())
451451
cpusetsize = cpumask_size();
452452

453+
cpumask_clear(&cpus);
453454
ret = copy_from_user(&cpus, cpus_user, cpusetsize);
454455
if (ret)
455456
return -EFAULT;

0 commit comments

Comments
 (0)