Skip to content

Commit 3d729de

Browse files
James Hoganralfbaechle
authored andcommitted
MIPS: seccomp: Fix indirect syscall args
Since commit 669c409 ("MIPS: Give __secure_computing() access to syscall arguments."), upon syscall entry when seccomp is enabled, syscall_trace_enter() passes a carefully prepared struct seccomp_data containing syscall arguments to __secure_computing(). Unfortunately it directly uses mips_get_syscall_arg() and fails to take into account the indirect O32 system calls (i.e. syscall(2)) which put the system call number in a0 and have the arguments shifted up by one entry. We can't just revert that commit as samples/bpf/tracex5 would break again, so use syscall_get_arguments() which already takes indirect syscalls into account instead of directly using mips_get_syscall_arg(), similar to what populate_seccomp_data() does. This also removes the redundant error checking of the mips_get_syscall_arg() return value (get_user() already zeroes the result if an argument from the stack can't be loaded). Reported-by: James Cowgill <James.Cowgill@imgtec.com> Fixes: 669c409 ("MIPS: Give __secure_computing() access to syscall arguments.") Signed-off-by: James Hogan <james.hogan@imgtec.com> Reviewed-by: Kees Cook <keescook@chromium.org> Cc: David Daney <david.daney@cavium.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Will Drewry <wad@chromium.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/16994/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent cc4a41f commit 3d729de

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

arch/mips/kernel/ptrace.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -872,15 +872,13 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
872872
if (unlikely(test_thread_flag(TIF_SECCOMP))) {
873873
int ret, i;
874874
struct seccomp_data sd;
875+
unsigned long args[6];
875876

876877
sd.nr = syscall;
877878
sd.arch = syscall_get_arch();
878-
for (i = 0; i < 6; i++) {
879-
unsigned long v, r;
880-
881-
r = mips_get_syscall_arg(&v, current, regs, i);
882-
sd.args[i] = r ? 0 : v;
883-
}
879+
syscall_get_arguments(current, regs, 0, 6, args);
880+
for (i = 0; i < 6; i++)
881+
sd.args[i] = args[i];
884882
sd.instruction_pointer = KSTK_EIP(current);
885883

886884
ret = __secure_computing(&sd);

0 commit comments

Comments
 (0)