MIPS: Give __secure_computing() access to syscall arguments.
authorDavid Daney <david.daney@cavium.com>
Tue, 13 Jun 2017 22:28:47 +0000 (15:28 -0700)
committerRalf Baechle <ralf@linux-mips.org>
Wed, 28 Jun 2017 10:22:39 +0000 (12:22 +0200)
KProbes of __seccomp_filter() are not very useful without access to
the syscall arguments.

Do what x86 does, and populate a struct seccomp_data to be passed to
__secure_computing().  This allows samples/bpf/tracex5 to extract a
sensible trace.

Signed-off-by: David Daney <david.daney@cavium.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/16368/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/ptrace.c

index 6931fe722a0b54dcfa5078c8686160018c1e6c64..ba3b1f771256f763ce6d03143a3c6cef052ac08c 100644 (file)
@@ -868,8 +868,26 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
            tracehook_report_syscall_entry(regs))
                return -1;
 
-       if (secure_computing(NULL) == -1)
-               return -1;
+#ifdef CONFIG_SECCOMP
+       if (unlikely(test_thread_flag(TIF_SECCOMP))) {
+               int ret, i;
+               struct seccomp_data sd;
+
+               sd.nr = syscall;
+               sd.arch = syscall_get_arch();
+               for (i = 0; i < 6; i++) {
+                       unsigned long v, r;
+
+                       r = mips_get_syscall_arg(&v, current, regs, i);
+                       sd.args[i] = r ? 0 : v;
+               }
+               sd.instruction_pointer = KSTK_EIP(current);
+
+               ret = __secure_computing(&sd);
+               if (ret == -1)
+                       return ret;
+       }
+#endif
 
        if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
                trace_sys_enter(regs, regs->regs[2]);