]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Btrfs: memset to avoid stale content in btree node block
authorLiu Bo <bo.li.liu@oracle.com>
Thu, 15 Sep 2016 00:22:57 +0000 (17:22 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 28 Apr 2020 18:02:27 +0000 (19:02 +0100)
commit4fcf49a10eccd4efeeadc904d5d8dc0dcf5672fb
treefb0613e21fe1c98441dc672c39a7595dbadbb846
parentf160883f341780b9d040e9a3fbf9fbc691bb854b
Btrfs: memset to avoid stale content in btree node block

commit 3eb548ee3a8042d95ad81be254e67a5222c24e03 upstream.

During updating btree, we could push items between sibling
nodes/leaves, for leaves data sections starts reversely from
the end of the block while for nodes we only have key pairs
which are stored one by one from the start of the block.

So we could do try to push key pairs from one node to the next
node right in the tree, and after that, we update the node's
nritems to reflect the correct end while leaving the stale
content in the node.  One may intentionally corrupt the fs
image and access the stale content by bumping the nritems and
causes various crashes.

This takes the in-memory @nritems as the correct one and
gets to memset the unused part of a btree node.

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: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/btrfs/extent_io.c