All of lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Kees Cook <keescook@chromium.org>
Cc: Keno Fischer <keno@juliacomputing.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Will Drewry <wad@chromium.org>
Subject: Re: ptrace: seccomp: Return value when the call was already invalid
Date: Mon, 6 Jul 2020 09:15:51 +0100	[thread overview]
Message-ID: <20200706081550.GA23032@willie-the-truck> (raw)
In-Reply-To: <202007042132.DAFA2C2@keescook>

On Sat, Jul 04, 2020 at 09:56:50PM -0700, Kees Cook wrote:
> On Sat, Jul 04, 2020 at 01:33:56PM +0100, Will Deacon wrote:
> > On Fri, Jul 03, 2020 at 08:52:05AM -0700, Kees Cook wrote:
> > > On Fri, Jul 03, 2020 at 04:44:27PM +0100, Will Deacon wrote:
> > > > On Fri, Jul 03, 2020 at 08:17:19AM -0700, Kees Cook wrote:
> > > > > On Fri, Jul 03, 2020 at 09:39:14AM +0100, Will Deacon wrote:
> > > > > > diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c
> > > > > > index 5f5b868292f5..a13661f44818 100644
> > > > > > --- a/arch/arm64/kernel/syscall.c
> > > > > > +++ b/arch/arm64/kernel/syscall.c
> > > > > > @@ -121,12 +121,10 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr,
> > > > > >  	user_exit();
> > > > > >  
> > > > > >  	if (has_syscall_work(flags)) {
> > > > > > -		/* set default errno for user-issued syscall(-1) */
> > > > > > -		if (scno == NO_SYSCALL)
> > > > > > -			regs->regs[0] = -ENOSYS;
> > > > > > -		scno = syscall_trace_enter(regs);
> > > > > > -		if (scno == NO_SYSCALL)
> > > > > > +		if (syscall_trace_enter(regs))
> > > > > >  			goto trace_exit;
> > > > > > +
> > > > > > +		scno = regs->syscallno;
> > > > > >  	}
> > > > > >  
> > > > > >  	invoke_syscall(regs, scno, sc_nr, syscall_table);
> > > > > 
> > > > > What effect do either of these patches have on the existing seccomp
> > > > > selftests: tools/testing/selftests/seccomp/seccomp_bpf ?
> > > > 
> > > > Tests! Thanks, I'll have a look.
> > > 
> > > Thanks!
> > > 
> > > (And either way, that this behavioral difference went unnoticed means we
> > > need to add a test to the selftests for this patch.)
> > 
> > Unsurprisingly, I don't think the tests go near this. I get 75/77 passes
> > on arm64 defconfig with or without these changes.
> 
> (What doesn't pass for you? I tried to go find kernelci.org test output,
> but it doesn't appear to actually run selftests yet?)
> 
> Anyway, good that the test output doesn't change, bad that seccomp has
> missed a corner of this architecture interface. (i.e. the entire
> TRACE_syscall fixture is dedicated to exercising the changing/skipping
> interface, but I see now that it doesn't at all exercise any area of
> ENOSYS results.)
> 
> > We could add a test, but then we'd have to agree on what it's supposed to
> > be doing ;)
> 
> Well, if you look at change_syscall() in seccomp_bpf.c (once you stop
> screaming) you'll likely share my desire to have more things that are
> common across architectures. ;) So, to that end, yes, please, let's
> define what we'd like to see, and then build out the (likely wildly
> different per-architecture expectations). If I read this thread
> correctly, we need to test:
> 
> 	syscall(-1), direct,  returns ENOSYS
> 	syscall(-10), direct, returns ENOSYS
> 	syscall(-1), SECCOMP_RET_TRACE+PTRACE_CONT, returns ENOSYS
> 	syscall(-10), SECCOMP_RET_TRACE+PTRACE_CONT, returns ENOSYS
> 	syscall(-1), ptrace+PTRACE_SYSCALL, returns ENOSYS
> 	syscall(-10), ptrace+PTRACE_SYSCALL, returns ENOSYS
> 
> do we need to double-check that registers before/after are otherwise
> unchanged too? (I *think* just looking at syscall return should be
> sufficient to catch the visible results.)

There's also the case where the tracer sets the system call to -1 to skip
it.

Will

  reply	other threads:[~2020-07-06  8:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-23  1:01 ptrace: seccomp: Return value when the call was already invalid Keno Fischer
2020-07-03  8:39 ` Will Deacon
2020-07-03 15:17   ` Kees Cook
2020-07-03 15:44     ` Will Deacon
2020-07-03 15:52       ` Kees Cook
2020-07-04 12:33         ` Will Deacon
2020-07-05  4:56           ` Kees Cook
2020-07-06  8:15             ` Will Deacon [this message]
2020-07-06 21:40               ` Kees Cook
2020-07-10 12:42             ` Will Deacon
2020-07-10 16:14               ` Kees Cook
2020-07-03 20:27   ` Keno Fischer
2020-07-04 12:50     ` 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=20200706081550.GA23032@willie-the-truck \
    --to=will@kernel.org \
    --cc=keescook@chromium.org \
    --cc=keno@juliacomputing.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=wad@chromium.org \
    /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.