Re: [PATCH] syscalls: Document OCI seccomp filter interactions & workaround

From: Christian Brauner
Date: Tue Nov 24 2020 - 12:22:03 EST


On Tue, Nov 24, 2020 at 06:15:36PM +0100, Greg KH wrote:
> On Tue, Nov 24, 2020 at 06:06:38PM +0100, Jann Horn wrote:
> > +seccomp maintainers/reviewers
> > [thread context is at
> > https://lore.kernel.org/linux-api/87lfer2c0b.fsf@xxxxxxxxxxxxxxxxxxxxxxxxx/
> > ]
> >
> > On Tue, Nov 24, 2020 at 5:49 PM Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
> > > On Tue, Nov 24, 2020 at 03:08:05PM +0100, Mark Wielaard wrote:
> > > > For valgrind the issue is statx which we try to use before falling back
> > > > to stat64, fstatat or stat (depending on architecture, not all define
> > > > all of these). The problem with these fallbacks is that under some
> > > > containers (libseccomp versions) they might return EPERM instead of
> > > > ENOSYS. This causes really obscure errors that are really hard to
> > > > diagnose.
> > >
> > > So find a way to detect these completely broken container run times
> > > and refuse to run under them at all. After all they've decided to
> > > deliberately break the syscall ABI. (and yes, we gave the the rope
> > > to do that with seccomp :().
> >
> > FWIW, if the consensus is that seccomp filters that return -EPERM by
> > default are categorically wrong, I think it should be fairly easy to
> > add a check to the seccomp core that detects whether the installed
> > filter returns EPERM for some fixed unused syscall number and, if so,
> > prints a warning to dmesg or something along those lines...
>
> Why? seccomp is saying "this syscall is not permitted", so -EPERM seems
> like the correct error to provide here. It's not -ENOSYS as the syscall
> is present.
>
> As everyone knows, there are other ways to have -EPERM be returned from
> a syscall if you don't have the correct permissions to do something.
> Why is seccomp being singled out here? It's doing the correct thing.

The correct solution to this problem is simple: the standard and the
problematic container runtimes need to be fixed to return ENOSYS as I
said in my first mail. Imho, the kernel neither should need to log
anything or be opinionated about what error is correct or not. Imho,
this is a broken standard and that's where the story ends.

We've had that argument about ENOSYS being the correct errno in such
scenarios in userspace already and that's been ignored for _years_. Now,
as could be expected it's suddenly the kernel who's supposed to fix
this. That's totally wrong imho.

Christian