btrfs: validate qgroup inherit for SNAP_CREATE_V2 ioctl
authorDan Carpenter <dancarpenter@oracle.com>
Wed, 17 Feb 2021 06:04:34 +0000 (09:04 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Mar 2021 10:11:11 +0000 (11:11 +0100)
commita64ad80223f2173df2737a49148d2566b808f484
tree2e354067de5a2ad9c93b869430ddb001df66b33e
parente82407d24968531d636fc5d544715c86675f62e6
btrfs: validate qgroup inherit for SNAP_CREATE_V2 ioctl

commit 5011c5a663b9c6d6aff3d394f11049b371199627 upstream.

The problem is we're copying "inherit" from user space but we don't
necessarily know that we're copying enough data for a 64 byte
struct.  Then the next problem is that 'inherit' has a variable size
array at the end, and we have to verify that array is the size we
expected.

Fixes: 6f72c7e20dba ("Btrfs: add qgroup inheritance")
CC: stable@vger.kernel.org # 4.4+
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ioctl.c