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:
  reiserfs: fix j_last_flush_trans_id type
  fs: Mark get_filesystem_list() as __init function.
  kill vfs_stat_fd / vfs_lstat_fd
  Separate out common fstatat code into vfs_fstatat
  ecryptfs: use memdup_user()
  ncpfs: use memdup_user()
  xfs: use memdup_user()
  sysfs: use memdup_user()
  btrfs: use memdup_user()
  xattr: use memdup_user()
  autofs4: use memchr() in invalid_string()
  Documentation/filesystems: remove out of date reference to BKL being held
  Fix i_mutex vs. readdir handling in nfsd
  fs/compat_ioctl: fix build when !BLOCK
  Fix autofs_expire()
  No need for crossing to mountpoint in audit_tag_tree()
  Safer nfsd_cross_mnt()
  Touch all affected namespaces on propagation of mount
  Fix AUTOFS_DEV_IOCTL_REQUESTER_CMD
  • Loading branch information
Linus Torvalds committed Apr 21, 2009
2 parents 8b9cf76 + be9208d commit 9a41fe3
Show file tree
Hide file tree
Showing 27 changed files with 207 additions and 351 deletions.
3 changes: 1 addition & 2 deletions Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ or bottom half).
unfreeze_fs: called when VFS is unlocking a filesystem and making it writable
again.

statfs: called when the VFS needs to get filesystem statistics. This
is called with the kernel lock held
statfs: called when the VFS needs to get filesystem statistics.

remount_fs: called when the filesystem is remounted. This is called
with the kernel lock held
Expand Down
19 changes: 5 additions & 14 deletions arch/arm/kernel/sys_oabi-compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,12 @@ asmlinkage long sys_oabi_fstatat64(int dfd,
int flag)
{
struct kstat stat;
int error = -EINVAL;
int error;

if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
goto out;

if (flag & AT_SYMLINK_NOFOLLOW)
error = vfs_lstat_fd(dfd, filename, &stat);
else
error = vfs_stat_fd(dfd, filename, &stat);

if (!error)
error = cp_oldabi_stat64(&stat, statbuf);

out:
return error;
error = vfs_fstatat(dfd, filename, &stat, flag);
if (error)
return error;
return cp_oldabi_stat64(&stat, statbuf);
}

struct oabi_flock64 {
Expand Down
18 changes: 5 additions & 13 deletions arch/s390/kernel/compat_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,20 +702,12 @@ asmlinkage long sys32_fstatat64(unsigned int dfd, char __user *filename,
struct stat64_emu31 __user* statbuf, int flag)
{
struct kstat stat;
int error = -EINVAL;

if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
goto out;

if (flag & AT_SYMLINK_NOFOLLOW)
error = vfs_lstat_fd(dfd, filename, &stat);
else
error = vfs_stat_fd(dfd, filename, &stat);
int error;

if (!error)
error = cp_stat64(statbuf, &stat);
out:
return error;
error = vfs_fstatat(dfd, filename, &stat, flag);
if (error)
return error;
return cp_stat64(statbuf, &stat);
}

/*
Expand Down
19 changes: 5 additions & 14 deletions arch/sparc/kernel/sys_sparc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,12 @@ asmlinkage long compat_sys_fstatat64(unsigned int dfd, char __user *filename,
struct compat_stat64 __user * statbuf, int flag)
{
struct kstat stat;
int error = -EINVAL;

if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
goto out;

if (flag & AT_SYMLINK_NOFOLLOW)
error = vfs_lstat_fd(dfd, filename, &stat);
else
error = vfs_stat_fd(dfd, filename, &stat);

if (!error)
error = cp_compat_stat64(&stat, statbuf);
int error;

out:
return error;
error = vfs_fstatat(dfd, filename, &stat, flag);
if (error)
return error;
return cp_compat_stat64(&stat, statbuf);
}

asmlinkage long compat_sys_sysfs(int option, u32 arg1, u32 arg2)
Expand Down
19 changes: 5 additions & 14 deletions arch/x86/ia32/sys_ia32.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,12 @@ asmlinkage long sys32_fstatat(unsigned int dfd, char __user *filename,
struct stat64 __user *statbuf, int flag)
{
struct kstat stat;
int error = -EINVAL;
int error;

if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
goto out;

if (flag & AT_SYMLINK_NOFOLLOW)
error = vfs_lstat_fd(dfd, filename, &stat);
else
error = vfs_stat_fd(dfd, filename, &stat);

if (!error)
error = cp_stat64(statbuf, &stat);

out:
return error;
error = vfs_fstatat(dfd, filename, &stat, flag);
if (error)
return error;
return cp_stat64(statbuf, &stat);
}

/*
Expand Down
34 changes: 18 additions & 16 deletions fs/autofs/dirhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb,
{
struct autofs_dirhash *dh = &sbi->dirhash;
struct autofs_dir_ent *ent;
struct dentry *dentry;
unsigned long timeout = sbi->exp_timeout;

while (1) {
struct path path;
int umount_ok;

if ( list_empty(&dh->expiry_head) || sbi->catatonic )
return NULL; /* No entries */
/* We keep the list sorted by last_usage and want old stuff */
Expand All @@ -57,17 +59,17 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb,
return ent; /* Symlinks are always expirable */

/* Get the dentry for the autofs subdirectory */
dentry = ent->dentry;
path.dentry = ent->dentry;

if ( !dentry ) {
if (!path.dentry) {
/* Should only happen in catatonic mode */
printk("autofs: dentry == NULL but inode range is directory, entry %s\n", ent->name);
autofs_delete_usage(ent);
continue;
}

if ( !dentry->d_inode ) {
dput(dentry);
if (!path.dentry->d_inode) {
dput(path.dentry);
printk("autofs: negative dentry on expiry queue: %s\n",
ent->name);
autofs_delete_usage(ent);
Expand All @@ -76,29 +78,29 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb,

/* Make sure entry is mounted and unused; note that dentry will
point to the mounted-on-top root. */
if (!S_ISDIR(dentry->d_inode->i_mode)||!d_mountpoint(dentry)) {
if (!S_ISDIR(path.dentry->d_inode->i_mode) ||
!d_mountpoint(path.dentry)) {
DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name));
continue;
}
mntget(mnt);
dget(dentry);
if (!follow_down(&mnt, &dentry)) {
dput(dentry);
mntput(mnt);
path.mnt = mnt;
path_get(&path);
if (!follow_down(&path.mnt, &path.dentry)) {
path_put(&path);
DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name));
continue;
}
while (d_mountpoint(dentry) && follow_down(&mnt, &dentry))
while (d_mountpoint(path.dentry) &&
follow_down(&path.mnt, &path.dentry))
;
dput(dentry);
umount_ok = may_umount(path.mnt);
path_put(&path);

if ( may_umount(mnt) ) {
mntput(mnt);
if (umount_ok) {
DPRINTK(("autofs: signaling expire on %s\n", ent->name));
return ent; /* Expirable! */
}
DPRINTK(("autofs: didn't expire due to may_umount: %s\n", ent->name));
mntput(mnt);
}
return NULL; /* No expirable entries */
}
Expand Down
12 changes: 5 additions & 7 deletions fs/autofs4/dev-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ static int check_name(const char *name)
* Check a string doesn't overrun the chunk of
* memory we copied from user land.
*/
static int invalid_str(char *str, void *end)
static int invalid_str(char *str, size_t size)
{
while ((void *) str <= end)
if (!*str++)
return 0;
if (memchr(str, 0, size))
return 0;
return -EINVAL;
}

Expand Down Expand Up @@ -138,8 +137,7 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
}

if (param->size > sizeof(*param)) {
err = invalid_str(param->path,
(void *) ((size_t) param + param->size));
err = invalid_str(param->path, param->size - sizeof(*param));
if (err) {
AUTOFS_WARN(
"path string terminator missing for cmd(0x%08x)",
Expand Down Expand Up @@ -488,7 +486,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
}

path = param->path;
devid = sbi->sb->s_dev;
devid = new_encode_dev(sbi->sb->s_dev);

param->requester.uid = param->requester.gid = -1;

Expand Down
49 changes: 12 additions & 37 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,9 @@ static int btrfs_ioctl_resize(struct btrfs_root *root, void __user *arg)
if (!capable(CAP_SYS_ADMIN))
return -EPERM;

vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);

if (!vol_args)
return -ENOMEM;

if (copy_from_user(vol_args, arg, sizeof(*vol_args))) {
ret = -EFAULT;
goto out;
}
vol_args = memdup_user(arg, sizeof(*vol_args));
if (IS_ERR(vol_args))
return PTR_ERR(vol_args);

vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
namelen = strlen(vol_args->name);
Expand Down Expand Up @@ -545,7 +539,6 @@ static int btrfs_ioctl_resize(struct btrfs_root *root, void __user *arg)

out_unlock:
mutex_unlock(&root->fs_info->volume_mutex);
out:
kfree(vol_args);
return ret;
}
Expand All @@ -565,15 +558,9 @@ static noinline int btrfs_ioctl_snap_create(struct file *file,
if (root->fs_info->sb->s_flags & MS_RDONLY)
return -EROFS;

vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);

if (!vol_args)
return -ENOMEM;

if (copy_from_user(vol_args, arg, sizeof(*vol_args))) {
ret = -EFAULT;
goto out;
}
vol_args = memdup_user(arg, sizeof(*vol_args));
if (IS_ERR(vol_args))
return PTR_ERR(vol_args);

vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
namelen = strlen(vol_args->name);
Expand Down Expand Up @@ -675,19 +662,13 @@ static long btrfs_ioctl_add_dev(struct btrfs_root *root, void __user *arg)
if (!capable(CAP_SYS_ADMIN))
return -EPERM;

vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);
vol_args = memdup_user(arg, sizeof(*vol_args));
if (IS_ERR(vol_args))
return PTR_ERR(vol_args);

if (!vol_args)
return -ENOMEM;

if (copy_from_user(vol_args, arg, sizeof(*vol_args))) {
ret = -EFAULT;
goto out;
}
vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
ret = btrfs_init_new_device(root, vol_args->name);

out:
kfree(vol_args);
return ret;
}
Expand All @@ -703,19 +684,13 @@ static long btrfs_ioctl_rm_dev(struct btrfs_root *root, void __user *arg)
if (root->fs_info->sb->s_flags & MS_RDONLY)
return -EROFS;

vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS);
vol_args = memdup_user(arg, sizeof(*vol_args));
if (IS_ERR(vol_args))
return PTR_ERR(vol_args);

if (!vol_args)
return -ENOMEM;

if (copy_from_user(vol_args, arg, sizeof(*vol_args))) {
ret = -EFAULT;
goto out;
}
vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
ret = btrfs_rm_device(root, vol_args->name);

out:
kfree(vol_args);
return ret;
}
Expand Down
13 changes: 4 additions & 9 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,22 +635,17 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;

vol = kmalloc(sizeof(*vol), GFP_KERNEL);
if (!vol)
return -ENOMEM;

if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) {
ret = -EFAULT;
goto out;
}
vol = memdup_user((void __user *)arg, sizeof(*vol));
if (IS_ERR(vol))
return PTR_ERR(vol);

switch (cmd) {
case BTRFS_IOC_SCAN_DEV:
ret = btrfs_scan_one_device(vol->name, FMODE_READ,
&btrfs_fs_type, &fs_devices);
break;
}
out:

kfree(vol);
return ret;
}
Expand Down
Loading

0 comments on commit 9a41fe3

Please sign in to comment.