Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
  devcgroup_inode_permission: take "is it a device node" checks to inlined wrapper
  fix comment in generic_permission()
  kill obsolete comment for follow_down()
  proc_sys_permission() is OK in RCU mode
  reiserfs_permission() doesn't need to bail out in RCU mode
  proc_fd_permission() is doesn't need to bail out in RCU mode
  nilfs2_permission() doesn't need to bail out in RCU mode
  logfs doesn't need ->permission() at all
  coda_ioctl_permission() is safe in RCU mode
  cifs_permission() doesn't need to bail out in RCU mode
  bad_inode_permission() is safe from RCU mode
  ubifs: dereferencing an ERR_PTR in ubifs_mount()
  • Loading branch information
torvalds committed Jun 21, 2011
2 parents ef46222 + 482e0cd commit 3669820
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 44 deletions.
3 changes: 0 additions & 3 deletions fs/bad_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,

static int bad_inode_permission(struct inode *inode, int mask, unsigned int flags)
{
if (flags & IPERM_FLAG_RCU)
return -ECHILD;

return -EIO;
}

Expand Down
3 changes: 0 additions & 3 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@ static int cifs_permission(struct inode *inode, int mask, unsigned int flags)
{
struct cifs_sb_info *cifs_sb;

if (flags & IPERM_FLAG_RCU)
return -ECHILD;

cifs_sb = CIFS_SB(inode->i_sb);

if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
Expand Down
2 changes: 0 additions & 2 deletions fs/coda/pioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ const struct file_operations coda_ioctl_operations = {
/* the coda pioctl inode ops */
static int coda_ioctl_permission(struct inode *inode, int mask, unsigned int flags)
{
if (flags & IPERM_FLAG_RCU)
return -ECHILD;
return (mask & MAY_EXEC) ? -EACCES : 0;
}

Expand Down
8 changes: 0 additions & 8 deletions fs/logfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,6 @@ static int logfs_symlink(struct inode *dir, struct dentry *dentry,
return __logfs_create(dir, dentry, inode, target, destlen);
}

static int logfs_permission(struct inode *inode, int mask, unsigned int flags)
{
if (flags & IPERM_FLAG_RCU)
return -ECHILD;
return generic_permission(inode, mask, flags, NULL);
}

static int logfs_link(struct dentry *old_dentry, struct inode *dir,
struct dentry *dentry)
{
Expand Down Expand Up @@ -820,7 +813,6 @@ const struct inode_operations logfs_dir_iops = {
.mknod = logfs_mknod,
.rename = logfs_rename,
.rmdir = logfs_rmdir,
.permission = logfs_permission,
.symlink = logfs_symlink,
.unlink = logfs_unlink,
};
Expand Down
6 changes: 2 additions & 4 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ int generic_permission(struct inode *inode, int mask, unsigned int flags,

/*
* Read/write DACs are always overridable.
* Executable DACs are overridable if at least one exec bit is set.
* Executable DACs are overridable for all directories and
* for non-directories that have least one exec bit set.
*/
if (!(mask & MAY_EXEC) || execute_ok(inode))
if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE))
Expand Down Expand Up @@ -1011,9 +1012,6 @@ static int follow_dotdot_rcu(struct nameidata *nd)
* Follow down to the covering mount currently visible to userspace. At each
* point, the filesystem owning that dentry may be queried as to whether the
* caller is permitted to proceed or not.
*
* Care must be taken as namespace_sem may be held (indicated by mounting_here
* being true).
*/
int follow_down(struct path *path)
{
Expand Down
7 changes: 1 addition & 6 deletions fs/nilfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,12 +801,7 @@ int nilfs_setattr(struct dentry *dentry, struct iattr *iattr)

int nilfs_permission(struct inode *inode, int mask, unsigned int flags)
{
struct nilfs_root *root;

if (flags & IPERM_FLAG_RCU)
return -ECHILD;

root = NILFS_I(inode)->i_root;
struct nilfs_root *root = NILFS_I(inode)->i_root;
if ((mask & MAY_WRITE) && root &&
root->cno != NILFS_CPTREE_CURRENT_CNO)
return -EROFS; /* snapshot is not writable */
Expand Down
6 changes: 1 addition & 5 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2169,11 +2169,7 @@ static const struct file_operations proc_fd_operations = {
*/
static int proc_fd_permission(struct inode *inode, int mask, unsigned int flags)
{
int rv;

if (flags & IPERM_FLAG_RCU)
return -ECHILD;
rv = generic_permission(inode, mask, flags, NULL);
int rv = generic_permission(inode, mask, flags, NULL);
if (rv == 0)
return 0;
if (task_pid(current) == proc_pid(inode))
Expand Down
3 changes: 0 additions & 3 deletions fs/proc/proc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,6 @@ static int proc_sys_permission(struct inode *inode, int mask,unsigned int flags)
struct ctl_table *table;
int error;

if (flags & IPERM_FLAG_RCU)
return -ECHILD;

/* Executable files are not allowed under /proc/sys/ */
if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))
return -EACCES;
Expand Down
2 changes: 0 additions & 2 deletions fs/reiserfs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,6 @@ static int xattr_mount_check(struct super_block *s)

int reiserfs_permission(struct inode *inode, int mask, unsigned int flags)
{
if (flags & IPERM_FLAG_RCU)
return -ECHILD;
/*
* We don't do permission checks on the internal objects.
* Permissions are determined by the "owning" object.
Expand Down
1 change: 1 addition & 0 deletions fs/ubifs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,7 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
if (IS_ERR(sb)) {
err = PTR_ERR(sb);
kfree(c);
goto out_close;
}

if (sb->s_root) {
Expand Down
10 changes: 9 additions & 1 deletion include/linux/device_cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
#include <linux/fs.h>

#ifdef CONFIG_CGROUP_DEVICE
extern int devcgroup_inode_permission(struct inode *inode, int mask);
extern int __devcgroup_inode_permission(struct inode *inode, int mask);
extern int devcgroup_inode_mknod(int mode, dev_t dev);
static inline int devcgroup_inode_permission(struct inode *inode, int mask)
{
if (likely(!inode->i_rdev))
return 0;
if (!S_ISBLK(inode->i_mode) && !S_ISCHR(inode->i_mode))
return 0;
return __devcgroup_inode_permission(inode, mask);
}
#else
static inline int devcgroup_inode_permission(struct inode *inode, int mask)
{ return 0; }
Expand Down
8 changes: 1 addition & 7 deletions security/device_cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,17 +474,11 @@ struct cgroup_subsys devices_subsys = {
.subsys_id = devices_subsys_id,
};

int devcgroup_inode_permission(struct inode *inode, int mask)
int __devcgroup_inode_permission(struct inode *inode, int mask)
{
struct dev_cgroup *dev_cgroup;
struct dev_whitelist_item *wh;

dev_t device = inode->i_rdev;
if (!device)
return 0;
if (!S_ISBLK(inode->i_mode) && !S_ISCHR(inode->i_mode))
return 0;

rcu_read_lock();

dev_cgroup = task_devcgroup(current);
Expand Down

0 comments on commit 3669820

Please sign in to comment.