From: Jeff Layton <jlayton@redhat.com>
To: viro@zeniv.linux.org.uk
Cc: eparis@redhat.com, linux-audit@redhat.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1 06/10] vfs: turn do_path_lookup into wrapper around getname_info variant
Date: Fri, 7 Sep 2012 09:38:01 -0400 [thread overview]
Message-ID: <1347025085-20285-7-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1347025085-20285-1-git-send-email-jlayton@redhat.com>
...and make the user_path callers use that variant instead.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
fs/namei.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index 60db390..774f942 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1989,20 +1989,30 @@ static int path_lookupat(int dfd, const char *name,
return err;
}
-static int do_path_lookup(int dfd, const char *name,
+static int ginfo_lookup(int dfd, struct getname_info *ginfo,
unsigned int flags, struct nameidata *nd)
{
- int retval = path_lookupat(dfd, name, flags | LOOKUP_RCU, nd);
+ int retval = path_lookupat(dfd, ginfo->name, flags | LOOKUP_RCU, nd);
if (unlikely(retval == -ECHILD))
- retval = path_lookupat(dfd, name, flags, nd);
+ retval = path_lookupat(dfd, ginfo->name, flags, nd);
if (unlikely(retval == -ESTALE))
- retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd);
+ retval = path_lookupat(dfd, ginfo->name,
+ flags | LOOKUP_REVAL, nd);
if (likely(!retval))
- audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
+ audit_inode(ginfo->name, nd->path.dentry,
+ flags & LOOKUP_PARENT);
return retval;
}
+static int do_path_lookup(int dfd, const char *name,
+ unsigned int flags, struct nameidata *nd)
+{
+ struct getname_info ginfo = { .name = name };
+
+ return ginfo_lookup(dfd, &ginfo, flags, nd);
+}
+
/* does lookup, returns the object with parent locked */
struct dentry *kern_path_locked(const char *name, struct path *path)
{
@@ -2126,7 +2136,7 @@ int user_path_at_empty(int dfd, const char __user *name, unsigned flags,
BUG_ON(flags & LOOKUP_PARENT);
- err = do_path_lookup(dfd, tmp->name, flags, &nd);
+ err = ginfo_lookup(dfd, tmp, flags, &nd);
putname(tmp);
if (!err)
*path = nd.path;
@@ -2140,6 +2150,12 @@ int user_path_at(int dfd, const char __user *name, unsigned flags,
return user_path_at_empty(dfd, name, flags, path, NULL);
}
+/*
+ * NB: most callers don't do anything directly with the reference to the
+ * to ginfo, but the nd->last pointer points into the name string
+ * allocated by getinfo. So we must hold the reference to it until all
+ * path-walking is complete.
+ */
static struct getname_info *
user_path_parent(int dfd, const char __user *path, struct nameidata *nd)
{
@@ -2149,7 +2165,7 @@ user_path_parent(int dfd, const char __user *path, struct nameidata *nd)
if (IS_ERR(s))
return s;
- error = do_path_lookup(dfd, s->name, LOOKUP_PARENT, nd);
+ error = ginfo_lookup(dfd, s, LOOKUP_PARENT, nd);
if (error) {
putname(s);
return ERR_PTR(error);
--
1.7.11.4
next prev parent reply other threads:[~2012-09-07 13:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-07 13:37 [PATCH v1 00/10] vfs: getname/putname overhaul Jeff Layton
2012-09-07 13:37 ` [PATCH v1 01/10] vfs: allocate page instead of names_cache buffer in mount_block_root Jeff Layton
2012-09-07 13:37 ` [PATCH v1 02/10] vfs: make dir_name arg to do_mount a const char * Jeff Layton
2012-09-07 13:37 ` [PATCH v1 03/10] acct: constify the name arg to acct_on Jeff Layton
2012-09-07 13:37 ` [PATCH v1 04/10] vfs: define getname_info struct and have getname() return it Jeff Layton
2012-09-07 13:38 ` [PATCH v1 05/10] audit: allow audit code to satisfy getname requests from its names_list Jeff Layton
2012-09-07 13:38 ` Jeff Layton [this message]
2012-09-07 13:38 ` [PATCH v1 07/10] vfs: make path_openat take a getname_info pointer Jeff Layton
2012-09-07 13:38 ` [PATCH v1 08/10] audit: make audit_inode take getname_info Jeff Layton
2012-09-07 13:38 ` [PATCH v1 09/10] vfs: embed getname_info inside of names_cache allocation if possible Jeff Layton
2012-09-07 13:38 ` [PATCH v1 10/10] vfs: unexport getname and putname symbols Jeff Layton
2012-09-07 21:26 ` [PATCH v1 00/10] vfs: getname/putname overhaul Andi Kleen
2012-09-08 0:54 ` Jeff Layton
2012-09-08 3:08 ` Andi Kleen
2012-09-08 11:24 ` Jeff Layton
2012-09-08 15:38 ` Andi Kleen
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=1347025085-20285-7-git-send-email-jlayton@redhat.com \
--to=jlayton@redhat.com \
--cc=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).