btrfs: Check name_len on add_inode_ref call path
authorSu Yue <suy.fnst@cn.fujitsu.com>
Tue, 6 Jun 2017 09:57:02 +0000 (17:57 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 21 Jun 2017 17:16:04 +0000 (19:16 +0200)
commit26a836cec2ea38329ddf3f049c78e9b94e500670
tree80229894853e88e862f74defffa9bf2a2ed72f19
parente79a33270d05f711e985b9524a392fd45ad3e93f
btrfs: Check name_len on add_inode_ref call path

replay_one_buffer first reads buffers and dispatches items accroding to
the item type.
In this patch, add_inode_ref handles inode_ref and inode_extref.
Then add_inode_ref calls ref_get_fields and extref_get_fields to read
ref/extref name for the first time.
So checking name_len before reading those two is fine.

add_inode_ref also calls inode_in_dir to match ref/extref in parent_dir.
The call graph includes btrfs_match_dir_item_name to read dir_item name
in the parent dir.
Checking first dir_item is not enough. Change it to verify every
dir_item while doing matches.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/dir-item.c
fs/btrfs/tree-log.c