[PATCH] RISC-V: hwprobe: Check for the reserved flags

Palmer Dabbelt palmer at rivosinc.com
Wed Jan 3 04:12:20 PST 2024


This check got dropped when RISCV_HWPROBE_WHICH_CPUS was added, but
we've still got a bunch of other reserved flags.  So check for them,
just to make sure userspace doesn't get confused later.

Fixes: e178bf146e4b ("RISC-V: hwprobe: Introduce which-cpus flag")
Signed-off-by: Palmer Dabbelt <palmer at rivosinc.com>
---
 arch/riscv/kernel/sys_hwprobe.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index ccf61b040536..10d72893b04f 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -347,6 +347,10 @@ static int do_riscv_hwprobe(struct riscv_hwprobe __user *pairs,
 			    unsigned long __user *cpus_user,
 			    unsigned int flags)
 {
+	/* The rest of the flags are still reserved. */
+	if (flags & ~RISCV_HWPROBE_WICHH_CPUS)
+		return -EINVAL;
+
 	if (flags & RISCV_HWPROBE_WHICH_CPUS)
 		return hwprobe_get_cpus(pairs, pair_count, cpusetsize,
 					cpus_user, flags);
-- 
2.43.0




More information about the linux-riscv mailing list