Skip to content

Commit 762df35

Browse files
Al Viropalmer-dabbelt
authored andcommitted
riscv: fix a nasty sigreturn bug...
riscv has an equivalent of arm bug fixed by 653d48b ("arm: fix really nasty sigreturn bug"); if signal gets caught by an interrupt that hits when we have the right value in a0 (-513), *and* another signal gets delivered upon sigreturn() (e.g. included into the blocked mask for the first signal and posted while the handler had been running), the syscall restart logics will see regs->cause equal to EXC_SYSCALL (we are in a syscall, after all) and a0 already restored to its original value (-513, which happens to be -ERESTARTNOINTR) and assume that we need to apply the usual syscall restart logics. Signed-off-by: Al Viro <[email protected]> Fixes: e2c0cdf ("RISC-V: User-facing API") Cc: [email protected] Link: https://lore.kernel.org/r/YxJEiSq%2FCGaL6Gm9@ZenIV/ Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 2a2018c commit 762df35

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/riscv/kernel/signal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ SYSCALL_DEFINE0(rt_sigreturn)
124124
if (restore_altstack(&frame->uc.uc_stack))
125125
goto badframe;
126126

127+
regs->cause = -1UL;
128+
127129
return regs->a0;
128130

129131
badframe:

0 commit comments

Comments
 (0)