Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable:
  Btrfs: check for read permission on src file in the clone ioctl
  • Loading branch information
Linus Torvalds committed May 15, 2010
2 parents 43aa7ac + 5dc6416 commit 18e41da
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,12 +1481,17 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
ret = -EBADF;
goto out_drop_write;
}

src = src_file->f_dentry->d_inode;

ret = -EINVAL;
if (src == inode)
goto out_fput;

/* the src must be open for reading */
if (!(src_file->f_mode & FMODE_READ))
goto out_fput;

ret = -EISDIR;
if (S_ISDIR(src->i_mode) || S_ISDIR(inode->i_mode))
goto out_fput;
Expand Down

0 comments on commit 18e41da

Please sign in to comment.