Switch open_exec() and sys_uselib() to do_open_filp()
... and make path_lookup_open() static
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
diff --git a/fs/exec.c b/fs/exec.c
index 41ae8e0..895823d 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -105,36 +105,28 @@
SYSCALL_DEFINE1(uselib, const char __user *, library)
{
struct file *file;
- struct nameidata nd;
char *tmp = getname(library);
int error = PTR_ERR(tmp);
- if (!IS_ERR(tmp)) {
- error = path_lookup_open(AT_FDCWD, tmp,
- LOOKUP_FOLLOW, &nd,
- FMODE_READ|FMODE_EXEC);
- putname(tmp);
- }
- if (error)
+ if (IS_ERR(tmp))
goto out;
- error = -EINVAL;
- if (!S_ISREG(nd.path.dentry->d_inode->i_mode))
- goto exit;
-
- error = -EACCES;
- if (nd.path.mnt->mnt_flags & MNT_NOEXEC)
- goto exit;
-
- error = may_open(&nd.path, MAY_READ | MAY_EXEC | MAY_OPEN, 0);
- if (error)
- goto exit;
-
- file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
+ file = do_filp_open(AT_FDCWD, tmp,
+ O_LARGEFILE | O_RDONLY | FMODE_EXEC, 0,
+ MAY_READ | MAY_EXEC | MAY_OPEN);
+ putname(tmp);
error = PTR_ERR(file);
if (IS_ERR(file))
goto out;
+ error = -EINVAL;
+ if (!S_ISREG(file->f_path.dentry->d_inode->i_mode))
+ goto exit;
+
+ error = -EACCES;
+ if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
+ goto exit;
+
fsnotify_open(file->f_path.dentry);
error = -ENOEXEC;
@@ -156,13 +148,10 @@
}
read_unlock(&binfmt_lock);
}
+exit:
fput(file);
out:
return error;
-exit:
- release_open_intent(&nd);
- path_put(&nd.path);
- goto out;
}
#ifdef CONFIG_MMU
@@ -657,44 +646,33 @@
struct file *open_exec(const char *name)
{
- struct nameidata nd;
struct file *file;
int err;
- err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd,
- FMODE_READ|FMODE_EXEC);
- if (err)
+ file = do_filp_open(AT_FDCWD, name,
+ O_LARGEFILE | O_RDONLY | FMODE_EXEC, 0,
+ MAY_EXEC | MAY_OPEN);
+ if (IS_ERR(file))
goto out;
err = -EACCES;
- if (!S_ISREG(nd.path.dentry->d_inode->i_mode))
- goto out_path_put;
+ if (!S_ISREG(file->f_path.dentry->d_inode->i_mode))
+ goto exit;
- if (nd.path.mnt->mnt_flags & MNT_NOEXEC)
- goto out_path_put;
-
- err = may_open(&nd.path, MAY_EXEC | MAY_OPEN, 0);
- if (err)
- goto out_path_put;
-
- file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
- if (IS_ERR(file))
- return file;
+ if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
+ goto exit;
fsnotify_open(file->f_path.dentry);
err = deny_write_access(file);
- if (err) {
- fput(file);
- goto out;
- }
+ if (err)
+ goto exit;
+out:
return file;
- out_path_put:
- release_open_intent(&nd);
- path_put(&nd.path);
- out:
+exit:
+ fput(file);
return ERR_PTR(err);
}
EXPORT_SYMBOL(open_exec);