diff mbox series

btrfs-progs: fix invalid size check for extent items

Message ID c85b0bbcfff13bafec48f8cd266fb73b345c43c3.1605820453.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: fix invalid size check for extent items | expand

Commit Message

Josef Bacik Nov. 19, 2020, 9:14 p.m. UTC
While trying to run down a corruption problem I needed to use
btrfs-image to generate known good states in between tests.  At some
point this started failing with

either extent tree is corrupted or deprecated extent ref format

This is because the fs had an extent item that was large enough that it
no longer had inline extent references, they were all keyed extent
references.  The check is bogus, we can have extent items that are >=
the extent item size, not just > than the extent item size.  Fix the
check so that we can generate metadata dumps properly.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 image/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba Dec. 11, 2020, 5 p.m. UTC | #1
On Thu, Nov 19, 2020 at 04:14:20PM -0500, Josef Bacik wrote:
> While trying to run down a corruption problem I needed to use
> btrfs-image to generate known good states in between tests.  At some
> point this started failing with
> 
> either extent tree is corrupted or deprecated extent ref format
> 
> This is because the fs had an extent item that was large enough that it
> no longer had inline extent references, they were all keyed extent
> references.  The check is bogus, we can have extent items that are >=
> the extent item size, not just > than the extent item size.  Fix the
> check so that we can generate metadata dumps properly.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Added to devel, thanks.
diff mbox series

Patch

diff --git a/image/main.c b/image/main.c
index e59f24ff..48070e52 100644
--- a/image/main.c
+++ b/image/main.c
@@ -933,7 +933,7 @@  static int copy_from_extent_tree(struct metadump_struct *metadump,
 			break;
 		}
 
-		if (btrfs_item_size_nr(leaf, path->slots[0]) > sizeof(*ei)) {
+		if (btrfs_item_size_nr(leaf, path->slots[0]) >= sizeof(*ei)) {
 			ei = btrfs_item_ptr(leaf, path->slots[0],
 					    struct btrfs_extent_item);
 			if (btrfs_extent_flags(leaf, ei) &