Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 125001
b: refs/heads/master
c: cb23beb
h: refs/heads/master
i:
  124999: 8e6e824
v: v3
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Dec 31, 2008
1 parent f8e2ae0 commit afa6616
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3fb64190aa3c23c10e6e9fd0124ac030115c99bf
refs/heads/master: cb23beb55100171646e69e248fb45f10db6e99a4
5 changes: 3 additions & 2 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ asmlinkage long sys_uselib(const char __user * library)
if (nd.path.mnt->mnt_flags & MNT_NOEXEC)
goto exit;

error = vfs_permission(&nd, MAY_READ | MAY_EXEC | MAY_OPEN);
error = inode_permission(nd.path.dentry->d_inode,
MAY_READ | MAY_EXEC | MAY_OPEN);
if (error)
goto exit;

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

err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN);
err = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_OPEN);
if (err)
goto out_path_put;

Expand Down
31 changes: 13 additions & 18 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ int generic_permission(struct inode *inode, int mask,
return -EACCES;
}

/**
* inode_permission - check for access rights to a given inode
* @inode: inode to check permission on
* @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
*
* Used to check for read/write/execute permissions on an inode.
* We use "fsuid" for this, letting us set arbitrary permissions
* for filesystem access without changing the "normal" uids which
* are used for other things.
*/
int inode_permission(struct inode *inode, int mask)
{
int retval;
Expand Down Expand Up @@ -263,21 +273,6 @@ int inode_permission(struct inode *inode, int mask)
mask & (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND));
}

/**
* vfs_permission - check for access rights to a given path
* @nd: lookup result that describes the path
* @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
*
* Used to check for read/write/execute permissions on a path.
* We use "fsuid" for this, letting us set arbitrary permissions
* for filesystem access without changing the "normal" uids which
* are used for other things.
*/
int vfs_permission(struct nameidata *nd, int mask)
{
return inode_permission(nd->path.dentry->d_inode, mask);
}

/**
* file_permission - check for additional access rights to a given file
* @file: file to check access rights for
Expand All @@ -288,7 +283,7 @@ int vfs_permission(struct nameidata *nd, int mask)
*
* Note:
* Do not use this function in new code. All access checks should
* be done using vfs_permission().
* be done using inode_permission().
*/
int file_permission(struct file *file, int mask)
{
Expand Down Expand Up @@ -853,7 +848,8 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
nd->flags |= LOOKUP_CONTINUE;
err = exec_permission_lite(inode);
if (err == -EAGAIN)
err = vfs_permission(nd, MAY_EXEC);
err = inode_permission(nd->path.dentry->d_inode,
MAY_EXEC);
if (err)
break;

Expand Down Expand Up @@ -2882,7 +2878,6 @@ EXPORT_SYMBOL(path_lookup);
EXPORT_SYMBOL(kern_path);
EXPORT_SYMBOL(vfs_path_lookup);
EXPORT_SYMBOL(inode_permission);
EXPORT_SYMBOL(vfs_permission);
EXPORT_SYMBOL(file_permission);
EXPORT_SYMBOL(unlock_rename);
EXPORT_SYMBOL(vfs_create);
Expand Down
1 change: 0 additions & 1 deletion trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,6 @@ extern void unlock_super(struct super_block *);
/*
* VFS helper functions..
*/
extern int vfs_permission(struct nameidata *, int);
extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
extern int vfs_mkdir(struct inode *, struct dentry *, int);
extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
Expand Down

0 comments on commit afa6616

Please sign in to comment.