m68k: Check syscall_trace_enter() return code
authorMichael Schmitz <schmitzmic@gmail.com>
Thu, 12 Jan 2023 03:55:27 +0000 (16:55 +1300)
committerGeert Uytterhoeven <geert@linux-m68k.org>
Mon, 30 Jan 2023 15:40:15 +0000 (16:40 +0100)
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>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/r/20230112035529.13521-2-schmitzmic@gmail.com
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
arch/m68k/68000/entry.S
arch/m68k/coldfire/entry.S
arch/m68k/kernel/entry.S

index 997b549330156dc87bf48de2a2c2435b4fdc62d2..7d63e2f1555a03dc3193adc8f3f8439f00fc0cb1 100644 (file)
@@ -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
index 9f337c70243a39f75828675170028f2ed2c18980..35104c5417ff4d07bb543ffaef2b2ce9a78d6682 100644 (file)
@@ -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 */
index 18f278bdbd218ed36983feb0b46d2d56899fa839..42879e6eb651dc733c16c368ddcdf99e92a8f0fe 100644 (file)
@@ -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