Revert "fs: add file and path permissions helpers"
This reverts commit ef696bd15f
.
This commit is contained in:
parent
f7566e9585
commit
bfc0293419
13 changed files with 16 additions and 24 deletions
|
@ -49,7 +49,7 @@ int __init init_chdir(const char *filename)
|
|||
error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
|
||||
if (error)
|
||||
return error;
|
||||
error = path_permission(&path, MAY_EXEC | MAY_CHDIR);
|
||||
error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
|
||||
if (!error)
|
||||
set_fs_pwd(current->fs, &path);
|
||||
path_put(&path);
|
||||
|
@ -64,7 +64,7 @@ int __init init_chroot(const char *filename)
|
|||
error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
|
||||
if (error)
|
||||
return error;
|
||||
error = path_permission(&path, MAY_EXEC | MAY_CHDIR);
|
||||
error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
|
||||
if (error)
|
||||
goto dput_and_out;
|
||||
error = -EPERM;
|
||||
|
@ -118,7 +118,7 @@ int __init init_eaccess(const char *filename)
|
|||
error = kern_path(filename, LOOKUP_FOLLOW, &path);
|
||||
if (error)
|
||||
return error;
|
||||
error = path_permission(&path, MAY_ACCESS);
|
||||
error = inode_permission(d_inode(path.dentry), MAY_ACCESS);
|
||||
path_put(&path);
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -973,7 +973,7 @@ static int fanotify_find_path(int dfd, const char __user *filename,
|
|||
}
|
||||
|
||||
/* you can only watch an inode if you have read permissions on it */
|
||||
ret = path_permission(path, MAY_READ);
|
||||
ret = inode_permission(path->dentry->d_inode, MAY_READ);
|
||||
if (ret) {
|
||||
path_put(path);
|
||||
goto out;
|
||||
|
|
|
@ -366,7 +366,7 @@ static int inotify_find_inode(const char __user *dirname, struct path *path,
|
|||
if (error)
|
||||
return error;
|
||||
/* you can only watch an inode if you have read permissions on it */
|
||||
error = path_permission(path, MAY_READ);
|
||||
error = inode_permission(path->dentry->d_inode, MAY_READ);
|
||||
if (error) {
|
||||
path_put(path);
|
||||
return error;
|
||||
|
|
|
@ -493,7 +493,7 @@ retry:
|
|||
if (error)
|
||||
goto out;
|
||||
|
||||
error = path_permission(&path, MAY_EXEC | MAY_CHDIR);
|
||||
error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
|
||||
if (error)
|
||||
goto dput_and_out;
|
||||
|
||||
|
@ -522,7 +522,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
|
|||
if (!d_can_lookup(f.file->f_path.dentry))
|
||||
goto out_putf;
|
||||
|
||||
error = file_permission(f.file, MAY_EXEC | MAY_CHDIR);
|
||||
error = inode_permission(file_inode(f.file), MAY_EXEC | MAY_CHDIR);
|
||||
if (!error)
|
||||
set_fs_pwd(current->fs, &f.file->f_path);
|
||||
out_putf:
|
||||
|
@ -541,7 +541,7 @@ retry:
|
|||
if (error)
|
||||
goto out;
|
||||
|
||||
error = path_permission(&path, MAY_EXEC | MAY_CHDIR);
|
||||
error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
|
||||
if (error)
|
||||
goto dput_and_out;
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||
long old_block, new_block;
|
||||
int result;
|
||||
|
||||
if (file_permission(filp, MAY_READ) != 0) {
|
||||
if (inode_permission(inode, MAY_READ) != 0) {
|
||||
udf_debug("no permission to access inode %lu\n", inode->i_ino);
|
||||
return -EPERM;
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ int fsverity_ioctl_enable(struct file *filp, const void __user *uarg)
|
|||
* has verity enabled, and to stabilize the data being hashed.
|
||||
*/
|
||||
|
||||
err = file_permission(filp, MAY_WRITE);
|
||||
err = inode_permission(inode, MAY_WRITE);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
|
|
@ -2929,14 +2929,6 @@ static inline int bmap(struct inode *inode, sector_t *block)
|
|||
extern int notify_change(struct dentry *, struct iattr *, struct inode **);
|
||||
extern int inode_permission(struct inode *, int);
|
||||
extern int generic_permission(struct inode *, int);
|
||||
static inline int file_permission(struct file *file, int mask)
|
||||
{
|
||||
return inode_permission(file_inode(file), mask);
|
||||
}
|
||||
static inline int path_permission(const struct path *path, int mask)
|
||||
{
|
||||
return inode_permission(d_inode(path->dentry), mask);
|
||||
}
|
||||
extern int __check_sticky(struct inode *dir, struct inode *inode);
|
||||
|
||||
static inline bool execute_ok(struct inode *inode)
|
||||
|
|
|
@ -507,7 +507,7 @@ static void *bpf_obj_do_get(const char __user *pathname,
|
|||
return ERR_PTR(ret);
|
||||
|
||||
inode = d_backing_inode(path.dentry);
|
||||
ret = path_permission(&path, ACC_MODE(flags));
|
||||
ret = inode_permission(inode, ACC_MODE(flags));
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
|
|
|
@ -1907,7 +1907,7 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
|
|||
if (!S_ISREG(inode->i_mode) || path_noexec(&exe.file->f_path))
|
||||
goto exit;
|
||||
|
||||
err = file_permission(exe.file, MAY_EXEC);
|
||||
err = inode_permission(inode, MAY_EXEC);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
|
|
|
@ -577,7 +577,7 @@ static inline bool can_do_file_pageout(struct vm_area_struct *vma)
|
|||
* opens a side channel.
|
||||
*/
|
||||
return inode_owner_or_capable(file_inode(vma->vm_file)) ||
|
||||
file_permission(vma->vm_file, MAY_WRITE) == 0;
|
||||
inode_permission(file_inode(vma->vm_file), MAY_WRITE) == 0;
|
||||
}
|
||||
|
||||
static long madvise_pageout(struct vm_area_struct *vma,
|
||||
|
|
|
@ -4996,7 +4996,7 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of,
|
|||
|
||||
/* the process need read permission on control file */
|
||||
/* AV: shouldn't we check that it's been opened for read instead? */
|
||||
ret = file_permission(cfile.file, MAY_READ);
|
||||
ret = inode_permission(file_inode(cfile.file), MAY_READ);
|
||||
if (ret < 0)
|
||||
goto out_put_cfile;
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ static inline bool can_do_mincore(struct vm_area_struct *vma)
|
|||
* mappings, which opens a side channel.
|
||||
*/
|
||||
return inode_owner_or_capable(file_inode(vma->vm_file)) ||
|
||||
file_permission(vma->vm_file, MAY_WRITE) == 0;
|
||||
inode_permission(file_inode(vma->vm_file), MAY_WRITE) == 0;
|
||||
}
|
||||
|
||||
static const struct mm_walk_ops mincore_walk_ops = {
|
||||
|
|
|
@ -959,7 +959,7 @@ static struct sock *unix_find_other(struct net *net,
|
|||
if (err)
|
||||
goto fail;
|
||||
inode = d_backing_inode(path.dentry);
|
||||
err = path_permission(&path, MAY_WRITE);
|
||||
err = inode_permission(inode, MAY_WRITE);
|
||||
if (err)
|
||||
goto put_fail;
|
||||
|
||||
|
|
Loading…
Reference in a new issue