[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jLEvfOWGv+BNWCddMmtGumB_cpGOX6GCCm8Usz6=m=mPw@mail.gmail.com>
Date: Fri, 11 Aug 2017 15:18:04 -0700
From: Kees Cook <keescook@...omium.org>
To: James Hogan <james.hogan@...tec.com>
Cc: Linux MIPS Mailing List <linux-mips@...ux-mips.org>,
LKML <linux-kernel@...r.kernel.org>,
Ralf Baechle <ralf@...ux-mips.org>,
Lars Persson <lars.persson@...s.com>,
Oleg Nesterov <oleg@...hat.com>,
Andy Lutomirski <luto@...capital.net>,
Will Drewry <wad@...omium.org>
Subject: Re: [PATCH 2/4] MIPS/ptrace: Pick up ptrace/seccomp changed syscalls
On Fri, Aug 11, 2017 at 1:56 PM, James Hogan <james.hogan@...tec.com> wrote:
> The MIPS syscall_trace_enter() allows the system call number to be
> altered or cancelled by a ptrace tracer, via the normal ptrace hook
> (PTRACE_SYSCALL) and changing the system call number register on entry,
> and similarly via seccomp (PTRACE_EVENT_SECCOMP when a seccomp filter
> returns SECCOMP_RET_TRACE).
>
> Be sure to update the syscall local variable if this happens, so that
> seccomp will filter the correct system call number if the normal ptrace
> hook changes it first, and so that if either the normal ptrace hook or
> seccomp change it the correct system call number is passed to the trace
> event.
>
> This won't have any effect until the next commit, which fixes ptrace to
> update thread_info::syscall.
>
> Fixes: c2d9f1775731 ("MIPS: Fix syscall_get_nr for the syscall exit tracing.")
> Signed-off-by: James Hogan <james.hogan@...tec.com>
> Cc: Ralf Baechle <ralf@...ux-mips.org>
> Cc: Lars Persson <lars.persson@...s.com>
> Cc: Oleg Nesterov <oleg@...hat.com>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Andy Lutomirski <luto@...capital.net>
> Cc: Will Drewry <wad@...omium.org>
> Cc: linux-mips@...ux-mips.org
Reviewed-by: Kees Cook <keescook@...omium.org>
-Kees
> ---
> arch/mips/kernel/ptrace.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
> index 1395654cfc8d..be5d5fefcc7c 100644
> --- a/arch/mips/kernel/ptrace.c
> +++ b/arch/mips/kernel/ptrace.c
> @@ -864,9 +864,11 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
>
> current_thread_info()->syscall = syscall;
>
> - if (test_thread_flag(TIF_SYSCALL_TRACE) &&
> - tracehook_report_syscall_entry(regs))
> - return -1;
> + if (test_thread_flag(TIF_SYSCALL_TRACE)) {
> + if (tracehook_report_syscall_entry(regs))
> + return -1;
> + syscall = current_thread_info()->syscall;
> + }
>
> #ifdef CONFIG_SECCOMP
> if (unlikely(test_thread_flag(TIF_SECCOMP))) {
> @@ -884,6 +886,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
> ret = __secure_computing(&sd);
> if (ret == -1)
> return ret;
> + syscall = current_thread_info()->syscall;
> }
> #endif
>
> --
> 2.13.2
>
--
Kees Cook
Pixel Security
Powered by blists - more mailing lists