• Liu Bo's avatar
    Btrfs: memset to avoid stale content in btree node block · 3eb548ee
    Liu Bo authored
    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: default avatarLiu Bo <bo.li.liu@oracle.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    3eb548ee
extent_io.c 148 KB