diff options
author | AKASHI Takahiro <takahiro.akashi@linaro.org> | 2014-11-28 05:26:35 +0000 |
---|---|---|
committer | Kees Cook <keescook@google.com> | 2016-04-08 12:32:21 -0700 |
commit | ff43d9af5e7f0c7545b6b81a98171eb4c64479d8 (patch) | |
tree | edf58640041335464dceb3c4fe7add1f814efc0e | |
parent | 5e46412e971a9ceb0bb1471c8772a0da5ac91b1e (diff) | |
download | qcom-msm-v3.10-ff43d9af5e7f0c7545b6b81a98171eb4c64479d8.tar.gz |
BACKPORT: arm64: ptrace: allow tracer to skip a system call
If tracer modifies a syscall number to -1, this traced system call should
be skipped with a return value specified in x0.
This patch implements this semantics.
Please 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().
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
[will: fixed up conflict with blr rework]
Signed-off-by: Will Deacon <will.deacon@arm.com>
Bug: 28020023
Patchset: seccomp
(cherry picked from kernel/msm commit 6c552f2c72849c6f45904587d9643cfed57aee40)
Signed-off-by: Kees Cook <keescook@google.com>
Change-Id: If3ef7b7a1c08030702396842e814974486f71ea4
-rw-r--r-- | arch/arm64/kernel/entry.S | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 93e07f04ac1..1580951fb3c 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -641,9 +641,16 @@ ENDPROC(el0_svc) * switches, and waiting for our parent to respond. */ __sys_trace: - mov x0, sp + mov w0, #-1 // set default errno for + cmp scno, x0 // user-issued syscall(-1) + b.ne 1f + mov x0, #-ENOSYS + str x0, [sp, #S_X0] +1: mov x0, sp bl syscall_trace_enter adr lr, __sys_trace_return // return address + cmp w0, #-1 // skip the syscall? + b.eq __sys_trace_return_skipped uxtw scno, w0 // syscall number (possibly new) mov x1, sp // pointer to regs cmp scno, sc_nr // check upper syscall limit @@ -656,7 +663,8 @@ __sys_trace: br x16 // call sys_* routine __sys_trace_return: - str x0, [sp] // save returned x0 + str x0, [sp, #S_X0] // save returned x0 +__sys_trace_return_skipped: mov x0, sp bl syscall_trace_exit b ret_to_user |