From 711b2b76b706c9833d2b8ab52a48ec481d70248c Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 10 Oct 2012 15:25:29 -0400 Subject: [PATCH] --- yaml --- r: 333907 b: refs/heads/master c: 873f1eedc1b983d772283279192c4ca2f60e8482 h: refs/heads/master i: 333905: b8f0c989207247be8440fd6adb1e2a6690d07bf4 333903: cdf42c12dfc0c35aededc75215e144e068b27798 v: v3 --- [refs] | 2 +- trunk/fs/namei.c | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index 6948d2e8461d..511f2d214fe4 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7ac86265dc8f665cc49d6e60a125e608cd2fca14 +refs/heads/master: 873f1eedc1b983d772283279192c4ca2f60e8482 diff --git a/trunk/fs/namei.c b/trunk/fs/namei.c index 5dbc3f836934..8c14353fb750 100644 --- a/trunk/fs/namei.c +++ b/trunk/fs/namei.c @@ -1988,20 +1988,30 @@ static int path_lookupat(int dfd, const char *name, return err; } -static int do_path_lookup(int dfd, const char *name, +static int filename_lookup(int dfd, struct filename *name, unsigned int flags, struct nameidata *nd) { - int retval = path_lookupat(dfd, name, flags | LOOKUP_RCU, nd); + int retval = path_lookupat(dfd, name->name, flags | LOOKUP_RCU, nd); if (unlikely(retval == -ECHILD)) - retval = path_lookupat(dfd, name, flags, nd); + retval = path_lookupat(dfd, name->name, flags, nd); if (unlikely(retval == -ESTALE)) - retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd); + retval = path_lookupat(dfd, name->name, + flags | LOOKUP_REVAL, nd); if (likely(!retval)) - audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT); + audit_inode(name->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 filename filename = { .name = name }; + + return filename_lookup(dfd, &filename, flags, nd); +} + /* does lookup, returns the object with parent locked */ struct dentry *kern_path_locked(const char *name, struct path *path) { @@ -2125,7 +2135,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 = filename_lookup(dfd, tmp, flags, &nd); putname(tmp); if (!err) *path = nd.path; @@ -2139,6 +2149,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 struct filename, but the nd->last pointer points into the name string + * allocated by getname. So we must hold the reference to it until all + * path-walking is complete. + */ static struct filename * user_path_parent(int dfd, const char __user *path, struct nameidata *nd) { @@ -2148,7 +2164,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 = filename_lookup(dfd, s, LOOKUP_PARENT, nd); if (error) { putname(s); return ERR_PTR(error);