Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5ea505d authored by Kees Cook's avatar Kees Cook Committed by Greg Hackmann
Browse files

UPSTREAM: arm/ptrace: run seccomp after ptrace



Close the hole where ptrace can change a syscall out from under seccomp.

Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
(cherry picked from commit 0f3912fd934cdfd03d93f2dc6f064099795bf638)

Bug: 119769499
Change-Id: Id82e4137207db42a8af31b2745581c53eaaf1f89
Signed-off-by: default avatarGreg Hackmann <ghackmann@google.com>
parent 7f891268
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -932,18 +932,19 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
{
	current_thread_info()->syscall = scno;

	/* Do the secure computing check first; failures should be fast. */
	if (test_thread_flag(TIF_SYSCALL_TRACE))
		tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);

	/* Do seccomp after ptrace; syscall may have changed. */
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
	if (secure_computing(NULL) == -1)
		return -1;
#else
	/* XXX: remove this once OABI gets fixed */
	secure_computing_strict(scno);
	secure_computing_strict(current_thread_info()->syscall);
#endif

	if (test_thread_flag(TIF_SYSCALL_TRACE))
		tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);

	/* Tracer or seccomp may have changed syscall. */
	scno = current_thread_info()->syscall;

	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))