diff options
author | AKASHI Takahiro <takahiro.akashi@linaro.org> | 2014-11-28 00:26:35 -0500 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2014-11-28 05:24:13 -0500 |
commit | 1014c81d9a5546b64352c04cdb93494aceb317fc (patch) | |
tree | e587ed27bb5651cbf6571fd804f479b0618c063c | |
parent | 766a85d7bc5d7f1ddd6de28bdb844eae45ec63b0 (diff) |
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>
-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 99c8d13fc00d..fd4fa374e5d2 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S | |||
@@ -669,8 +669,15 @@ ENDPROC(el0_svc) | |||
669 | * switches, and waiting for our parent to respond. | 669 | * switches, and waiting for our parent to respond. |
670 | */ | 670 | */ |
671 | __sys_trace: | 671 | __sys_trace: |
672 | mov x0, sp | 672 | mov w0, #-1 // set default errno for |
673 | cmp scno, x0 // user-issued syscall(-1) | ||
674 | b.ne 1f | ||
675 | mov x0, #-ENOSYS | ||
676 | str x0, [sp, #S_X0] | ||
677 | 1: mov x0, sp | ||
673 | bl syscall_trace_enter | 678 | bl syscall_trace_enter |
679 | cmp w0, #-1 // skip the syscall? | ||
680 | b.eq __sys_trace_return_skipped | ||
674 | uxtw scno, w0 // syscall number (possibly new) | 681 | uxtw scno, w0 // syscall number (possibly new) |
675 | mov x1, sp // pointer to regs | 682 | mov x1, sp // pointer to regs |
676 | cmp scno, sc_nr // check upper syscall limit | 683 | cmp scno, sc_nr // check upper syscall limit |
@@ -683,7 +690,8 @@ __sys_trace: | |||
683 | blr x16 // call sys_* routine | 690 | blr x16 // call sys_* routine |
684 | 691 | ||
685 | __sys_trace_return: | 692 | __sys_trace_return: |
686 | str x0, [sp] // save returned x0 | 693 | str x0, [sp, #S_X0] // save returned x0 |
694 | __sys_trace_return_skipped: | ||
687 | mov x0, sp | 695 | mov x0, sp |
688 | bl syscall_trace_exit | 696 | bl syscall_trace_exit |
689 | b ret_to_user | 697 | b ret_to_user |