diff mbox

[1/3] btrfs: fsck/original: Don't panic out when unexpected root item is referring to one extent

Message ID 20180705074558.20022-1-wqu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Qu Wenruo July 5, 2018, 7:45 a.m. UTC
With crafted image, expected root item can refer to certain extent, and
original mode uses BUG_ON() to handle such case.

Fix it by gracefully return error.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=200403
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

David Sterba July 16, 2018, 4:15 p.m. UTC | #1
On Thu, Jul 05, 2018 at 03:45:56PM +0800, Qu Wenruo wrote:
> With crafted image, expected root item can refer to certain extent, and
> original mode uses BUG_ON() to handle such case.
> 
> Fix it by gracefully return error.
> 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=200403
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Please send cover lettter for patchsets with more than one patch.
Patches 1-3 applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/check/main.c b/check/main.c
index 8db300abb825..6f1182106071 100644
--- a/check/main.c
+++ b/check/main.c
@@ -3724,7 +3724,12 @@  static int check_owner_ref(struct btrfs_root *root,
 		if (btrfs_header_owner(buf) == back->root)
 			return 0;
 	}
-	BUG_ON(rec->is_root);
+	/*
+	 * Some unexpected root item referring to this one, return 1 to
+	 * indicate owner not found
+	 */
+	if (rec->is_root)
+		return 1;
 
 	/* try to find the block by search corresponding fs tree */
 	key.objectid = btrfs_header_owner(buf);