All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	stable@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sasha.levin@oracle.com>,
	Jiri Slaby <jirislaby@gmail.com>,
	Willy Tarreau <willy@meta-x.org>, Li Zefan <lizefan@huawei.com>
Subject: Re: [PATCHES] Bind mount escape fixes (CVE-2015-2925)
Date: Thu, 8 Oct 2015 07:11:18 +0200	[thread overview]
Message-ID: <20151008051118.GA4263@1wt.eu> (raw)
In-Reply-To: <1444266508.2956.228.camel@decadent.org.uk>

Hi Ben,

On Thu, Oct 08, 2015 at 02:08:28AM +0100, Ben Hutchings wrote:
> For 2.6.32, the first backport looks wrong:
> 
> > --- a/fs/dcache.c
> > +++ b/fs/dcache.c
> > @@ -1910,7 +1910,7 @@ char *__d_path(const struct path *path, struct path *root,
> >         struct dentry *dentry = path->dentry;
> >         struct vfsmount *vfsmnt = path->mnt;
> >         char *end = buffer + buflen;
> > -       char *retval;
> > +       char *retval, *tail;
> >  
> >         spin_lock(&vfsmount_lock);
> >         prepend(&end, &buflen, "\0", 1);
> > @@ -1923,6 +1923,7 @@ char *__d_path(const struct path *path, struct path *root,
> >         /* Get '/' right */
> >         retval = end-1;
> >         *retval = '/';
> > +       tail = end;
> 
> So tail points to the null terminator.
> 
> >         for (;;) {
> >                 struct dentry * parent;
> > @@ -1930,6 +1931,12 @@ char *__d_path(const struct path *path, struct path *root,
> >                 if (dentry == root->dentry && vfsmnt == root->mnt)
> >                         break;
> >                 if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
> > +                       /* Escaped? */
> > +                       if (dentry != vfsmnt->mnt_root) {
> > +                               retval = tail;
> > +                               *retval = '/';
> 
> Now we overwrite the null terminator.

Good catch!

> > +                               goto out;
> > +                       }
> >                         /* Global root? */
> >                         if (vfsmnt->mnt_parent == vfsmnt) {
> >                                 goto global_root;
> 
> Also, nothing inserts the "(unreachable)" string.  I've attached my
> version, which deals with both of these.

Thanks, I've queued this one instead!

Willy


  reply	other threads:[~2015-10-08  5:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 16:15 [PATCHES] Bind mount escape fixes (CVE-2015-2925) Eric W. Biederman
2015-10-01 23:08 ` Willy Tarreau
2015-10-02  2:45 ` Ben Hutchings
2015-10-02  3:28   ` Eric W. Biederman
2015-10-02 16:01     ` Eric W. Biederman
2015-10-03  1:48       ` Ben Hutchings
2015-10-03  6:12         ` Willy Tarreau
2015-10-02  9:26 ` Jiri Slaby
2015-10-05 10:34 ` Luis Henriques
2015-10-08  1:08 ` Ben Hutchings
2015-10-08  5:11   ` Willy Tarreau [this message]
2015-10-18  0:01 ` Greg Kroah-Hartman

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=20151008051118.GA4263@1wt.eu \
    --to=w@1wt.eu \
    --cc=ben@decadent.org.uk \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@gmail.com \
    --cc=lizefan@huawei.com \
    --cc=sasha.levin@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=willy@meta-x.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.