From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH AUTOSEL for 4.9 160/293] MIPS: Give __secure_computing() access to syscall arguments. Date: Mon, 9 Apr 2018 00:24:58 +0000 Message-ID: <20180409002239.163177-160-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: David Daney , Alexei Starovoitov , Daniel Borkmann , Matt Redfearn , "netdev@vger.kernel.org" , "linux-mips@linux-mips.org" , Ralf Baechle , Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" Return-path: Received: from mail-by2nam03on0135.outbound.protection.outlook.com ([104.47.42.135]:16544 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756209AbeDIAbO (ORCPT ); Sun, 8 Apr 2018 20:31:14 -0400 In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: From: David Daney [ Upstream commit 669c4092225f0ed5df12ebee654581b558a5e3ed ] 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 Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Matt Redfearn 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 Signed-off-by: Sasha Levin --- arch/mips/kernel/ptrace.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 0c8ae2cc6380..956dae7e6a69 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c @@ -1011,8 +1011,26 @@ asmlinkage long syscall_trace_enter(struct pt_regs *= regs, long syscall) tracehook_report_syscall_entry(regs)) return -1; =20 - if (secure_computing(NULL) =3D=3D -1) - return -1; +#ifdef CONFIG_SECCOMP + if (unlikely(test_thread_flag(TIF_SECCOMP))) { + int ret, i; + struct seccomp_data sd; + + sd.nr =3D syscall; + sd.arch =3D syscall_get_arch(); + for (i =3D 0; i < 6; i++) { + unsigned long v, r; + + r =3D mips_get_syscall_arg(&v, current, regs, i); + sd.args[i] =3D r ? 0 : v; + } + sd.instruction_pointer =3D KSTK_EIP(current); + + ret =3D __secure_computing(&sd); + if (ret =3D=3D -1) + return ret; + } +#endif =20 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) trace_sys_enter(regs, regs->regs[2]); --=20 2.15.1