summary refs log tree commit diff
path: root/fs
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-04-23 11:30:14 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-05-06 15:55:05 -0400
commit1c24c3ce6a8022ab225f44160bfddc92a5a6e435 (patch)
tree594033c6bf744a5d8baf0c7c9ad51fdde2b8d5ed /fs
parent5ec8dca7617b77afb0e3c7e6271089172b498546 (diff)
downloadlinux-1c24c3ce6a8022ab225f44160bfddc92a5a6e435.tar.gz
Btrfs: add tree block level sanity check
With a users corrupted fs I was getting weird behavior and panics and it turns
out it was because one of his tree blocks had a bogus header level.  So add this
to the sanity checks in the endio handler for tree blocks.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/disk-io.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index bb6cdbda4f56..c7d8fb0dbff6 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -613,6 +613,12 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
 		goto err;
 	}
 	found_level = btrfs_header_level(eb);
+	if (found_level >= BTRFS_MAX_LEVEL) {
+		btrfs_info(root->fs_info, "bad tree block level %d\n",
+			   (int)btrfs_header_level(eb));
+		ret = -EIO;
+		goto err;
+	}
 
 	btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb),
 				       eb, found_level);