summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2016-05-08 15:08:00 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-07 18:18:55 -0700
commitf97bce9f0c792712767dcff09e46b0617c1462a4 (patch)
tree2bd0f83663f6b9498297f9bd496b2b16c10db659
parente5788f9679c122730e1f9978aa8413516dca7b17 (diff)
downloadlinux-stable-f97bce9f0c792712767dcff09e46b0617c1462a4.tar.gz
linux-stable-f97bce9f0c792712767dcff09e46b0617c1462a4.zip
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>
-rw-r--r--fs/btrfs/extent-tree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e2287c7c10be..95e57320dd75 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4620,7 +4620,7 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
/* Calc the number of the pages we need flush for space reservation */
items = calc_reclaim_items_nr(root, to_reclaim);
- to_reclaim = items * EXTENT_SIZE_PER_ITEM;
+ to_reclaim = (u64)items * EXTENT_SIZE_PER_ITEM;
trans = (struct btrfs_trans_handle *)current->journal_info;
block_rsv = &root->fs_info->delalloc_block_rsv;