public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: stable@vger.kernel.org
Subject: [PATCH 13/21] btrfs: fix int32 overflow in shrink_delalloc().
Date: Fri,  3 Jun 2016 17:42:35 +0200	[thread overview]
Message-ID: <1464968555-6771-1-git-send-email-dsterba@suse.com> (raw)
In-Reply-To: <20160603154006.GP29147@suse.cz>

From: Adam Borowski <kilobyte@angband.pl>

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>
---
 fs/btrfs/extent-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.7.1


  parent reply	other threads:[~2016-06-03 15:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03 15:40 Btrfs stable patches for 4.5.x David Sterba
2016-06-03 15:42 ` [PATCH 01/21] btrfs: bugfix: handle FS_IOC32_{GETFLAGS,SETFLAGS,GETVERSION} in btrfs_ioctl David Sterba
2016-06-03 15:42 ` [PATCH 02/21] Btrfs: do not create empty block group if we have allocated data David Sterba
2016-06-03 15:42 ` [PATCH 03/21] btrfs: allow balancing to dup with multi-device David Sterba
2016-06-03 15:42 ` [PATCH 04/21] btrfs: fix mixed block count of available space David Sterba
2016-06-03 15:42 ` [PATCH 05/21] btrfs: avoid overflowing f_bfree David Sterba
2016-06-03 15:42 ` [PATCH 06/21] btrfs: fix lock dep warning, move scratch dev out of device_list_mutex and uuid_mutex David Sterba
2016-06-03 15:42 ` [PATCH 07/21] btrfs: add read-only check to sysfs handler of features David Sterba
2016-06-03 15:42 ` [PATCH 08/21] btrfs: add check to sysfs handler of label David Sterba
2016-06-03 15:42 ` [PATCH 09/21] Btrfs: fix divide error upon chunk's stripe_len David Sterba
2016-06-03 15:42 ` [PATCH 10/21] Btrfs: remove BUG_ON()'s in btrfs_map_block David Sterba
2016-06-03 15:42 ` [PATCH 11/21] btrfs: fix lock dep warning move scratch super outside of chunk_mutex David Sterba
2016-06-03 15:42 ` [PATCH 12/21] btrfs: add write protection to SET_FEATURES ioctl David Sterba
2016-06-03 15:42 ` David Sterba [this message]
2016-06-03 15:42 ` [PATCH 14/21] Btrfs: fix fspath error deallocation David Sterba
2016-06-03 15:42 ` [PATCH 15/21] btrfs: fix memory leak during RAID 5/6 device replacement David Sterba
2016-06-03 15:42 ` [PATCH 16/21] btrfs: pass the right error code to the btrfs_std_error David Sterba
2016-06-03 15:42 ` [PATCH 17/21] Btrfs: fix for incorrect directory entries after fsync log replay David Sterba
2016-06-03 15:42 ` [PATCH 18/21] Btrfs: fix empty symlink after creating symlink and fsync parent dir David Sterba
2016-06-03 15:42 ` [PATCH 19/21] Btrfs: fix unexpected return value of fiemap David Sterba
2016-06-03 15:42 ` [PATCH 20/21] btrfs: scrub: Set bbio to NULL before calling btrfs_map_block David Sterba
2016-06-03 15:42 ` [PATCH 21/21] btrfs: make state preallocation more speculative in __set_extent_bit David Sterba
2016-06-05 21:48 ` Btrfs stable patches for 4.5.x Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464968555-6771-1-git-send-email-dsterba@suse.com \
    --to=dsterba@suse.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox