Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:43852 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754169AbcFEWDQ (ORCPT ); Sun, 5 Jun 2016 18:03:16 -0400 Subject: Patch "Btrfs: remove BUG_ON()'s in btrfs_map_block" has been added to the 4.5-stable tree To: jbacik@fb.com, dsterba@suse.com, gregkh@linuxfoundation.org Cc: , From: Date: Sun, 05 Jun 2016 14:48:37 -0700 Message-ID: <1465163317116206@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled Btrfs: remove BUG_ON()'s in btrfs_map_block to the 4.5-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-remove-bug_on-s-in-btrfs_map_block.patch and it can be found in the queue-4.5 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From e042d1ec4417981dfe9331e47b76f17929bc2ffe Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 12 Apr 2016 12:54:40 -0400 Subject: Btrfs: remove BUG_ON()'s in btrfs_map_block From: Josef Bacik 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 [ removed type casts ] Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- 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) { Patches currently in stable-queue which might be from jbacik@fb.com are queue-4.5/btrfs-bugfix-handle-fs_ioc32_-getflags-setflags-getversion-in-btrfs_ioctl.patch queue-4.5/btrfs-remove-bug_on-s-in-btrfs_map_block.patch