aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-05-12 16:53:42 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-05-15 01:10:41 -0400
commitabc9f5beb1ca97b5157914c83c85d67a6b665d74 (patch)
treeb62c7291495137f2c3a5c50276bd7f92c426b38f /fs/namei.c
parent9ad1aaa61522ffba001a5599623182fe23083a94 (diff)
namei: make filename_lookup() reject ERR_PTR() passed as name
makes for much easier life in callers Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 2999404c8d30..a9c593e4f35e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2122,7 +2122,10 @@ static int filename_lookup(int dfd, struct filename *name, unsigned flags,
2122 struct path *path, struct path *root) 2122 struct path *path, struct path *root)
2123{ 2123{
2124 int retval; 2124 int retval;
2125 struct nameidata nd, *saved_nd = set_nameidata(&nd); 2125 struct nameidata nd, *saved_nd;
2126 if (IS_ERR(name))
2127 return PTR_ERR(name);
2128 saved_nd = set_nameidata(&nd);
2126 if (unlikely(root)) { 2129 if (unlikely(root)) {
2127 nd.root = *root; 2130 nd.root = *root;
2128 flags |= LOOKUP_ROOT; 2131 flags |= LOOKUP_ROOT;
@@ -2212,10 +2215,8 @@ out:
2212 2215
2213int kern_path(const char *name, unsigned int flags, struct path *path) 2216int kern_path(const char *name, unsigned int flags, struct path *path)
2214{ 2217{
2215 struct filename *filename = getname_kernel(name); 2218 return filename_lookup(AT_FDCWD, getname_kernel(name),
2216 if (IS_ERR(filename)) 2219 flags, path, NULL);
2217 return PTR_ERR(filename);
2218 return filename_lookup(AT_FDCWD, filename, flags, path, NULL);
2219} 2220}
2220EXPORT_SYMBOL(kern_path); 2221EXPORT_SYMBOL(kern_path);
2221 2222
@@ -2232,15 +2233,9 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
2232 struct path *path) 2233 struct path *path)
2233{ 2234{
2234 struct path root = {.mnt = mnt, .dentry = dentry}; 2235 struct path root = {.mnt = mnt, .dentry = dentry};
2235 struct filename *filename = getname_kernel(name);
2236
2237 BUG_ON(flags & LOOKUP_PARENT);
2238
2239 if (IS_ERR(filename))
2240 return PTR_ERR(filename);
2241
2242 /* the first argument of filename_lookup() is ignored with root */ 2236 /* the first argument of filename_lookup() is ignored with root */
2243 return filename_lookup(AT_FDCWD, filename, flags , path, &root); 2237 return filename_lookup(AT_FDCWD, getname_kernel(name),
2238 flags , path, &root);
2244} 2239}
2245EXPORT_SYMBOL(vfs_path_lookup); 2240EXPORT_SYMBOL(vfs_path_lookup);
2246 2241
@@ -2298,13 +2293,8 @@ EXPORT_SYMBOL(lookup_one_len);
2298int user_path_at_empty(int dfd, const char __user *name, unsigned flags, 2293int user_path_at_empty(int dfd, const char __user *name, unsigned flags,
2299 struct path *path, int *empty) 2294 struct path *path, int *empty)
2300{ 2295{
2301 struct filename *tmp = getname_flags(name, flags, empty); 2296 return filename_lookup(dfd, getname_flags(name, flags, empty),
2302 if (IS_ERR(tmp)) 2297 flags, path, NULL);
2303 return PTR_ERR(tmp);
2304
2305 BUG_ON(flags & LOOKUP_PARENT);
2306
2307 return filename_lookup(dfd, tmp, flags, path, NULL);
2308} 2298}
2309 2299
2310int user_path_at(int dfd, const char __user *name, unsigned flags, 2300int user_path_at(int dfd, const char __user *name, unsigned flags,