btrfs: fix int32 overflow in shrink_delalloc().
authorAdam Borowski <kilobyte@angband.pl>
Sun, 8 May 2016 13:08:00 +0000 (15:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jun 2016 01:18:55 +0000 (18:18 -0700)
commitf97bce9f0c792712767dcff09e46b0617c1462a4
tree2bd0f83663f6b9498297f9bd496b2b16c10db659
parente5788f9679c122730e1f9978aa8413516dca7b17
btrfs: fix int32 overflow in shrink_delalloc().

commit 8eb0dfdbda3f56bf7d248ed87fcc383df114ecbb upstream.

UBSAN: Undefined behaviour in fs/btrfs/extent-tree.c:4623:21
signed integer overflow:
10808 * 262144 cannot be represented in type 'int [8]'

If 8192<=items<16384, we request a writeback of an insane number of pages
which is benign (everything will be written).  But if items>=16384, the
space reservation won't be enough.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
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/extent-tree.c