Skip to content

Commit

Permalink
Btrfs: Fix BTRFS_IOC_SUBVOL_SETFLAGS ioctl
Browse files Browse the repository at this point in the history
- Check user-specified flags correctly
- Check the inode owership
- Search root item in root tree but not fs tree

Reported-by: Dan Rosenberg <drosenberg@vsecurity.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Li Zefan authored and Chris Mason committed Feb 16, 2011
1 parent c87f08c commit b4dc2b8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,12 +1071,15 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
if (copy_from_user(&flags, arg, sizeof(flags)))
return -EFAULT;

if (flags & ~BTRFS_SUBVOL_CREATE_ASYNC)
if (flags & BTRFS_SUBVOL_CREATE_ASYNC)
return -EINVAL;

if (flags & ~BTRFS_SUBVOL_RDONLY)
return -EOPNOTSUPP;

if (!is_owner_or_cap(inode))
return -EACCES;

down_write(&root->fs_info->subvol_sem);

/* nothing to do */
Expand All @@ -1097,7 +1100,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
goto out_reset;
}

ret = btrfs_update_root(trans, root,
ret = btrfs_update_root(trans, root->fs_info->tree_root,
&root->root_key, &root->root_item);

btrfs_commit_transaction(trans, root);
Expand Down

0 comments on commit b4dc2b8

Please sign in to comment.