stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Chris Mason <clm@fb.com>,
	Mark Fasheh <mfasheh@suse.de>, Filipe Manana <fdmanana@suse.com>
Subject: [PATCH 3.14 14/25] btrfs: fix use after free iterating extrefs
Date: Fri, 23 Oct 2015 10:45:55 -0700	[thread overview]
Message-ID: <20151023174553.232337295@linuxfoundation.org> (raw)
In-Reply-To: <20151023174552.800926510@linuxfoundation.org>

3.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Chris Mason <clm@fb.com>

commit dc6c5fb3b514221f2e9d21ee626a9d95d3418dff upstream.

The code for btrfs inode-resolve has never worked properly for
files with enough hard links to trigger extrefs.  It was trying to
get the leaf out of a path after freeing the path:

	btrfs_release_path(path);
	leaf = path->nodes[0];
	item_size = btrfs_item_size_nr(leaf, slot);

The fix here is to use the extent buffer we cloned just a little higher
up to avoid deadlocks caused by using the leaf in the path.

Signed-off-by: Chris Mason <clm@fb.com>
cc: Mark Fasheh <mfasheh@suse.de>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/btrfs/backref.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -1692,7 +1692,6 @@ static int iterate_inode_extrefs(u64 inu
 	int found = 0;
 	struct extent_buffer *eb;
 	struct btrfs_inode_extref *extref;
-	struct extent_buffer *leaf;
 	u32 item_size;
 	u32 cur_offset;
 	unsigned long ptr;
@@ -1720,9 +1719,8 @@ static int iterate_inode_extrefs(u64 inu
 		btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
 		btrfs_release_path(path);
 
-		leaf = path->nodes[0];
-		item_size = btrfs_item_size_nr(leaf, slot);
-		ptr = btrfs_item_ptr_offset(leaf, slot);
+		item_size = btrfs_item_size_nr(eb, slot);
+		ptr = btrfs_item_ptr_offset(eb, slot);
 		cur_offset = 0;
 
 		while (cur_offset < item_size) {
@@ -1736,7 +1734,7 @@ static int iterate_inode_extrefs(u64 inu
 			if (ret)
 				break;
 
-			cur_offset += btrfs_inode_extref_name_len(leaf, extref);
+			cur_offset += btrfs_inode_extref_name_len(eb, extref);
 			cur_offset += sizeof(*extref);
 		}
 		btrfs_tree_read_unlock_blocking(eb);



  parent reply	other threads:[~2015-10-23 17:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23 17:45 [PATCH 3.14 00/25] 3.14.56-stable review Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 01/25] l2tp: protect tunnel->del_work by ref_count Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 02/25] af_unix: Convert the unix_sk macro to an inline function for type safety Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 03/25] af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 04/25] net/unix: fix logic about sk_peek_offset Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 05/25] skbuff: Fix skb checksum flag on skb pull Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 06/25] skbuff: Fix skb checksum partial check Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 07/25] net: add pfmemalloc check in sk_add_backlog() Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 08/25] ppp: dont override sk->sk_state in pppoe_flush_dev() Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 09/25] ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 10/25] asix: Dont reset PHY on if_up for ASIX 88772 Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 11/25] asix: Do full reset during ax88772_bind Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 12/25] crypto: sparc - initialize blkcipher.ivsize Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 13/25] crypto: ahash - ensure statesize is non-zero Greg Kroah-Hartman
2015-10-23 17:45 ` Greg Kroah-Hartman [this message]
2015-10-23 17:45 ` [PATCH 3.14 15/25] arm64: errata: use KBUILD_CFLAGS_MODULE for erratum #843419 Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 16/25] i2c: rcar: enable RuntimePM before registering to the core Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 17/25] i2c: s3c2410: " Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.14 18/25] i2c: designware: Do not use parameters from ACPI on Dell Inspiron 7348 Greg Kroah-Hartman
2015-10-23 17:46 ` [PATCH 3.14 19/25] workqueue: make sure delayed work run in local cpu Greg Kroah-Hartman
2015-10-23 17:46 ` [PATCH 3.14 20/25] drm/nouveau/fbcon: take runpm reference when userspace has an open fd Greg Kroah-Hartman
2015-10-23 17:46 ` [PATCH 3.14 21/25] drm/radeon: add pm sysfs files late Greg Kroah-Hartman
2015-10-23 17:46 ` [PATCH 3.14 22/25] dm thin: fix missing pool reference count decrement in pool_ctr error path Greg Kroah-Hartman
2015-10-23 17:46 ` [PATCH 3.14 23/25] rbd: fix double free on rbd_dev->header_name Greg Kroah-Hartman
2015-10-23 17:46 ` [PATCH 3.14 24/25] sched/preempt: Rename PREEMPT_CHECK_OFFSET to PREEMPT_DISABLE_OFFSET Greg Kroah-Hartman
2015-10-23 17:46 ` [PATCH 3.14 25/25] sched/preempt: Fix cond_resched_lock() and cond_resched_softirq() Greg Kroah-Hartman
2015-10-23 21:07 ` [PATCH 3.14 00/25] 3.14.56-stable review Shuah Khan
2015-10-24  2:02 ` Guenter Roeck

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=20151023174553.232337295@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=clm@fb.com \
    --cc=fdmanana@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mfasheh@suse.de \
    --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;
as well as URLs for NNTP newsgroup(s).