diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-01-18 15:12:19 +0530 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-15 23:15:50 +0530 |
commit | 55bb9480f9159b229ac3c3454c97b62d1e0a7e80 (patch) | |
tree | 4de8a97445bb41f250cdadba78169d0463bd244b /arch/arc/kernel/signal.c | |
parent | 5c39c0ab5e862cf71cda1fc39a5cedd4e2f18c6e (diff) | |
download | op-kernel-dev-55bb9480f9159b229ac3c3454c97b62d1e0a7e80.zip op-kernel-dev-55bb9480f9159b229ac3c3454c97b62d1e0a7e80.tar.gz |
ARC: [Review] Prevent incorrect syscall restarts
Per Al Viro's "signals for dummies" https://lkml.org/lkml/2012/12/6/366
there are 3 golden rules for (not) restarting syscalls:
" What we need to guarantee is
* restarts do not happen on signals caught in interrupts or exceptions
* restarts do not happen on signals caught in sigreturn()
* restart should happen only once, even if we get through do_signal()
many times."
ARC Port already handled #1, this patch fixes #2 and #3.
We use the additional state in pt_regs->orig_r8 to ckh if restarting
has already been done once.
Thanks to Al Viro for spotting this.
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Diffstat (limited to 'arch/arc/kernel/signal.c')
-rw-r--r-- | arch/arc/kernel/signal.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c index ab8ed5a..ee6ef2f 100644 --- a/arch/arc/kernel/signal.c +++ b/arch/arc/kernel/signal.c @@ -128,6 +128,9 @@ SYSCALL_DEFINE0(rt_sigreturn) if (restore_altstack(&sf->uc.uc_stack)) goto badframe; + /* Don't restart from sigreturn */ + syscall_wont_restart(regs); + return regs->r0; badframe: @@ -318,13 +321,13 @@ void do_signal(struct pt_regs *regs) signr = get_signal_to_deliver(&info, &ka, regs, NULL); - /* Are we from a system call? */ - restart_scall = in_syscall(regs); + restart_scall = in_syscall(regs) && syscall_restartable(regs); if (signr > 0) { - if (restart_scall) + if (restart_scall) { arc_restart_syscall(&ka, regs); - + syscall_wont_restart(regs); /* No more restarts */ + } handle_signal(signr, &ka, &info, regs); return; } @@ -339,6 +342,7 @@ void do_signal(struct pt_regs *regs) regs->r8 = __NR_restart_syscall; regs->ret -= 4; } + syscall_wont_restart(regs); /* No more restarts */ } /* If there's no signal to deliver, restore the saved sigmask back */ |