All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tycho Andersen <tycho.andersen@canonical.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux API <linux-api@vger.kernel.org>,
	Kees Cook <keescook@chromium.org>, Will Drewry <wad@chromium.org>,
	Roland McGrath <roland@hack.frob.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Pavel Emelyanov <xemul@parallels.com>,
	"Serge E. Hallyn" <serge.hallyn@ubuntu.com>
Subject: Re: [PATCH v4] seccomp: add ptrace options for suspend/resume
Date: Wed, 10 Jun 2015 09:19:00 -0600	[thread overview]
Message-ID: <20150610151900.GB10632@hopstrocity> (raw)
In-Reply-To: <CALCETrVuNzZRAw40reo_2ne9saO5KbbG-omFUQXDo=+XFhpuWA@mail.gmail.com>

Hi Andy,

On Tue, Jun 09, 2015 at 06:08:42PM -0700, Andy Lutomirski wrote:
>
> > +       if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) {
> > +               if (!config_enabled(CONFIG_CHECKPOINT_RESTORE) ||
> > +                   !config_enabled(CONFIG_SECCOMP))
> > +                       return -EINVAL;
> > +
> > +               if (!capable(CAP_SYS_ADMIN))
> > +                       return -EPERM;
> 
> I tend to think that we should also require that current not be using
> seccomp.  Otherwise, in principle, there's a seccomp bypass for
> privileged-but-seccomped programs.  In any event, CRIU isn't going to
> work well if you run the restorer under seccomp, since it'll start
> nesting in a manner that probably isn't desirable.

Ok, I can resend with that. (sorry Oleg :)

> > +       }
> > +
> >         /* Avoid intermediate state when all opts are cleared */
> >         flags = child->ptrace;
> >         flags &= ~(PTRACE_O_MASK << PT_OPT_FLAG_SHIFT);
> > diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> > index 980fd26..645e42d 100644
> > --- a/kernel/seccomp.c
> > +++ b/kernel/seccomp.c
> > @@ -590,6 +590,10 @@ void secure_computing_strict(int this_syscall)
> >  {
> >         int mode = current->seccomp.mode;
> >
> > +       if (config_enabled(CONFIG_CHECKPOINT_RESTORE) &&
> > +           unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
> > +               return;
> > +
> >         if (mode == 0)
> >                 return;
> >         else if (mode == SECCOMP_MODE_STRICT)
> > @@ -691,6 +695,10 @@ u32 seccomp_phase1(struct seccomp_data *sd)
> >         int this_syscall = sd ? sd->nr :
> >                 syscall_get_nr(current, task_pt_regs(current));
> >
> > +       if (config_enabled(CONFIG_CHECKPOINT_RESTORE) &&
> > +           unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
> > +               return SECCOMP_PHASE1_OK;
> > +
> 
> If it's not hard, it might still be nice to try to fold this into
> mode.  This code is rather hot.  If it would be a mess, then don't
> worry about it for now.

The part I'm not immediately clear on is what to do when the tracer
dies and the task is running. Oleg pointed out that we can't play with
TIF_SECCOMP (or we could, but restoring it in this case is
complicated), and I'm not sure if playing with ->seccomp.mode has any
similar complications. I /think/ it should be ok to just re-enable it,
but I'm not sure.

I'd like to leave this patch as is (modulo the extra check) for now.
I'm still looking at a way to export mode 2 filters, so there will
hopefully be more patches in this area soon and we can reexamine then.

Thanks for the review.

Tycho

WARNING: multiple messages have this Message-ID (diff)
From: Tycho Andersen <tycho.andersen-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
To: Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>
Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Linux API <linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Will Drewry <wad-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Roland McGrath <roland-/Z5OmTQCD9xF6kxbq+BtvQ@public.gmane.org>,
	Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Pavel Emelyanov <xemul-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>,
	"Serge E. Hallyn"
	<serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v4] seccomp: add ptrace options for suspend/resume
Date: Wed, 10 Jun 2015 09:19:00 -0600	[thread overview]
Message-ID: <20150610151900.GB10632@hopstrocity> (raw)
In-Reply-To: <CALCETrVuNzZRAw40reo_2ne9saO5KbbG-omFUQXDo=+XFhpuWA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Andy,

On Tue, Jun 09, 2015 at 06:08:42PM -0700, Andy Lutomirski wrote:
>
> > +       if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) {
> > +               if (!config_enabled(CONFIG_CHECKPOINT_RESTORE) ||
> > +                   !config_enabled(CONFIG_SECCOMP))
> > +                       return -EINVAL;
> > +
> > +               if (!capable(CAP_SYS_ADMIN))
> > +                       return -EPERM;
> 
> I tend to think that we should also require that current not be using
> seccomp.  Otherwise, in principle, there's a seccomp bypass for
> privileged-but-seccomped programs.  In any event, CRIU isn't going to
> work well if you run the restorer under seccomp, since it'll start
> nesting in a manner that probably isn't desirable.

Ok, I can resend with that. (sorry Oleg :)

> > +       }
> > +
> >         /* Avoid intermediate state when all opts are cleared */
> >         flags = child->ptrace;
> >         flags &= ~(PTRACE_O_MASK << PT_OPT_FLAG_SHIFT);
> > diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> > index 980fd26..645e42d 100644
> > --- a/kernel/seccomp.c
> > +++ b/kernel/seccomp.c
> > @@ -590,6 +590,10 @@ void secure_computing_strict(int this_syscall)
> >  {
> >         int mode = current->seccomp.mode;
> >
> > +       if (config_enabled(CONFIG_CHECKPOINT_RESTORE) &&
> > +           unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
> > +               return;
> > +
> >         if (mode == 0)
> >                 return;
> >         else if (mode == SECCOMP_MODE_STRICT)
> > @@ -691,6 +695,10 @@ u32 seccomp_phase1(struct seccomp_data *sd)
> >         int this_syscall = sd ? sd->nr :
> >                 syscall_get_nr(current, task_pt_regs(current));
> >
> > +       if (config_enabled(CONFIG_CHECKPOINT_RESTORE) &&
> > +           unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
> > +               return SECCOMP_PHASE1_OK;
> > +
> 
> If it's not hard, it might still be nice to try to fold this into
> mode.  This code is rather hot.  If it would be a mess, then don't
> worry about it for now.

The part I'm not immediately clear on is what to do when the tracer
dies and the task is running. Oleg pointed out that we can't play with
TIF_SECCOMP (or we could, but restoring it in this case is
complicated), and I'm not sure if playing with ->seccomp.mode has any
similar complications. I /think/ it should be ok to just re-enable it,
but I'm not sure.

I'd like to leave this patch as is (modulo the extra check) for now.
I'm still looking at a way to export mode 2 filters, so there will
hopefully be more patches in this area soon and we can reexamine then.

Thanks for the review.

Tycho

  reply	other threads:[~2015-06-10 15:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10  0:49 [PATCH v4] seccomp: add ptrace options for suspend/resume Tycho Andersen
2015-06-10  0:49 ` Tycho Andersen
2015-06-10  1:08 ` Andy Lutomirski
2015-06-10  1:08   ` Andy Lutomirski
2015-06-10 15:19   ` Tycho Andersen [this message]
2015-06-10 15:19     ` Tycho Andersen
2015-06-10 16:31   ` Oleg Nesterov
2015-06-10 17:20     ` Andy Lutomirski
2015-06-10 17:20       ` Andy Lutomirski
2015-06-10 17:29       ` Serge Hallyn
2015-06-10 17:29         ` Serge Hallyn
2015-06-10 17:42         ` Andy Lutomirski
2015-06-10 17:42           ` Andy Lutomirski
2015-06-10 19:20       ` Oleg Nesterov
2015-06-10 19:20         ` Oleg Nesterov
2015-06-10 20:18       ` Kees Cook
2015-06-10 20:18         ` Kees Cook
2015-06-10 20:26         ` Oleg Nesterov
2015-06-10 20:26           ` Oleg Nesterov
2015-06-12 23:27         ` Andy Lutomirski
2015-06-12 23:27           ` Andy Lutomirski
2015-06-12 23:29           ` Kees Cook
2015-06-12 23:29             ` Kees Cook
2015-06-13 15:06             ` Tycho Andersen
2015-06-13 15:06               ` Tycho Andersen
2015-06-10 20:33 ` Kees Cook
2015-06-10 20:33   ` Kees Cook
2015-06-10 20:57   ` Tycho Andersen
2015-06-10 20:57     ` Tycho Andersen

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=20150610151900.GB10632@hopstrocity \
    --to=tycho.andersen@canonical.com \
    --cc=keescook@chromium.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=roland@hack.frob.com \
    --cc=serge.hallyn@ubuntu.com \
    --cc=wad@chromium.org \
    --cc=xemul@parallels.com \
    /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.