Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1415146
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4.5 117/128] Btrfs: remove BUG_ON()s in btrfs_map_block |
| Date | 2016-06-06 16:40 +0200 |
| Message-ID | <rH3R9-68Z-69@gated-at.bofh.it> (permalink) |
| References | <rGOIq-4dq-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
4.5-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <jbacik@fb.com>
commit e042d1ec4417981dfe9331e47b76f17929bc2ffe upstream.
btrfs_map_block can go horribly wrong in the face of fs corruption, lets agree
to not be assholes and panic at any possible chance things are all fucked up.
Signed-off-by: Josef Bacik <jbacik@fb.com>
[ removed type casts ]
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/btrfs/volumes.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5289,7 +5289,15 @@ static int __btrfs_map_block(struct btrf
stripe_nr = div64_u64(stripe_nr, stripe_len);
stripe_offset = stripe_nr * stripe_len;
- BUG_ON(offset < stripe_offset);
+ if (offset < stripe_offset) {
+ btrfs_crit(fs_info, "stripe math has gone wrong, "
+ "stripe_offset=%llu, offset=%llu, start=%llu, "
+ "logical=%llu, stripe_len=%llu",
+ stripe_offset, offset, em->start, logical,
+ stripe_len);
+ free_extent_map(em);
+ return -EINVAL;
+ }
/* stripe_offset is the offset of this block in its stripe*/
stripe_offset = offset - stripe_offset;
@@ -5528,7 +5536,13 @@ static int __btrfs_map_block(struct btrf
&stripe_index);
mirror_num = stripe_index + 1;
}
- BUG_ON(stripe_index >= map->num_stripes);
+ if (stripe_index >= map->num_stripes) {
+ btrfs_crit(fs_info, "stripe index math went horribly wrong, "
+ "got stripe_index=%u, num_stripes=%u",
+ stripe_index, map->num_stripes);
+ ret = -EINVAL;
+ goto out;
+ }
num_alloc_stripes = num_stripes;
if (dev_replace_is_ongoing) {
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 4.5 000/128] 4.5.7-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:00 +0200 [PATCH 4.5 126/128] Btrfs: fix unexpected return value of fiemap Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 127/128] btrfs: scrub: Set bbio to NULL before calling btrfs_map_block Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 098/128] PM / sleep: Handle failures in device_suspend_late() consistently Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 093/128] ext4: fix check of dqget() return value in ext4_ioctl_setproject() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 110/128] btrfs: allow balancing to dup with multi-device Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 128/128] btrfs: make state preallocation more speculative in __set_extent_bit Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 120/128] btrfs: fix int32 overflow in shrink_delalloc(). Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 095/128] ext4: address UBSAN warning in mb_find_order_for_block() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 102/128] gcov: disable tree-loop-im to reduce stack usage Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 097/128] nfs: avoid race that crashes nfs_init_commit Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 100/128] scripts/package/Makefile: rpmbuild add support of RPMOPTS Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 115/128] btrfs: add check to sysfs handler of label Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 096/128] ext4: silence UBSAN in ext4_mb_init() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 116/128] Btrfs: fix divide error upon chunks stripe_len Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 123/128] btrfs: pass the right error code to the btrfs_std_error Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 113/128] btrfs: fix lock dep warning, move scratch dev out of device_list_mutex and uuid_mutex Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 122/128] btrfs: fix memory leak during RAID 5/6 device replacement Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 109/128] Btrfs: do not create empty block group if we have allocated data Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 114/128] btrfs: add read-only check to sysfs handler of features Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 119/128] btrfs: add write protection to SET_FEATURES ioctl Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 117/128] Btrfs: remove BUG_ON()s in btrfs_map_block Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 111/128] btrfs: fix mixed block count of available space Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 118/128] btrfs: fix lock dep warning move scratch super outside of chunk_mutex Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 125/128] Btrfs: fix empty symlink after creating symlink and fsync parent dir Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 101/128] mm: thp: avoid false positive VM_BUG_ON_PAGE in page_move_anon_rmap() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:40 +0200 [PATCH 4.5 112/128] btrfs: avoid overflowing f_bfree Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 16:50 +0200 Re: [PATCH 4.5 000/128] 4.5.7-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2016-06-06 19:30 +0200 Re: [PATCH 4.5 000/128] 4.5.7-stable review Guenter Roeck <linux@roeck-us.net> - 2016-06-07 15:40 +0200
csiph-web