We can safely reenable IRQs if coming from userspace. This allows to
access user memory that could potentially trigger a page fault.
Fixes: b686ecdeacf6 ("riscv: misaligned: Restrict user access to kernel memory")
Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20250422162324.956065-3-cleger@rivosinc.com
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
{
irqentry_state_t state;
- if (user_mode(regs))
+ if (user_mode(regs)) {
irqentry_enter_from_user_mode(regs);
- else
+ local_irq_enable();
+ } else {
state = irqentry_nmi_enter(regs);
+ }
if (misaligned_handler[type].handler(regs))
do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc,
misaligned_handler[type].type_str);
- if (user_mode(regs))
+ if (user_mode(regs)) {
+ local_irq_disable();
irqentry_exit_to_user_mode(regs);
- else
+ } else {
irqentry_nmi_exit(regs, state);
+ }
}
asmlinkage __visible __trap_section void do_trap_load_misaligned(struct pt_regs *regs)