]> git.itanic.dy.fi Git - linux-stable/commitdiff
riscv: fix a nasty sigreturn bug...
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 24 Sep 2021 01:55:27 +0000 (01:55 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:10:27 +0000 (11:10 +0200)
commit 762df359aa5849e010ef04c3ed79d57588ce17d9 upstream.

riscv has an equivalent of arm bug fixed by 653d48b22166 ("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 <viro@zeniv.linux.org.uk>
Fixes: e2c0cdfba7f6 ("RISC-V: User-facing API")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/YxJEiSq%2FCGaL6Gm9@ZenIV/
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/riscv/kernel/signal.c

index bc6841867b5122eef4ac3c49e21338b840ed5367..529c123cf0a47689a47b595c4ea0f282266e7fff 100644 (file)
@@ -121,6 +121,8 @@ SYSCALL_DEFINE0(rt_sigreturn)
        if (restore_altstack(&frame->uc.uc_stack))
                goto badframe;
 
+       regs->cause = -1UL;
+
        return regs->a0;
 
 badframe: