Reduce path_lookup() abuses
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 3 Apr 2009 01:17:03 +0000 (21:17 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 9 May 2009 14:49:42 +0000 (10:49 -0400)
... use kern_path() where possible

[folded a fix from rdd]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/scsi/osd/osd_uld.c
fs/gfs2/ops_fstype.c
security/tomoyo/common.c
security/tomoyo/realpath.c

index f644c9571eab01d3f43be700914cac38b0c3c3d8..22b59e13ba83fd7d91b71c6b78f7b945291ab5da 100644 (file)
@@ -173,26 +173,26 @@ static const struct file_operations osd_fops = {
        .unlocked_ioctl = osd_uld_ioctl,
 };
 
-struct osd_dev *osduld_path_lookup(const char *path)
+struct osd_dev *osduld_path_lookup(const char *name)
 {
-       struct nameidata nd;
+       struct path path;
        struct inode *inode;
        struct cdev *cdev;
        struct osd_uld_device *uninitialized_var(oud);
        int error;
 
-       if (!path || !*path) {
+       if (!name || !*name) {
                OSD_ERR("Mount with !path || !*path\n");
                return ERR_PTR(-EINVAL);
        }
 
-       error = path_lookup(path, LOOKUP_FOLLOW, &nd);
+       error = kern_path(name, LOOKUP_FOLLOW, &path);
        if (error) {
-               OSD_ERR("path_lookup of %s faild=>%d\n", path, error);
+               OSD_ERR("path_lookup of %s failed=>%d\n", name, error);
                return ERR_PTR(error);
        }
 
-       inode = nd.path.dentry->d_inode;
+       inode = path.dentry->d_inode;
        error = -EINVAL; /* Not the right device e.g osd_uld_device */
        if (!S_ISCHR(inode->i_mode)) {
                OSD_DEBUG("!S_ISCHR()\n");
@@ -202,15 +202,15 @@ struct osd_dev *osduld_path_lookup(const char *path)
        cdev = inode->i_cdev;
        if (!cdev) {
                OSD_ERR("Before mounting an OSD Based filesystem\n");
-               OSD_ERR("  user-mode must open+close the %s device\n", path);
-               OSD_ERR("  Example: bash: echo < %s\n", path);
+               OSD_ERR("  user-mode must open+close the %s device\n", name);
+               OSD_ERR("  Example: bash: echo < %s\n", name);
                goto out;
        }
 
        /* The Magic wand. Is it our char-dev */
        /* TODO: Support sg devices */
        if (cdev->owner != THIS_MODULE) {
-               OSD_ERR("Error mounting %s - is not an OSD device\n", path);
+               OSD_ERR("Error mounting %s - is not an OSD device\n", name);
                goto out;
        }
 
@@ -220,7 +220,7 @@ struct osd_dev *osduld_path_lookup(const char *path)
        error = 0;
 
 out:
-       path_put(&nd.path);
+       path_put(&path);
        return error ? ERR_PTR(error) : &oud->od;
 }
 EXPORT_SYMBOL(osduld_path_lookup);
index 650a730707b767515ce24e51a37cf2cf3f3fd6f4..1ff9473ea7531999436b20d618ce142853abef3e 100644 (file)
@@ -1282,21 +1282,21 @@ static int gfs2_get_sb(struct file_system_type *fs_type, int flags,
 static struct super_block *get_gfs2_sb(const char *dev_name)
 {
        struct super_block *sb;
-       struct nameidata nd;
+       struct path path;
        int error;
 
-       error = path_lookup(dev_name, LOOKUP_FOLLOW, &nd);
+       error = kern_path(dev_name, LOOKUP_FOLLOW, &path);
        if (error) {
                printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n",
                       dev_name, error);
                return NULL;
        }
-       sb = nd.path.dentry->d_inode->i_sb;
+       sb = path.dentry->d_inode->i_sb;
        if (sb && (sb->s_type == &gfs2_fs_type))
                atomic_inc(&sb->s_active);
        else
                sb = NULL;
-       path_put(&nd.path);
+       path_put(&path);
        return sb;
 }
 
index d4d41b3efc7c9f68ac786c1cae0ad8f1e0fe2c90..ddfb9cccf468aee271c4a84757c5f475a8c47524 100644 (file)
@@ -1720,14 +1720,14 @@ static bool tomoyo_policy_loader_exists(void)
         * policies are not loaded yet.
         * Thus, let do_execve() call this function everytime.
         */
-       struct nameidata nd;
+       struct path path;
 
-       if (path_lookup(tomoyo_loader, LOOKUP_FOLLOW, &nd)) {
+       if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) {
                printk(KERN_INFO "Not activating Mandatory Access Control now "
                       "since %s doesn't exist.\n", tomoyo_loader);
                return false;
        }
-       path_put(&nd.path);
+       path_put(&path);
        return true;
 }
 
index bf8e2b451687fac607d109147c16284375093c09..40927a84cb6e697a24671c36a3527c1645f850a1 100644 (file)
@@ -165,11 +165,11 @@ char *tomoyo_realpath_from_path(struct path *path)
  */
 char *tomoyo_realpath(const char *pathname)
 {
-       struct nameidata nd;
+       struct path path;
 
-       if (pathname && path_lookup(pathname, LOOKUP_FOLLOW, &nd) == 0) {
-               char *buf = tomoyo_realpath_from_path(&nd.path);
-               path_put(&nd.path);
+       if (pathname && kern_path(pathname, LOOKUP_FOLLOW, &path) == 0) {
+               char *buf = tomoyo_realpath_from_path(&path);
+               path_put(&path);
                return buf;
        }
        return NULL;
@@ -184,11 +184,11 @@ char *tomoyo_realpath(const char *pathname)
  */
 char *tomoyo_realpath_nofollow(const char *pathname)
 {
-       struct nameidata nd;
+       struct path path;
 
-       if (pathname && path_lookup(pathname, 0, &nd) == 0) {
-               char *buf = tomoyo_realpath_from_path(&nd.path);
-               path_put(&nd.path);
+       if (pathname && kern_path(pathname, 0, &path) == 0) {
+               char *buf = tomoyo_realpath_from_path(&path);
+               path_put(&path);
                return buf;
        }
        return NULL;