diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ioctl.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 0e92e576300..7011871c45b 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -2340,6 +2340,10 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2340 | goto out_drop_write; | 2340 | goto out_drop_write; |
2341 | } | 2341 | } |
2342 | 2342 | ||
2343 | ret = -EXDEV; | ||
2344 | if (src_file->f_path.mnt != file->f_path.mnt) | ||
2345 | goto out_fput; | ||
2346 | |||
2343 | src = src_file->f_dentry->d_inode; | 2347 | src = src_file->f_dentry->d_inode; |
2344 | 2348 | ||
2345 | ret = -EINVAL; | 2349 | ret = -EINVAL; |
@@ -2360,7 +2364,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2360 | goto out_fput; | 2364 | goto out_fput; |
2361 | 2365 | ||
2362 | ret = -EXDEV; | 2366 | ret = -EXDEV; |
2363 | if (src->i_sb != inode->i_sb || BTRFS_I(src)->root != root) | 2367 | if (src->i_sb != inode->i_sb) |
2364 | goto out_fput; | 2368 | goto out_fput; |
2365 | 2369 | ||
2366 | ret = -ENOMEM; | 2370 | ret = -ENOMEM; |
@@ -2434,13 +2438,14 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2434 | * note the key will change type as we walk through the | 2438 | * note the key will change type as we walk through the |
2435 | * tree. | 2439 | * tree. |
2436 | */ | 2440 | */ |
2437 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | 2441 | ret = btrfs_search_slot(NULL, BTRFS_I(src)->root, &key, path, |
2442 | 0, 0); | ||
2438 | if (ret < 0) | 2443 | if (ret < 0) |
2439 | goto out; | 2444 | goto out; |
2440 | 2445 | ||
2441 | nritems = btrfs_header_nritems(path->nodes[0]); | 2446 | nritems = btrfs_header_nritems(path->nodes[0]); |
2442 | if (path->slots[0] >= nritems) { | 2447 | if (path->slots[0] >= nritems) { |
2443 | ret = btrfs_next_leaf(root, path); | 2448 | ret = btrfs_next_leaf(BTRFS_I(src)->root, path); |
2444 | if (ret < 0) | 2449 | if (ret < 0) |
2445 | goto out; | 2450 | goto out; |
2446 | if (ret > 0) | 2451 | if (ret > 0) |