arm64: ptrace: allow tracer to skip a system call
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Thu, 4 Sep 2014 14:20:53 +0000 (15:20 +0100)
committerJP Abgrall <jpa@google.com>
Tue, 7 Oct 2014 22:26:23 +0000 (15:26 -0700)
commitfeb28436457d33fef9f264635291432df4b74122
tree6d37233382f88f18ac31b0dee9fcfc0dac66dfc2
parentabbfed9ed1a78701ef3db74f5287958feb897035
arm64: ptrace: allow tracer to skip a system call

Note: This patch is from v6 of Takahiro's proposed
"arm64: add seccomp support" patchset (leecam@google.com)

If tracer specifies -1 as a syscall number, this traced system call should
be skipped with a value in x0 used as a return value.
This patch enables this semantics, but there is a restriction here:

   when syscall(-1) is issued by user, tracer cannot skip this system call
   and modify a return value at syscall entry.

In order to ease this flavor, we need to treat whatever value in x0 as
a return value, but this might result in a bogus value being returned,
especially when tracer doesn't do anything at this syscall.
So we always return ENOSYS instead, while we have another chance to change
a return value at syscall exit.

Please also note:
* syscall entry tracing and syscall exit tracing (ftrace tracepoint and
  audit) are always executed, if enabled, even when skipping a system call
  (that is, -1).
  In this way, we can avoid a potential bug where audit_syscall_entry()
  might be called without audit_syscall_exit() at the previous system call
  being called, that would cause OOPs in audit_syscall_entry().

* syscallno may also be set to -1 if a fatal signal (SIGKILL) is detected
  in tracehook_report_syscall_entry(), but since a value set to x0 (ENOSYS)
  is not used in this case, we may neglect the case.

Signed-off-by: AKASHI Takahiro <takahiro.akashi <at> linaro.org>
Conflicts:
arch/arm64/kernel/entry.S

Change-Id: Ifcdcdbcb7c8cf97e5b5f1086a1ea4107e1d4f9a8
arch/arm64/include/asm/ptrace.h
arch/arm64/kernel/entry.S
arch/arm64/kernel/ptrace.c