OSDN Git Service

Btrfs: detect corruption when non-root leaf has zero item
authorLiu Bo <bo.li.liu@oracle.com>
Tue, 23 Aug 2016 22:22:58 +0000 (15:22 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jan 2019 21:16:06 +0000 (22:16 +0100)
commitdc059e58af01c31a8d593cc99086cf41600852b2
tree85f40d9277600cae6987e7ab23c477a36f0d273e
parent4bf414d2ff5758d64d4c785339c92ba22af979c3
Btrfs: detect corruption when non-root leaf has zero item

commit 1ba98d086fe3a14d6a31f2f66dbab70c45d00f63 upstream.

Right now we treat leaf which has zero item as a valid one
because we could have an empty tree, that is, a root that is
also a leaf without any item, however, in the same case but
when the leaf is not a root, we can end up with hitting the
BUG_ON(1) in btrfs_extend_item() called by
setup_inline_extent_backref().

This makes us check the situation as a corruption if leaf is
not its own root.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/disk-io.c