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:
  [PATCH] pass struct path * to do_add_mount()
  [PATCH] switch mtd and dm-table to lookup_bdev()
  [patch 3/4] vfs: remove unused nameidata argument of may_create()
  [PATCH] devpts: switch to IDA
  [PATCH 2/2] proc: switch inode number allocation to IDA
  [PATCH 1/2] proc: fix inode number bogorithmetic
  [PATCH] fix bdev leak in block_dev.c do_open()
  [PATCH] fix races and leaks in vfs_quota_on() users
  [PATCH] clean dup2() up a bit
  [PATCH] merge locate_fd() and get_unused_fd()
  [PATCH] ipv4_static_sysctl_init() should be under CONFIG_SYSCTL
  Re: BUG at security/selinux/avc.c:883 (was: Re: linux-next: Tree
  • Loading branch information
torvalds committed Aug 1, 2008
2 parents a8086ad + 8d66bf5 commit d65f5c5
Show file tree
Hide file tree
Showing 21 changed files with 203 additions and 268 deletions.
29 changes: 6 additions & 23 deletions drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,29 +316,12 @@ static inline int check_space(struct dm_table *t)
*/
static int lookup_device(const char *path, dev_t *dev)
{
int r;
struct nameidata nd;
struct inode *inode;

if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd)))
return r;

inode = nd.path.dentry->d_inode;
if (!inode) {
r = -ENOENT;
goto out;
}

if (!S_ISBLK(inode->i_mode)) {
r = -ENOTBLK;
goto out;
}

*dev = inode->i_rdev;

out:
path_put(&nd.path);
return r;
struct block_device *bdev = lookup_bdev(path);
if (IS_ERR(bdev))
return PTR_ERR(bdev);
*dev = bdev->bd_dev;
bdput(bdev);
return 0;
}

/*
Expand Down
33 changes: 11 additions & 22 deletions drivers/mtd/mtdsuper.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
int (*fill_super)(struct super_block *, void *, int),
struct vfsmount *mnt)
{
struct nameidata nd;
struct block_device *bdev;
int mtdnr, ret;

if (!dev_name)
Expand Down Expand Up @@ -181,29 +181,20 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
/* try the old way - the hack where we allowed users to mount
* /dev/mtdblock$(n) but didn't actually _use_ the blockdev
*/
ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd);

DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n",
ret, nd.path.dentry ? nd.path.dentry->d_inode : NULL);

if (ret)
bdev = lookup_bdev(dev_name);
if (IS_ERR(bdev)) {
ret = PTR_ERR(bdev);
DEBUG(1, "MTDSB: lookup_bdev() returned %d\n", ret);
return ret;

ret = -EINVAL;

if (!S_ISBLK(nd.path.dentry->d_inode->i_mode))
goto out;

if (nd.path.mnt->mnt_flags & MNT_NODEV) {
ret = -EACCES;
goto out;
}
DEBUG(1, "MTDSB: lookup_bdev() returned 0\n");

if (imajor(nd.path.dentry->d_inode) != MTD_BLOCK_MAJOR)
ret = -EINVAL;
if (MAJOR(bdev->bd_dev) != MTD_BLOCK_MAJOR)
goto not_an_MTD_device;

mtdnr = iminor(nd.path.dentry->d_inode);
path_put(&nd.path);
mtdnr = MINOR(bdev->bd_dev);
bdput(bdev);

return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super,
mnt);
Expand All @@ -213,10 +204,8 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
printk(KERN_NOTICE
"MTD: Attempt to mount non-MTD device \"%s\"\n",
dev_name);
out:
path_put(&nd.path);
bdput(bdev);
return ret;

}

EXPORT_SYMBOL_GPL(get_sb_mtd);
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/mntpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
}

mntget(newmnt);
err = do_add_mount(newmnt, nd, MNT_SHRINKABLE, &afs_vfsmounts);
err = do_add_mount(newmnt, &nd->path, MNT_SHRINKABLE, &afs_vfsmounts);
switch (err) {
case 0:
path_put(&nd->path);
Expand Down
5 changes: 4 additions & 1 deletion fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,10 @@ static int do_open(struct block_device *bdev, struct file *file, int for_part)
* hooks: /n/, see "layering violations".
*/
ret = devcgroup_inode_permission(bdev->bd_inode, perm);
if (ret != 0)
if (ret != 0) {
bdput(bdev);
return ret;
}

ret = -ENXIO;
file->f_mapping = bdev->bd_inode->i_mapping;
Expand Down Expand Up @@ -1234,6 +1236,7 @@ struct block_device *lookup_bdev(const char *path)
bdev = ERR_PTR(error);
goto out;
}
EXPORT_SYMBOL(lookup_bdev);

/**
* open_bdev_excl - open a block device by name and set it up for use
Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/cifs_dfs_ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static int add_mount_helper(struct vfsmount *newmnt, struct nameidata *nd,
int err;

mntget(newmnt);
err = do_add_mount(newmnt, nd, nd->path.mnt->mnt_flags, mntlist);
err = do_add_mount(newmnt, &nd->path, nd->path.mnt->mnt_flags, mntlist);
switch (err) {
case 0:
path_put(&nd->path);
Expand Down
16 changes: 8 additions & 8 deletions fs/devpts/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define DEVPTS_DEFAULT_MODE 0600

extern int pty_limit; /* Config limit on Unix98 ptys */
static DEFINE_IDR(allocated_ptys);
static DEFINE_IDA(allocated_ptys);
static DEFINE_MUTEX(allocated_ptys_lock);

static struct vfsmount *devpts_mnt;
Expand Down Expand Up @@ -180,24 +180,24 @@ static struct dentry *get_node(int num)
int devpts_new_index(void)
{
int index;
int idr_ret;
int ida_ret;

retry:
if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) {
if (!ida_pre_get(&allocated_ptys, GFP_KERNEL)) {
return -ENOMEM;
}

mutex_lock(&allocated_ptys_lock);
idr_ret = idr_get_new(&allocated_ptys, NULL, &index);
if (idr_ret < 0) {
ida_ret = ida_get_new(&allocated_ptys, &index);
if (ida_ret < 0) {
mutex_unlock(&allocated_ptys_lock);
if (idr_ret == -EAGAIN)
if (ida_ret == -EAGAIN)
goto retry;
return -EIO;
}

if (index >= pty_limit) {
idr_remove(&allocated_ptys, index);
ida_remove(&allocated_ptys, index);
mutex_unlock(&allocated_ptys_lock);
return -EIO;
}
Expand All @@ -208,7 +208,7 @@ int devpts_new_index(void)
void devpts_kill_index(int idx)
{
mutex_lock(&allocated_ptys_lock);
idr_remove(&allocated_ptys, idx);
ida_remove(&allocated_ptys, idx);
mutex_unlock(&allocated_ptys_lock);
}

Expand Down
33 changes: 20 additions & 13 deletions fs/dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,21 @@ static int vfs_quota_on_remount(struct super_block *sb, int type)
return ret;
}

int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
struct path *path)
{
int error = security_quota_on(path->dentry);
if (error)
return error;
/* Quota file not on the same filesystem? */
if (path->mnt->mnt_sb != sb)
error = -EXDEV;
else
error = vfs_quota_on_inode(path->dentry->d_inode, type,
format_id);
return error;
}

/* Actual function called from quotactl() */
int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path,
int remount)
Expand All @@ -1804,19 +1819,10 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path,
return vfs_quota_on_remount(sb, type);

error = path_lookup(path, LOOKUP_FOLLOW, &nd);
if (error < 0)
return error;
error = security_quota_on(nd.path.dentry);
if (error)
goto out_path;
/* Quota file not on the same filesystem? */
if (nd.path.mnt->mnt_sb != sb)
error = -EXDEV;
else
error = vfs_quota_on_inode(nd.path.dentry->d_inode, type,
format_id);
out_path:
path_put(&nd.path);
if (!error) {
error = vfs_quota_on_path(sb, type, format_id, &nd.path);
path_put(&nd.path);
}
return error;
}

Expand Down Expand Up @@ -2185,6 +2191,7 @@ EXPORT_SYMBOL(unregister_quota_format);
EXPORT_SYMBOL(dqstats);
EXPORT_SYMBOL(dq_data_lock);
EXPORT_SYMBOL(vfs_quota_on);
EXPORT_SYMBOL(vfs_quota_on_path);
EXPORT_SYMBOL(vfs_quota_on_mount);
EXPORT_SYMBOL(vfs_quota_off);
EXPORT_SYMBOL(vfs_quota_sync);
Expand Down
3 changes: 2 additions & 1 deletion fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2810,8 +2810,9 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
journal_unlock_updates(EXT3_SB(sb)->s_journal);
}

err = vfs_quota_on_path(sb, type, format_id, &nd.path);
path_put(&nd.path);
return vfs_quota_on(sb, type, format_id, path, remount);
return err;
}

/* Read data from quotafile - avoid pagecache and such because we cannot afford
Expand Down
3 changes: 2 additions & 1 deletion fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -3352,8 +3352,9 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
}

err = vfs_quota_on_path(sb, type, format_id, &nd.path);
path_put(&nd.path);
return vfs_quota_on(sb, type, format_id, path, remount);
return err;
}

/* Read data from quotafile - avoid pagecache and such because we cannot afford
Expand Down
Loading

0 comments on commit d65f5c5

Please sign in to comment.