[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181013082210.GU32577@ZenIV.linux.org.uk>
Date: Sat, 13 Oct 2018 09:22:10 +0100
From: Al Viro <viro@...IV.linux.org.uk>
To: Aleksa Sarai <asarai@...e.de>
Cc: Jann Horn <jannh@...gle.com>, cyphar@...har.com,
"Eric W. Biederman" <ebiederm@...ssion.com>, jlayton@...nel.org,
Bruce Fields <bfields@...ldses.org>,
Arnd Bergmann <arnd@...db.de>,
Andy Lutomirski <luto@...nel.org>,
David Howells <dhowells@...hat.com>, christian@...uner.io,
Tycho Andersen <tycho@...ho.ws>,
David Drysdale <drysdale@...gle.com>, dev@...ncontainers.org,
containers@...ts.linux-foundation.org,
linux-fsdevel@...r.kernel.org,
kernel list <linux-kernel@...r.kernel.org>,
linux-arch <linux-arch@...r.kernel.org>,
Linux API <linux-api@...r.kernel.org>
Subject: Re: [PATCH v3 3/3] namei: aggressively check for nd->root escape on
".." resolution
On Wed, Oct 10, 2018 at 02:37:28AM +1100, Aleksa Sarai wrote:
> > > +static inline int nd_alloc_dpathbuf(struct nameidata *nd)
> > > +{
> > > + if (unlikely(!nd->dpathbuf)) {
> > > + if (nd->flags & LOOKUP_RCU) {
> > > + nd->dpathbuf = kmalloc(PATH_MAX, GFP_ATOMIC);
> > > + if (unlikely(!nd->dpathbuf))
> > > + return -ECHILD;
> > > + } else {
> > > + nd->dpathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
> > > + if (unlikely(!nd->dpathbuf))
> > > + return -ENOMEM;
> > > + }
> > > + }
> > > + return 0;
> > > +}
> >
> > Note that a fixed-size path buffer means that if the path is very
> > long, e.g. because you followed long symlinks on the way down, this
> > can cause lookup failures.
>
> This is already an issue with __d_path (even if the buffer was larger)
> because it will not output a path longer than PATH_MAX. I imagine this
> is a pretty strong argument for why we should refactor __d_path so that
> we can *just* use the escape checking to avoid -ENAMETOOLONG.
Let me get it straight - the whole point of that buffer is to check
if __d_path() returns NULL? So you allocate it so that you would have
place to copy the path components into... only to have them completely
ignored?
How is that different from path_is_under()?
Powered by blists - more mailing lists