diff options
author | Dave Martin <Dave.Martin@arm.com> | 2018-06-07 07:32:05 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2018-06-08 08:21:39 -0400 |
commit | 0fe42512b2f03f9e5a20b9f55ef1013a68b4cd48 (patch) | |
tree | 3afaea68ef0f23eae6cf6dd57eaf1a83d09350d5 | |
parent | e156ab71a974737c279530e3b868131291fe677e (diff) |
arm64: Fix syscall restarting around signal suppressed by tracer
Commit 17c2895 ("arm64: Abstract syscallno manipulation") abstracts
out the pt_regs.syscallno value for a syscall cancelled by a tracer
as NO_SYSCALL, and provides helpers to set and check for this
condition. However, the way this was implemented has the
unintended side-effect of disabling part of the syscall restart
logic.
This comes about because the second in_syscall() check in
do_signal() re-evaluates the "in a syscall" condition based on the
updated pt_regs instead of the original pt_regs. forget_syscall()
is explicitly called prior to the second check in order to prevent
restart logic in the ret_to_user path being spuriously triggered,
which means that the second in_syscall() check always yields false.
This triggers a failure in
tools/testing/selftests/seccomp/seccomp_bpf.c, when using ptrace to
suppress a signal that interrups a nanosleep() syscall.
Misbehaviour of this type is only expected in the case where a
tracer suppresses a signal and the target process is either being
single-stepped or the interrupted syscall attempts to restart via
-ERESTARTBLOCK.
This patch restores the old behaviour by performing the
in_syscall() check only once at the start of the function.
Fixes: 17c289586009 ("arm64: Abstract syscallno manipulation")
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Reported-by: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: <stable@vger.kernel.org> # 4.14.x-
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r-- | arch/arm64/kernel/signal.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index e7da5dba7ba8..511af13e8d8f 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c | |||
@@ -843,11 +843,12 @@ static void do_signal(struct pt_regs *regs) | |||
843 | unsigned long continue_addr = 0, restart_addr = 0; | 843 | unsigned long continue_addr = 0, restart_addr = 0; |
844 | int retval = 0; | 844 | int retval = 0; |
845 | struct ksignal ksig; | 845 | struct ksignal ksig; |
846 | bool syscall = in_syscall(regs); | ||
846 | 847 | ||
847 | /* | 848 | /* |
848 | * If we were from a system call, check for system call restarting... | 849 | * If we were from a system call, check for system call restarting... |
849 | */ | 850 | */ |
850 | if (in_syscall(regs)) { | 851 | if (syscall) { |
851 | continue_addr = regs->pc; | 852 | continue_addr = regs->pc; |
852 | restart_addr = continue_addr - (compat_thumb_mode(regs) ? 2 : 4); | 853 | restart_addr = continue_addr - (compat_thumb_mode(regs) ? 2 : 4); |
853 | retval = regs->regs[0]; | 854 | retval = regs->regs[0]; |
@@ -899,7 +900,7 @@ static void do_signal(struct pt_regs *regs) | |||
899 | * Handle restarting a different system call. As above, if a debugger | 900 | * Handle restarting a different system call. As above, if a debugger |
900 | * has chosen to restart at a different PC, ignore the restart. | 901 | * has chosen to restart at a different PC, ignore the restart. |
901 | */ | 902 | */ |
902 | if (in_syscall(regs) && regs->pc == restart_addr) { | 903 | if (syscall && regs->pc == restart_addr) { |
903 | if (retval == -ERESTART_RESTARTBLOCK) | 904 | if (retval == -ERESTART_RESTARTBLOCK) |
904 | setup_restart_syscall(regs); | 905 | setup_restart_syscall(regs); |
905 | user_rewind_single_step(current); | 906 | user_rewind_single_step(current); |