riscv: fix seccomp reject syscall code path
[linux-2.6-microblaze.git] / arch / riscv / kernel / entry.S
index bad4d85..208702d 100644 (file)
@@ -228,20 +228,13 @@ check_syscall_nr:
        /* Check to make sure we don't jump to a bogus syscall number. */
        li t0, __NR_syscalls
        la s0, sys_ni_syscall
-       /*
-        * The tracer can change syscall number to valid/invalid value.
-        * We use syscall_set_nr helper in syscall_trace_enter thus we
-        * cannot trust the current value in a7 and have to reload from
-        * the current task pt_regs.
-        */
-       REG_L a7, PT_A7(sp)
        /*
         * Syscall number held in a7.
         * If syscall number is above allowed value, redirect to ni_syscall.
         */
        bge a7, t0, 1f
        /*
-        * Check if syscall is rejected by tracer or seccomp, i.e., a7 == -1.
+        * Check if syscall is rejected by tracer, i.e., a7 == -1.
         * If yes, we pretend it was executed.
         */
        li t1, -1
@@ -334,6 +327,7 @@ work_resched:
 handle_syscall_trace_enter:
        move a0, sp
        call do_syscall_trace_enter
+       move t0, a0
        REG_L a0, PT_A0(sp)
        REG_L a1, PT_A1(sp)
        REG_L a2, PT_A2(sp)
@@ -342,6 +336,7 @@ handle_syscall_trace_enter:
        REG_L a5, PT_A5(sp)
        REG_L a6, PT_A6(sp)
        REG_L a7, PT_A7(sp)
+       bnez t0, ret_from_syscall_rejected
        j check_syscall_nr
 handle_syscall_trace_exit:
        move a0, sp