Commit 256984a8 authored by Al Viro's avatar Al Viro

[PATCH] preparation to __user_walk_fd cleanup

Almost all users __user_walk_fd() and friends care only about struct path.
Get rid of the few that do not.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f419a2e3
...@@ -365,7 +365,7 @@ static int find_inode(const char __user *dirname, struct nameidata *nd, ...@@ -365,7 +365,7 @@ static int find_inode(const char __user *dirname, struct nameidata *nd,
if (error) if (error)
return error; return error;
/* you can only watch an inode if you have read permissions on it */ /* you can only watch an inode if you have read permissions on it */
error = vfs_permission(nd, MAY_READ); error = inode_permission(nd->path.dentry->d_inode, MAY_READ);
if (error) if (error)
path_put(&nd->path); path_put(&nd->path);
return error; return error;
......
...@@ -251,7 +251,7 @@ static long do_sys_truncate(const char __user * path, loff_t length) ...@@ -251,7 +251,7 @@ static long do_sys_truncate(const char __user * path, loff_t length)
if (error) if (error)
goto dput_and_out; goto dput_and_out;
error = vfs_permission(&nd, MAY_WRITE); error = inode_permission(inode, MAY_WRITE);
if (error) if (error)
goto mnt_drop_write_and_out; goto mnt_drop_write_and_out;
...@@ -426,6 +426,7 @@ out: ...@@ -426,6 +426,7 @@ out:
asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
{ {
struct nameidata nd; struct nameidata nd;
struct inode *inode;
int old_fsuid, old_fsgid; int old_fsuid, old_fsgid;
kernel_cap_t uninitialized_var(old_cap); /* !SECURE_NO_SETUID_FIXUP */ kernel_cap_t uninitialized_var(old_cap); /* !SECURE_NO_SETUID_FIXUP */
int res; int res;
...@@ -461,7 +462,9 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) ...@@ -461,7 +462,9 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
if (res) if (res)
goto out; goto out;
if ((mode & MAY_EXEC) && S_ISREG(nd.path.dentry->d_inode->i_mode)) { inode = nd.path.dentry->d_inode;
if ((mode & MAY_EXEC) && S_ISREG(inode->i_mode)) {
/* /*
* MAY_EXEC on regular files is denied if the fs is mounted * MAY_EXEC on regular files is denied if the fs is mounted
* with the "noexec" flag. * with the "noexec" flag.
...@@ -471,10 +474,9 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) ...@@ -471,10 +474,9 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
goto out_path_release; goto out_path_release;
} }
res = vfs_permission(&nd, mode | MAY_ACCESS); res = inode_permission(inode, mode | MAY_ACCESS);
/* SuS v2 requires we report a read only fs too */ /* SuS v2 requires we report a read only fs too */
if(res || !(mode & S_IWOTH) || if (res || !(mode & S_IWOTH) || special_file(inode->i_mode))
special_file(nd.path.dentry->d_inode->i_mode))
goto out_path_release; goto out_path_release;
/* /*
* This is a rare case where using __mnt_is_readonly() * This is a rare case where using __mnt_is_readonly()
...@@ -515,7 +517,7 @@ asmlinkage long sys_chdir(const char __user * filename) ...@@ -515,7 +517,7 @@ asmlinkage long sys_chdir(const char __user * filename)
if (error) if (error)
goto out; goto out;
error = vfs_permission(&nd, MAY_EXEC | MAY_ACCESS); error = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_ACCESS);
if (error) if (error)
goto dput_and_out; goto dput_and_out;
...@@ -544,7 +546,7 @@ asmlinkage long sys_fchdir(unsigned int fd) ...@@ -544,7 +546,7 @@ asmlinkage long sys_fchdir(unsigned int fd)
if (!S_ISDIR(inode->i_mode)) if (!S_ISDIR(inode->i_mode))
goto out_putf; goto out_putf;
error = file_permission(file, MAY_EXEC | MAY_ACCESS); error = inode_permission(inode, MAY_EXEC | MAY_ACCESS);
if (!error) if (!error)
set_fs_pwd(current->fs, &file->f_path); set_fs_pwd(current->fs, &file->f_path);
out_putf: out_putf:
...@@ -562,7 +564,7 @@ asmlinkage long sys_chroot(const char __user * filename) ...@@ -562,7 +564,7 @@ asmlinkage long sys_chroot(const char __user * filename)
if (error) if (error)
goto out; goto out;
error = vfs_permission(&nd, MAY_EXEC | MAY_ACCESS); error = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_ACCESS);
if (error) if (error)
goto dput_and_out; goto dput_and_out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment