btrfs: Verify dir_item in iterate_object_props
authorSu Yue <suy.fnst@cn.fujitsu.com>
Tue, 6 Jun 2017 09:57:08 +0000 (17:57 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 21 Jun 2017 17:16:04 +0000 (19:16 +0200)
Call verify_dir_item before memcmp_extent_buffer reading name from
dir_item.

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/props.c

index d6cb155ef7a15fa1cc780bd1f5e6cc9624b891b6..4b23ae5d0e5c0330260ae96d2574b9422c16978d 100644 (file)
@@ -164,6 +164,7 @@ static int iterate_object_props(struct btrfs_root *root,
                                                 size_t),
                                void *ctx)
 {
+       struct btrfs_fs_info *fs_info = root->fs_info;
        int ret;
        char *name_buf = NULL;
        char *value_buf = NULL;
@@ -214,6 +215,12 @@ static int iterate_object_props(struct btrfs_root *root,
                        name_ptr = (unsigned long)(di + 1);
                        data_ptr = name_ptr + name_len;
 
+                       if (verify_dir_item(fs_info, leaf,
+                                           path->slots[0], di)) {
+                               ret = -EIO;
+                               goto out;
+                       }
+
                        if (name_len <= XATTR_BTRFS_PREFIX_LEN ||
                            memcmp_extent_buffer(leaf, XATTR_BTRFS_PREFIX,
                                                 name_ptr,