[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190318104925.16600-5-sudeep.holla@arm.com>
Date: Mon, 18 Mar 2019 10:49:23 +0000
From: Sudeep Holla <sudeep.holla@....com>
To: x86@...nel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Cc: Sudeep Holla <sudeep.holla@....com>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>,
Oleg Nesterov <oleg@...hat.com>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Richard Weinberger <richard@....at>, jdike@...toit.com,
Steve Capper <Steve.Capper@....com>,
Haibo Xu <haibo.xu@....com>, Bin Lu <bin.lu@....com>,
Andy Lutomirski <luto@...nel.org>
Subject: [PATCH v2 4/6] powerpc: use common ptrace_syscall_enter hook to handle _TIF_SYSCALL_EMU
Now that we have a new hook ptrace_syscall_enter that can be called from
syscall entry code and it handles PTRACE_SYSEMU in generic code, we
can do some cleanup using the same in do_syscall_trace_enter.
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Michael Ellerman <mpe@...erman.id.au>
Signed-off-by: Sudeep Holla <sudeep.holla@....com>
---
arch/powerpc/kernel/ptrace.c | 48 ++++++++++++++++--------------------
1 file changed, 21 insertions(+), 27 deletions(-)
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 2e2183b800a8..05579a5dcb12 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -3278,35 +3278,29 @@ long do_syscall_trace_enter(struct pt_regs *regs)
user_exit();
- flags = READ_ONCE(current_thread_info()->flags) &
- (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE);
-
- if (flags) {
- int rc = tracehook_report_syscall_entry(regs);
+ if (unlikely(ptrace_syscall_enter(regs))) {
+ /*
+ * A nonzero return code from tracehook_report_syscall_entry()
+ * tells us to prevent the syscall execution, but we are not
+ * going to execute it anyway.
+ *
+ * Returning -1 will skip the syscall execution. We want to
+ * avoid clobbering any registers, so we don't goto the skip
+ * label below.
+ */
+ return -1;
+ }
- if (unlikely(flags & _TIF_SYSCALL_EMU)) {
- /*
- * A nonzero return code from
- * tracehook_report_syscall_entry() tells us to prevent
- * the syscall execution, but we are not going to
- * execute it anyway.
- *
- * Returning -1 will skip the syscall execution. We want
- * to avoid clobbering any registers, so we don't goto
- * the skip label below.
- */
- return -1;
- }
+ flags = READ_ONCE(current_thread_info()->flags) & _TIF_SYSCALL_TRACE;
- if (rc) {
- /*
- * The tracer decided to abort the syscall. Note that
- * the tracer may also just change regs->gpr[0] to an
- * invalid syscall number, that is handled below on the
- * exit path.
- */
- goto skip;
- }
+ if (flags && tracehook_report_syscall_entry(regs)) {
+ /*
+ * The tracer decided to abort the syscall. Note that
+ * the tracer may also just change regs->gpr[0] to an
+ * invalid syscall number, that is handled below on the
+ * exit path.
+ */
+ goto skip;
}
/* Run seccomp after ptrace; allow it to set gpr[3]. */
--
2.17.1
Powered by blists - more mailing lists