• Qu Wenruo's avatar
    btrfs: tree-checker: Add checker for dir item · ad7b0368
    Qu Wenruo authored
    Add checker for dir item, for key types DIR_ITEM, DIR_INDEX and
    XATTR_ITEM.
    
    This checker does comprehensive checks for:
    
    1) dir_item header and its data size
       Against item boundary and maximum name/xattr length.
       This part is mostly the same as old verify_dir_item().
    
    2) dir_type
       Against maximum file types, and against key type.
       Since XATTR key should only have FT_XATTR dir item, and normal dir
       item type should not have XATTR key.
    
       The check between key->type and dir_type is newly introduced by this
       patch.
    
    3) name hash
       For XATTR and DIR_ITEM key, key->offset is name hash (crc32c).
       Check the hash of the name against the key to ensure it's correct.
    
       The name hash check is only found in btrfs-progs before this patch.
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
    Reviewed-by: default avatarSu Yue <suy.fnst@cn.fujitsu.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    ad7b0368
tree-checker.c 16.8 KB