All of lore.kernel.org
 help / color / mirror / Atom feed
From: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
To: tim@majoroak.me.uk
Cc: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>,
	Oleg Nesterov <oleg@redhat.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	stable@vger.kernel.org, Kees Cook <keescook@chromium.org>,
	Sudeep Holla <sudeep.holla@arm.com>
Subject: [PATCH] arm64: ptrace: Fix seccomp of traced syscall -1 (NO_SYSCALL)
Date: Fri,  5 Mar 2021 19:12:05 +0000	[thread overview]
Message-ID: <20210305191205.2239589-1-T.E.Baldwin99@members.leeds.ac.uk> (raw)
In-Reply-To: <20210301131000.avqjoi4vousakiq2@bogus>

commit df84fe94708985cdfb78a83148322bcd0a699472 upstream.

Backported to Linux 5.4 by changing "return NO_SYSCALL" to "return -1"
in patch context.

Since commit f086f67485c5 ("arm64: ptrace: add support for syscall
emulation"), if system call number -1 is called and the process is being
traced with PTRACE_SYSCALL, for example by strace, the seccomp check is
skipped and -ENOSYS is returned unconditionally (unless altered by the
tracer) rather than carrying out action specified in the seccomp filter.

The consequence of this is that it is not possible to reliably strace
a seccomp based implementation of a foreign system call interface in
which r7/x8 is permitted to be -1 on entry to a system call.

Also trace_sys_enter and audit_syscall_entry are skipped if a system
call is skipped.

Fix by removing the in_syscall(regs) check restoring the previous
behaviour which is like AArch32, x86 (which uses generic code) and
everything else.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: <stable@vger.kernel.org>
Fixes: f086f67485c5 ("arm64: ptrace: add support for syscall emulation")
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
Link: https://lore.kernel.org/r/90edd33b-6353-1228-791f-0336d94d5f8c@majoroak.me.uk
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arm64/kernel/ptrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 30b877f8b85e..0cfd68577489 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1844,7 +1844,7 @@ int syscall_trace_enter(struct pt_regs *regs)
 
 	if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) {
 		tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
-		if (!in_syscall(regs) || (flags & _TIF_SYSCALL_EMU))
+		if (flags & _TIF_SYSCALL_EMU)
 			return -1;
 	}
 
-- 
2.27.0


  reply	other threads:[~2021-03-05 19:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 10:33 FAILED: patch "[PATCH] arm64: ptrace: Fix seccomp of traced syscall -1 (NO_SYSCALL)" failed to apply to 5.4-stable tree gregkh
2021-03-01 13:10 ` Sudeep Holla
2021-03-05 19:12   ` Timothy E Baldwin [this message]
2021-03-07 15:01     ` [PATCH] arm64: ptrace: Fix seccomp of traced syscall -1 (NO_SYSCALL) Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2021-01-18  2:58 Timothy Baldwin
2021-02-24 14:49 ` Sudeep Holla
2021-02-24 22:48   ` Kees Cook
2021-02-25 10:12     ` Will Deacon
2021-02-25 11:02 ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210305191205.2239589-1-T.E.Baldwin99@members.leeds.ac.uk \
    --to=t.e.baldwin99@members.leeds.ac.uk \
    --cc=catalin.marinas@arm.com \
    --cc=keescook@chromium.org \
    --cc=oleg@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=tim@majoroak.me.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.