vfs: ioctl: prevent double-fetch in dedupe ioctl
authorScott Bauer <sbauer@plzdonthack.me>
Thu, 28 Jul 2016 01:11:29 +0000 (19:11 -0600)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Jul 2016 22:23:12 +0000 (15:23 -0700)
This prevents a double-fetch from user space that can lead to to an
undersized allocation and heap overflow.

Fixes: 54dbc1517237 ("vfs: hoist the btrfs deduplication ioctl to the vfs")
Signed-off-by: Scott Bauer <sbauer@plzdonthack.me>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ioctl.c

index 116a333..0f56deb 100644 (file)
@@ -590,6 +590,7 @@ static long ioctl_file_dedupe_range(struct file *file, void __user *arg)
                goto out;
        }
 
+       same->dest_count = count;
        ret = vfs_dedupe_file_range(file, same);
        if (ret)
                goto out;