From: Scott Bauer Date: Thu, 28 Jul 2016 01:11:29 +0000 (-0600) Subject: vfs: ioctl: prevent double-fetch in dedupe ioctl X-Git-Tag: v4.6.6~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04678f5598322beecf6f06ddf73b2eb6a8b0ef9a;p=thirdparty%2Fkernel%2Fstable.git vfs: ioctl: prevent double-fetch in dedupe ioctl commit 10eec60ce79187686e052092e5383c99b4420a20 upstream. 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 Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ioctl.c b/fs/ioctl.c index 116a333e9c773..0f56deb24ce65 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -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;