From: Michael Schmitz <schmitzmic@gmail.com>
To: glaubitz@physik.fu-berlin.de, geert@linux-m68k.org
Cc: linux-m68k@vger.kernel.org, schwab@linux-m68k.org,
Michael Schmitz <schmitzmic@gmail.com>
Subject: [PATCH RFC v2] m68k/kernel - wire up syscall_trace_enter/leave for m68k
Date: Sun, 26 Jul 2020 13:28:50 +1200 [thread overview]
Message-ID: <1595726930-8969-1-git-send-email-schmitzmic@gmail.com> (raw)
In-Reply-To: <f0c9edc0-e596-c483-b9a6-f67778bd297c@physik.fu-berlin.de>
m68k (other than Coldfire) uses syscall_trace for both trace entry
and trace exit. Seccomp support requires separate entry points for
trace entry and exit which are already provided for Coldfire.
Replace syscall_trace by syscall_trace_enter and syscall_trace_leave
in preparation for seccomp support. Check return code of
syscall_trace_enter(), and skip syscall if nonzero. Return code
will be set to -EPERM in that case.
No regression seen in testing with strace on ARAnyM.
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
Changes from v1:
- add return code check in do_trace_entry branch to enable syscall
filtering (will return -EPERM)
- change to use testl for return code check (suggested by Andreas Schwab)
---
arch/m68k/kernel/entry.S | 11 ++++++++---
arch/m68k/kernel/ptrace.c | 17 -----------------
2 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index 9dd76fb..fbd2222 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -164,20 +164,25 @@ do_trace_entry:
movel #-ENOSYS,%sp@(PT_OFF_D0)| needed for strace
subql #4,%sp
SAVE_SWITCH_STACK
- jbsr syscall_trace
+ jbsr syscall_trace_enter
RESTORE_SWITCH_STACK
addql #4,%sp
+ tstl %d0
+ jne denied
movel %sp@(PT_OFF_ORIG_D0),%d0
cmpl #NR_syscalls,%d0
jcs syscall
badsys:
movel #-ENOSYS,%sp@(PT_OFF_D0)
jra ret_from_syscall
+denied:
+ movel #-EPERM,%sp@(PT_OFF_D0)
+ jra ret_from_syscall
do_trace_exit:
subql #4,%sp
SAVE_SWITCH_STACK
- jbsr syscall_trace
+ jbsr syscall_trace_leave
RESTORE_SWITCH_STACK
addql #4,%sp
jra .Lret_from_exception
@@ -186,7 +191,7 @@ ENTRY(ret_from_signal)
movel %curptr@(TASK_STACK),%a1
tstb %a1@(TINFO_FLAGS+2)
jge 1f
- jbsr syscall_trace
+ jbsr syscall_trace_leave
1: RESTORE_SWITCH_STACK
addql #4,%sp
/* on 68040 complete pending writebacks if any */
diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c
index 748c63b..b747a86 100644
--- a/arch/m68k/kernel/ptrace.c
+++ b/arch/m68k/kernel/ptrace.c
@@ -272,22 +272,6 @@ long arch_ptrace(struct task_struct *child, long request,
return -EIO;
}
-asmlinkage void syscall_trace(void)
-{
- ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
- ? 0x80 : 0));
- /*
- * this isn't the same as continuing with a signal, but it will do
- * for normal use. strace only continues with a signal if the
- * stopping signal is not SIGTRAP. -brl
- */
- if (current->exit_code) {
- send_sig(current->exit_code, current, 1);
- current->exit_code = 0;
- }
-}
-
-#if defined(CONFIG_COLDFIRE) || !defined(CONFIG_MMU)
asmlinkage int syscall_trace_enter(void)
{
int ret = 0;
@@ -302,4 +286,3 @@ asmlinkage void syscall_trace_leave(void)
if (test_thread_flag(TIF_SYSCALL_TRACE))
tracehook_report_syscall_exit(task_pt_regs(current), 0);
}
-#endif /* CONFIG_COLDFIRE */
--
1.7.0.4
next prev parent reply other threads:[~2020-07-26 1:28 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-23 10:03 syscall_trace_enter and syscall_trace_leave for m68k w/MMU John Paul Adrian Glaubitz
2020-07-23 22:56 ` Michael Schmitz
2020-07-25 1:48 ` [PATCH RFC] m68k/kernel - wire up syscall_trace_enter/leave for m68k Michael Schmitz
2020-07-26 1:28 ` Michael Schmitz [this message]
2020-07-27 4:19 ` [PATCH] " Michael Schmitz
2020-07-27 10:03 ` John Paul Adrian Glaubitz
2020-07-27 20:48 ` Michael Schmitz
2020-07-27 21:09 ` John Paul Adrian Glaubitz
2020-08-26 11:18 ` Geert Uytterhoeven
2020-08-26 11:50 ` John Paul Adrian Glaubitz
2020-08-26 11:23 ` Geert Uytterhoeven
2020-08-26 11:27 ` John Paul Adrian Glaubitz
2020-08-26 12:32 ` Geert Uytterhoeven
2020-08-26 12:35 ` John Paul Adrian Glaubitz
2020-08-26 12:38 ` Geert Uytterhoeven
2020-08-26 12:42 ` John Paul Adrian Glaubitz
2020-08-26 14:22 ` Geert Uytterhoeven
2020-08-27 0:08 ` Michael Schmitz
2020-08-27 9:19 ` Geert Uytterhoeven
2020-08-27 19:29 ` Michael Schmitz
2020-08-28 8:58 ` Geert Uytterhoeven
2021-06-14 22:11 ` Michael Schmitz
2021-06-14 23:04 ` John Paul Adrian Glaubitz
2021-06-14 23:14 ` Michael Schmitz
2021-06-15 7:51 ` Geert Uytterhoeven
2021-06-15 20:32 ` Michael Schmitz
2021-06-16 0:27 ` Michael Schmitz
2020-08-05 12:23 ` syscall_trace_enter and syscall_trace_leave for m68k w/MMU Greg Ungerer
2020-08-05 12:36 ` John Paul Adrian Glaubitz
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=1595726930-8969-1-git-send-email-schmitzmic@gmail.com \
--to=schmitzmic@gmail.com \
--cc=geert@linux-m68k.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-m68k@vger.kernel.org \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).