Skip to content

Commit

Permalink
btrfs: Check name_len before read in iterate_dir_item
Browse files Browse the repository at this point in the history
Since iterate_dir_item checks name_len in its own way,
so use btrfs_is_name_len_valid not 'verify_dir_item' to make more strict
name_len check.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ switched ENAMETOOLONG to EIO ]
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Su Yue authored and David Sterba committed Jun 21, 2017
1 parent 3c1d418 commit 59b0a7f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/btrfs/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,12 @@ static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
}
}

ret = btrfs_is_name_len_valid(eb, path->slots[0],
(unsigned long)(di + 1), name_len + data_len);
if (!ret) {
ret = -EIO;
goto out;
}
if (name_len + data_len > buf_len) {
buf_len = name_len + data_len;
if (is_vmalloc_addr(buf)) {
Expand Down

0 comments on commit 59b0a7f

Please sign in to comment.