Skip to content

Commit ae08d55

Browse files
covanamAlexandre Ghiti
authored and
Alexandre Ghiti
committed
riscv: Fix kernel crash due to PR_SET_TAGGED_ADDR_CTRL
When userspace does PR_SET_TAGGED_ADDR_CTRL, but Supm extension is not available, the kernel crashes: Oops - illegal instruction [#1] [snip] epc : set_tagged_addr_ctrl+0x112/0x15a ra : set_tagged_addr_ctrl+0x74/0x15a epc : ffffffff80011ace ra : ffffffff80011a30 sp : ffffffc60039be10 [snip] status: 0000000200000120 badaddr: 0000000010a79073 cause: 0000000000000002 set_tagged_addr_ctrl+0x112/0x15a __riscv_sys_prctl+0x352/0x73c do_trap_ecall_u+0x17c/0x20c andle_exception+0x150/0x15c Fix it by checking if Supm is available. Fixes: 09d6775 ("riscv: Add support for userspace pointer masking") Signed-off-by: Nam Cao <[email protected]> Cc: [email protected] Reviewed-by: Samuel Holland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Ghiti <[email protected]>
1 parent 897e8ae commit ae08d55

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/riscv/kernel/process.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg)
275275
unsigned long pmm;
276276
u8 pmlen;
277277

278+
if (!riscv_has_extension_unlikely(RISCV_ISA_EXT_SUPM))
279+
return -EINVAL;
280+
278281
if (is_compat_thread(ti))
279282
return -EINVAL;
280283

0 commit comments

Comments
 (0)