All of lore.kernel.org
 help / color / mirror / Atom feed
From: Serge Hallyn <serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
To: Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>
Cc: Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Tycho Andersen
	<tycho.andersen-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
	"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>,
	Pavel Emelyanov <xemul-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
Subject: Re: [PATCH v4] seccomp: add ptrace options for suspend/resume
Date: Wed, 10 Jun 2015 17:29:31 +0000	[thread overview]
Message-ID: <20150610172931.GD4069@ubuntumail> (raw)
In-Reply-To: <CALCETrX_GXgjPRXXT4jMZtjR6vMQrmYbk_OwrAoxaJWFT0+0Fw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Quoting Andy Lutomirski (luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org):
> On Wed, Jun 10, 2015 at 9:31 AM, Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > On 06/09, Andy Lutomirski wrote:
> >>
> >> On Tue, Jun 9, 2015 at 5:49 PM, Tycho Andersen
> >> >
> >> > @@ -556,6 +556,15 @@ static int ptrace_setoptions(struct task_struct *child, unsigned long data)
> >> >         if (data & ~(unsigned long)PTRACE_O_MASK)
> >> >                 return -EINVAL;
> >> >
> >> > +       if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) {
> >
> > Well, we should do this if
> >
> >                         (data & O_SUSPEND) && !(flags & O_SUSPEND)
> >
> > or at least if
> >
> >                         (data ^ flags) & O_SUSPEND
> >
> >
> >> > +               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.
> >
> > Andy, I simply can't understand why do we need any security check at all.
> >
> > OK, yes, in theory we can have a seccomped CAP_SYS_ADMIN process, seccomp
> > doesn't filter ptrace, you hack that process and force it to attach to
> > another CAP_SYS_ADMIN/seccomped process, etc, etc... Looks too paranoid
> > to me.
> 
> I've sometimes considered having privileged processes I write fork and
> seccomp their child.  Of course, if you're allowing ptrace through
> your seccomp filter, you open a giant can of worms, but I think we
> should take the more paranoid approach to start and relax it later as

I really do intend to look at your old proposed tree for improving that...
have only done a once-over so far, though.

> needed.  After all, for the intended use of this patch, stuff will
> break regardless of what we do if the ptracer is itself seccomped.
> 
> I could be convinced that if the ptracer is outside seccomp then we
> shouldn't need the CAP_SYS_ADMIN check.  That would at least make this
> work in a user namespace.
> 
> >> > @@ -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.
> >
> > IMO, this would be a mess ;) At least compared to this simple patch.
> >
> > Suppose we add SECCOMP_MODE_SUSPENDED. Not only this adds the problems
> > with detach if the tracer dies.
> >
> > We need to change copy_seccomp(). And it is not clear what should we
> > do if the child is traced too.
> >
> > We need to change prctl_set_seccomp() paths.
> >
> > And even the "tracee->seccomp.mode = SECCOMP_MODE_SUSPENDED" code needs
> > some locking even if the tracee is stopped, we need to avoid the races
> > with SECCOMP_FILTER_FLAG_TSYNC from other threads.
> >
> 
> Agreed.  Let's hold off until this becomes a problem (if it ever does).
> 
> --Andy

WARNING: multiple messages have this Message-ID (diff)
From: Serge Hallyn <serge.hallyn@ubuntu.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Oleg Nesterov <oleg@redhat.com>,
	Tycho Andersen <tycho.andersen@canonical.com>,
	"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>,
	Pavel Emelyanov <xemul@parallels.com>
Subject: Re: [PATCH v4] seccomp: add ptrace options for suspend/resume
Date: Wed, 10 Jun 2015 17:29:31 +0000	[thread overview]
Message-ID: <20150610172931.GD4069@ubuntumail> (raw)
In-Reply-To: <CALCETrX_GXgjPRXXT4jMZtjR6vMQrmYbk_OwrAoxaJWFT0+0Fw@mail.gmail.com>

Quoting Andy Lutomirski (luto@amacapital.net):
> On Wed, Jun 10, 2015 at 9:31 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> > On 06/09, Andy Lutomirski wrote:
> >>
> >> On Tue, Jun 9, 2015 at 5:49 PM, Tycho Andersen
> >> >
> >> > @@ -556,6 +556,15 @@ static int ptrace_setoptions(struct task_struct *child, unsigned long data)
> >> >         if (data & ~(unsigned long)PTRACE_O_MASK)
> >> >                 return -EINVAL;
> >> >
> >> > +       if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) {
> >
> > Well, we should do this if
> >
> >                         (data & O_SUSPEND) && !(flags & O_SUSPEND)
> >
> > or at least if
> >
> >                         (data ^ flags) & O_SUSPEND
> >
> >
> >> > +               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.
> >
> > Andy, I simply can't understand why do we need any security check at all.
> >
> > OK, yes, in theory we can have a seccomped CAP_SYS_ADMIN process, seccomp
> > doesn't filter ptrace, you hack that process and force it to attach to
> > another CAP_SYS_ADMIN/seccomped process, etc, etc... Looks too paranoid
> > to me.
> 
> I've sometimes considered having privileged processes I write fork and
> seccomp their child.  Of course, if you're allowing ptrace through
> your seccomp filter, you open a giant can of worms, but I think we
> should take the more paranoid approach to start and relax it later as

I really do intend to look at your old proposed tree for improving that...
have only done a once-over so far, though.

> needed.  After all, for the intended use of this patch, stuff will
> break regardless of what we do if the ptracer is itself seccomped.
> 
> I could be convinced that if the ptracer is outside seccomp then we
> shouldn't need the CAP_SYS_ADMIN check.  That would at least make this
> work in a user namespace.
> 
> >> > @@ -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.
> >
> > IMO, this would be a mess ;) At least compared to this simple patch.
> >
> > Suppose we add SECCOMP_MODE_SUSPENDED. Not only this adds the problems
> > with detach if the tracer dies.
> >
> > We need to change copy_seccomp(). And it is not clear what should we
> > do if the child is traced too.
> >
> > We need to change prctl_set_seccomp() paths.
> >
> > And even the "tracee->seccomp.mode = SECCOMP_MODE_SUSPENDED" code needs
> > some locking even if the tracee is stopped, we need to avoid the races
> > with SECCOMP_FILTER_FLAG_TSYNC from other threads.
> >
> 
> Agreed.  Let's hold off until this becomes a problem (if it ever does).
> 
> --Andy

  parent reply	other threads:[~2015-06-10 17:29 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
     [not found] ` <1433897388-9567-1-git-send-email-tycho.andersen-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2015-06-10  1:08   ` Andy Lutomirski
2015-06-10  1:08     ` Andy Lutomirski
     [not found]     ` <CALCETrVuNzZRAw40reo_2ne9saO5KbbG-omFUQXDo=+XFhpuWA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-10 15:19       ` Tycho Andersen
2015-06-10 15:19         ` Tycho Andersen
2015-06-10 16:31     ` Oleg Nesterov
     [not found]       ` <20150610163149.GA5092-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-10 17:20         ` Andy Lutomirski
2015-06-10 17:20           ` Andy Lutomirski
     [not found]           ` <CALCETrX_GXgjPRXXT4jMZtjR6vMQrmYbk_OwrAoxaJWFT0+0Fw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-10 17:29             ` Serge Hallyn [this message]
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
     [not found]               ` <CAGXu5jJovcC1S4OANpqbVe6e86xr4W9Y7897MsSDOpvEqezpnA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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
     [not found]                   ` <CALCETrUSjKVWoMM8aVeevAZRHqtiE7zOSUvjdW_yCBTnR07Ahg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-12 23:29                     ` Kees Cook
2015-06-12 23:29                       ` Kees Cook
     [not found]                       ` <CAGXu5jKD8nj-E87em6BqS_TAeca4-kqL2u7jqYFompzqPrvqfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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
     [not found]     ` <CAGXu5jKuf6PoBDDkr21ZHOMnWpRAZ-G=NA7rVMx_1qiHZ-8DzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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=20150610172931.GD4069@ubuntumail \
    --to=serge.hallyn-gewih/nmzzlqt0dzr+alfa@public.gmane.org \
    --cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org \
    --cc=oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=roland-/Z5OmTQCD9xF6kxbq+BtvQ@public.gmane.org \
    --cc=tycho.andersen-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
    --cc=wad-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=xemul-bzQdu9zFT3WakBO8gow8eQ@public.gmane.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.