mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Morris <jmorris@namei.org>
To: Kees Cook <keescook@chromium.org>
Cc: Tycho Andersen <tycho@tycho.ws>,
	LKML <linux-kernel@vger.kernel.org>,
	"# 3.4.x" <stable@vger.kernel.org>
Subject: Re: [PATCH 2/2] seccomp: disallow NEW_LISTENER and TSYNC flags
Date: Wed, 24 Apr 2019 09:18:04 +1000 (AEST)	[thread overview]
Message-ID: <alpine.LRH.2.21.1904240917350.29297@namei.org> (raw)
In-Reply-To: <CAGXu5jKaK-mTq=Qez7E_fYysz916_xEN7Houj-y8gdmNGkMMVw@mail.gmail.com>

On Tue, 23 Apr 2019, Kees Cook wrote:

> Thanks! Sorry I missed this. James, can you take this for Linus's
> fixes for v5.1? (Or should I send a pull request to you?)
> 
> Acked-by: Kees Cook <keescook@chromium.org>

These are standalone for v5.1 fixes currently so you can send them 
directly to Linus.

> 
> Let's also add:
> 
> Reported-by: syzbot+b562969adb2e04af3442@syzkaller.appspotmail.com
> 
> > ---
> >  kernel/seccomp.c | 17 +++++++++++++++--
> >  1 file changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> > index d0d355ded2f4..79bada51091b 100644
> > --- a/kernel/seccomp.c
> > +++ b/kernel/seccomp.c
> > @@ -500,7 +500,10 @@ seccomp_prepare_user_filter(const char __user *user_filter)
> >   *
> >   * Caller must be holding current->sighand->siglock lock.
> >   *
> > - * Returns 0 on success, -ve on error.
> > + * Returns 0 on success, -ve on error, or
> > + *   - in TSYNC mode: the pid of a thread which was either not in the correct
> > + *     seccomp mode or did not have an ancestral seccomp filter
> > + *   - in NEW_LISTENER mode: the fd of the new listener
> >   */
> >  static long seccomp_attach_filter(unsigned int flags,
> >                                   struct seccomp_filter *filter)
> > @@ -1256,6 +1259,16 @@ static long seccomp_set_mode_filter(unsigned int flags,
> >         if (flags & ~SECCOMP_FILTER_FLAG_MASK)
> >                 return -EINVAL;
> >
> > +       /*
> > +        * In the successful case, NEW_LISTENER returns the new listener fd.
> > +        * But in the failure case, TSYNC returns the thread that died. If you
> > +        * combine these two flags, there's no way to tell whether something
> > +        * succeded or failed. So, let's disallow this combination.
> 
> also a tiny typo: succeeded
> 
> > +        */
> > +       if ((flags & SECCOMP_FILTER_FLAG_TSYNC) &&
> > +           (flags && SECCOMP_FILTER_FLAG_NEW_LISTENER))
> > +               return -EINVAL;
> > +
> >         /* Prepare the new filter before holding any locks. */
> >         prepared = seccomp_prepare_user_filter(filter);
> >         if (IS_ERR(prepared))
> > @@ -1302,7 +1315,7 @@ static long seccomp_set_mode_filter(unsigned int flags,
> >                 mutex_unlock(&current->signal->cred_guard_mutex);
> >  out_put_fd:
> >         if (flags & SECCOMP_FILTER_FLAG_NEW_LISTENER) {
> > -               if (ret < 0) {
> > +               if (ret) {
> >                         listener_f->private_data = NULL;
> >                         fput(listener_f);
> >                         put_unused_fd(listener);
> > --
> > 2.19.1
> >
> 
> -Kees
> 
> 

-- 
James Morris
<jmorris@namei.org>


  reply	other threads:[~2019-04-23 23:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06 20:14 [PATCH 1/2] seccomp: fix up grammar in comment Tycho Andersen
2019-03-06 20:14 ` [PATCH 2/2] seccomp: disallow NEW_LISTENER and TSYNC flags Tycho Andersen
2019-03-06 20:39   ` Christian Brauner
2019-03-06 20:46     ` Tycho Andersen
2019-03-06 21:02       ` Christian Brauner
2019-03-06 21:30         ` Tycho Andersen
2019-04-23 22:09   ` Kees Cook
2019-04-23 23:18     ` James Morris [this message]
2019-04-23 23:31     ` Kees Cook
2019-04-23 23:34       ` Tycho Andersen
2019-04-24  1:02         ` Kees Cook
2019-04-23 22:11 ` [PATCH 1/2] seccomp: fix up grammar in comment Kees Cook
2019-04-23 23:24   ` James Morris

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=alpine.LRH.2.21.1904240917350.29297@namei.org \
    --to=jmorris@namei.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tycho@tycho.ws \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®