From: Paul Menage <pmenage@ensim.com>
To: Maneesh Soni <maneesh@in.ibm.com>
Cc: pmenage@ensim.com, linux-kernel@vger.kernel.org, viro@math.psu.edu
Subject: Re: [RFC] link_path_walk cleanup
Date: Fri, 26 Apr 2002 14:28:26 -0700 [thread overview]
Message-ID: <E171DGU-0003m7-00@pmenage-dt.ensim.com> (raw)
Hi Maneesh,
The handling of '/' in path_walk() and vfs_follow_link() is broken - if
the pathname consists entirely of '/' characters, then lookup_parent
returns the base immediately without setting nd->last. If there's more
than one '/', then the check for looking up '/' won't be triggered, and
walk_one() will be called with an undefined nd->last.
So e.g. running
ls '//'
produces
ls: //: File name too long
(but I suspect that it could Oops, depending on what was on the stack
when the nameidata was allocated.)
Ideally the tests in vfs_follow_link() and path_walk() ought to be
testing for (nd->last_type == LAST_ROOT), rather than checking
explicitly for '/' followed by NUL. But that doesn't work, as last_type
is only set if you include LOOKUP_PARENT in the flags. Setting last_type
on every path element resolution would probably be unecessary overhead
given the relative infrequency of looking up "/".
So the alternative that I suggest is to change lookup_parent() as
follows:
while (*name=='/')
name++;
if (!*name) {
nd->last = (struct qstr) { name : ".", len : 1, hash : 0 };
goto return_base;
}
and remove the tests for "/" in vfs_follow_link() and path_walk().
Setting nd->last to refer to "." will cause walk_one() to return
immediately, so the zero hash value is OK.
Paul
next reply other threads:[~2002-04-26 21:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-26 21:28 Paul Menage [this message]
2002-04-29 5:19 ` Maneesh Soni
-- strict thread matches above, loose matches on Subject: below --
2002-04-26 13:51 Maneesh Soni
2002-04-26 16:40 ` Andrew Morton
2002-04-26 17:26 ` Alexander Viro
2002-04-27 1:45 ` Denis Vlasenko
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=E171DGU-0003m7-00@pmenage-dt.ensim.com \
--to=pmenage@ensim.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maneesh@in.ibm.com \
--cc=viro@math.psu.edu \
/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®