Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: fix invalid size check for extent items
@ 2020-11-19 21:14 Josef Bacik
  2020-12-11 17:00 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2020-11-19 21:14 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

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(-)

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) &
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-11 18:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-19 21:14 [PATCH] btrfs-progs: fix invalid size check for extent items Josef Bacik
2020-12-11 17:00 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox