]> git.baikalelectronics.ru Git - kernel.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)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Sep 2016 16:03:47 +0000 (18:03 +0200)
commit1f6956ef7ba9f49cd97a9241cbe6e015a59e0ccc
tree4c43a736bd3ea8f094c060afed9c000278e65348
parent97e29413ca5a2967dea4045599d1d3bc955bab51
Btrfs: memset to avoid stale content in btree node block

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>
fs/btrfs/extent_io.c