Skip to content

Commit cb23beb

Browse files
Christoph HellwigAl Viro
authored andcommitted
kill vfs_permission
With all the nameidata removal there's no point anymore for this helper. Of the three callers left two will go away with the next lookup series anyway. Also add proper kerneldoc to inode_permission as this is the main permission check routine now. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 3fb6419 commit cb23beb

3 files changed

Lines changed: 16 additions & 21 deletions

File tree

‎fs/exec.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ asmlinkage long sys_uselib(const char __user * library)
127127
if (nd.path.mnt->mnt_flags & MNT_NOEXEC)
128128
goto exit;
129129

130-
error = vfs_permission(&nd, MAY_READ | MAY_EXEC | MAY_OPEN);
130+
error = inode_permission(nd.path.dentry->d_inode,
131+
MAY_READ | MAY_EXEC | MAY_OPEN);
131132
if (error)
132133
goto exit;
133134

@@ -680,7 +681,7 @@ struct file *open_exec(const char *name)
680681
if (nd.path.mnt->mnt_flags & MNT_NOEXEC)
681682
goto out_path_put;
682683

683-
err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN);
684+
err = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_OPEN);
684685
if (err)
685686
goto out_path_put;
686687

‎fs/namei.c‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ int generic_permission(struct inode *inode, int mask,
226226
return -EACCES;
227227
}
228228

229+
/**
230+
* inode_permission - check for access rights to a given inode
231+
* @inode: inode to check permission on
232+
* @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
233+
*
234+
* Used to check for read/write/execute permissions on an inode.
235+
* We use "fsuid" for this, letting us set arbitrary permissions
236+
* for filesystem access without changing the "normal" uids which
237+
* are used for other things.
238+
*/
229239
int inode_permission(struct inode *inode, int mask)
230240
{
231241
int retval;
@@ -263,21 +273,6 @@ int inode_permission(struct inode *inode, int mask)
263273
mask & (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND));
264274
}
265275

266-
/**
267-
* vfs_permission - check for access rights to a given path
268-
* @nd: lookup result that describes the path
269-
* @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
270-
*
271-
* Used to check for read/write/execute permissions on a path.
272-
* We use "fsuid" for this, letting us set arbitrary permissions
273-
* for filesystem access without changing the "normal" uids which
274-
* are used for other things.
275-
*/
276-
int vfs_permission(struct nameidata *nd, int mask)
277-
{
278-
return inode_permission(nd->path.dentry->d_inode, mask);
279-
}
280-
281276
/**
282277
* file_permission - check for additional access rights to a given file
283278
* @file: file to check access rights for
@@ -288,7 +283,7 @@ int vfs_permission(struct nameidata *nd, int mask)
288283
*
289284
* Note:
290285
* Do not use this function in new code. All access checks should
291-
* be done using vfs_permission().
286+
* be done using inode_permission().
292287
*/
293288
int file_permission(struct file *file, int mask)
294289
{
@@ -853,7 +848,8 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
853848
nd->flags |= LOOKUP_CONTINUE;
854849
err = exec_permission_lite(inode);
855850
if (err == -EAGAIN)
856-
err = vfs_permission(nd, MAY_EXEC);
851+
err = inode_permission(nd->path.dentry->d_inode,
852+
MAY_EXEC);
857853
if (err)
858854
break;
859855

@@ -2882,7 +2878,6 @@ EXPORT_SYMBOL(path_lookup);
28822878
EXPORT_SYMBOL(kern_path);
28832879
EXPORT_SYMBOL(vfs_path_lookup);
28842880
EXPORT_SYMBOL(inode_permission);
2885-
EXPORT_SYMBOL(vfs_permission);
28862881
EXPORT_SYMBOL(file_permission);
28872882
EXPORT_SYMBOL(unlock_rename);
28882883
EXPORT_SYMBOL(vfs_create);

‎include/linux/fs.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,6 @@ extern void unlock_super(struct super_block *);
12121212
/*
12131213
* VFS helper functions..
12141214
*/
1215-
extern int vfs_permission(struct nameidata *, int);
12161215
extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
12171216
extern int vfs_mkdir(struct inode *, struct dentry *, int);
12181217
extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);

0 commit comments

Comments
 (0)