]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
btrfs: tree-checker: Detect invalid and empty essential trees
authorQu Wenruo <wqu@suse.com>
Tue, 3 Jul 2018 09:10:06 +0000 (17:10 +0800)
committerSultan Alsawaf <sultan.alsawaf@canonical.com>
Wed, 24 Jul 2019 15:44:56 +0000 (09:44 -0600)
commit49a46309b57312c7a73baeb42a64a370da4b1a6b
tree2e5c2bd9b908c157c68f3fdbe042fced297ba215
parent404f17e94f85a8850475e6e5bca0c98481132b2d
btrfs: tree-checker: Detect invalid and empty essential trees

BugLink: https://bugs.launchpad.net/bugs/1836968
commit ba480dd4db9f1798541eb2d1c423fc95feee8d36 upstream.

A crafted image has empty root tree block, which will later cause NULL
pointer dereference.

The following trees should never be empty:
1) Tree root
   Must contain at least root items for extent tree, device tree and fs
   tree

2) Chunk tree
   Or we can't even bootstrap as it contains the mapping.

3) Fs tree
   At least inode item for top level inode (.).

4) Device tree
   Dev extents for chunks

5) Extent tree
   Must have corresponding extent for each chunk.

If any of them is empty, we are sure the fs is corrupted and no need to
mount it.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=199847
Reported-by: Xu Wen <wen.xu@gatech.edu>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Tested-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
[bwh: Backported to 4.14: Pass root instead of fs_info to generic_err()]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/btrfs/tree-checker.c