public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux•org>
To: linux-kernel@vger•kernel.org
Cc: Elvira Khabirova <lineprinter@altlinux•org>,
	linuxppc-dev@lists•ozlabs.org, Oleg Nesterov <oleg@redhat•com>,
	Eugene Syromyatnikov <esyr@redhat•com>
Subject: [PATCH v6 25/27] powerpc/ptrace: replace ptrace_report_syscall() with a tracehook call
Date: Thu, 13 Dec 2018 20:24:30 +0300	[thread overview]
Message-ID: <20181213172430.GY6024@altlinux.org> (raw)
In-Reply-To: 20181213171833.GA5240@altlinux.org

From: Elvira Khabirova <lineprinter@altlinux•org>

Arch code should use tracehook_*() helpers, as documented in
include/linux/tracehook.h, ptrace_report_syscall() is not expected to
be used outside that file.

The patch does not look very nice, but at least it is correct
and opens the way for PTRACE_GET_SYSCALL_INFO API.

Co-authored-by: Dmitry V. Levin <ldv@altlinux•org>
Fixes: 5521eb4bca2d ("powerpc/ptrace: Add support for PTRACE_SYSEMU")
Signed-off-by: Elvira Khabirova <lineprinter@altlinux•org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux•org>
[mpe: Take this as a minimal fix for 4.20, we'll rework it later]
Signed-off-by: Michael Ellerman <mpe@ellerman•id.au>
---

Notes:
    v6: this is the fix that was taken into powerpc tree
    v5: reverted to a simple approach, compile- and run-tested
    v4: rewritten to call tracehook_report_syscall_entry() once, compile-tested
    v3: add a descriptive comment
    v2: explicitly ignore tracehook_report_syscall_entry() return code

 arch/powerpc/kernel/ptrace.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index afb819f4ca68..714c3480c52d 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -3266,12 +3266,17 @@ long do_syscall_trace_enter(struct pt_regs *regs)
 	user_exit();
 
 	if (test_thread_flag(TIF_SYSCALL_EMU)) {
-		ptrace_report_syscall(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 register also, thus, not 'gotoing'
 		 * skip label.
 		 */
+		if (tracehook_report_syscall_entry(regs))
+			;
 		return -1;
 	}
 
-- 
ldv

  parent reply	other threads:[~2018-12-13 17:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 17:18 [PATCH v6 00/27] ptrace: add PTRACE_GET_SYSCALL_INFO request Dmitry V. Levin
2018-12-13 17:23 ` [PATCH v6 18/27] powerpc: define syscall_get_error() Dmitry V. Levin
2018-12-18 12:36   ` powerpc syscall_set_return_value() is confused (was Re: [PATCH v6 18/27] powerpc: define syscall_get_error()) Michael Ellerman
2018-12-13 17:24 ` [PATCH v6 24/27] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
2018-12-13 17:24 ` Dmitry V. Levin [this message]
2018-12-14 20:15 ` [PATCH v6 00/27] ptrace: add PTRACE_GET_SYSCALL_INFO request Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181213172430.GY6024@altlinux.org \
    --to=ldv@altlinux$(echo .)org \
    --cc=esyr@redhat$(echo .)com \
    --cc=lineprinter@altlinux$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=oleg@redhat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox