linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Schmitz <schmitzmic@gmail.com>
To: linux-m68k@vger.kernel.org, geert@linux-m68k.org
Cc: glaubitz@physik.fu-berlin.de, Michael Schmitz <schmitzmic@gmail.com>
Subject: [PATCH v13 1/3] m68k/kernel - check syscall_trace_enter() return code on m68k
Date: Thu, 12 Jan 2023 16:55:27 +1300	[thread overview]
Message-ID: <20230112035529.13521-2-schmitzmic@gmail.com> (raw)
In-Reply-To: <20230112035529.13521-1-schmitzmic@gmail.com>

Check return code of syscall_trace_enter(), and skip syscall
if -1. Return code will be left at what had been set by
ptrace or seccomp (in regs->d0).

No regression seen in testing with strace on ARAnyM.

Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>

--
Changes from v12:

- prevent overwriting the syscall return value after change
  by ptrace or seccomp on 68020+

Changes from v7:

Al Viro:
- split return code checks from switch to syscall_trace_enter()

Changes from v6:

Geert Uytterhoeven:
- add syscall_trace_enter() return code check for 68000
  and coldfire

Changes from v5:

- add comment to explain optimization

Changes from v4:

Andreas Schwab:
- optimize return code test (addql #1,%d0 for cmpil #-1,%d0)
- spelling fix in commit message

Changes from v3:

- change syscall_trace_enter return code test from !=0 to ==-1
---
 arch/m68k/68000/entry.S    | 2 ++
 arch/m68k/coldfire/entry.S | 2 ++
 arch/m68k/kernel/entry.S   | 3 +++
 3 files changed, 7 insertions(+)

diff --git a/arch/m68k/68000/entry.S b/arch/m68k/68000/entry.S
index 997b54933015..7d63e2f1555a 100644
--- a/arch/m68k/68000/entry.S
+++ b/arch/m68k/68000/entry.S
@@ -45,6 +45,8 @@ do_trace:
 	jbsr	syscall_trace_enter
 	RESTORE_SWITCH_STACK
 	addql	#4,%sp
+	addql	#1,%d0
+	jeq	ret_from_exception
 	movel	%sp@(PT_OFF_ORIG_D0),%d1
 	movel	#-ENOSYS,%d0
 	cmpl	#NR_syscalls,%d1
diff --git a/arch/m68k/coldfire/entry.S b/arch/m68k/coldfire/entry.S
index 9f337c70243a..35104c5417ff 100644
--- a/arch/m68k/coldfire/entry.S
+++ b/arch/m68k/coldfire/entry.S
@@ -90,6 +90,8 @@ ENTRY(system_call)
 	jbsr	syscall_trace_enter
 	RESTORE_SWITCH_STACK
 	addql	#4,%sp
+	addql	#1,%d0
+	jeq	ret_from_exception
 	movel	%d3,%a0
 	jbsr	%a0@
 	movel	%d0,%sp@(PT_OFF_D0)		/* save the return value */
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index 18f278bdbd21..42879e6eb651 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -184,9 +184,12 @@ do_trace_entry:
 	jbsr	syscall_trace_enter
 	RESTORE_SWITCH_STACK
 	addql	#4,%sp
+	addql	#1,%d0			| optimization for cmpil #-1,%d0
+	jeq	ret_from_syscall
 	movel	%sp@(PT_OFF_ORIG_D0),%d0
 	cmpl	#NR_syscalls,%d0
 	jcs	syscall
+	jra	ret_from_syscall
 badsys:
 	movel	#-ENOSYS,%sp@(PT_OFF_D0)
 	jra	ret_from_syscall
-- 
2.17.1


  reply	other threads:[~2023-01-12  3:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12  3:55 [PATCH v13 0/3] Add kernel seccomp support for m68k Michael Schmitz
2023-01-12  3:55 ` Michael Schmitz [this message]
2023-01-22 16:35   ` [PATCH v13 1/3] m68k/kernel - check syscall_trace_enter() return code on m68k Geert Uytterhoeven
2023-01-22 16:35     ` Geert Uytterhoeven
2023-01-12  3:55 ` [PATCH v13 2/3] m68k: add kernel seccomp support Michael Schmitz
2023-01-22 16:37   ` Geert Uytterhoeven
2023-01-22 16:40     ` John Paul Adrian Glaubitz
2023-01-22 18:11     ` Michael Schmitz
2023-01-22 18:49       ` Geert Uytterhoeven
2023-01-12  3:55 ` [PATCH v13 3/3] tools/testing - seccomp test fixes for m68k Michael Schmitz
2023-01-22 16:40   ` Geert Uytterhoeven
2023-01-12  6:42 ` [PATCH v13 0/3] Add kernel seccomp support " Michael Schmitz
2023-01-13 17:29 ` John Paul Adrian Glaubitz
2023-01-14  0:00   ` Michael Schmitz
2023-01-16  9:12     ` John Paul Adrian Glaubitz
2023-01-17  2:15       ` Michael Schmitz
2023-01-17  8:08         ` John Paul Adrian Glaubitz
2023-01-17 23:25           ` Michael Schmitz
2023-01-18  8:30             ` John Paul Adrian Glaubitz
2023-01-18  9:43               ` John Paul Adrian Glaubitz
2023-01-18 22:21                 ` Michael Schmitz
2023-01-19  9:18                   ` John Paul Adrian Glaubitz
2023-01-20 10:45                     ` John Paul Adrian Glaubitz
2023-02-27 20:45 ` Kees Cook
2023-03-07  2:57   ` Michael Schmitz

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=20230112035529.13521-2-schmitzmic@gmail.com \
    --to=schmitzmic@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-m68k@vger.kernel.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).