summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorSu Yue <suy.fnst@cn.fujitsu.com>2017-06-06 05:57:03 -0400
committerDavid Sterba <dsterba@suse.com>2017-06-21 13:16:04 -0400
commit8ee8c2d62d5f9e7d1e592426d3d0b941df29f688 (patch)
tree5026f6be37ee695402547dbb5d645b753c09750e /fs/btrfs
parent26a836cec2ea38329ddf3f049c78e9b94e500670 (diff)
btrfs: Verify dir_item in replay_xattr_deletes
replay_xattr_deletes calls btrfs_search_slot to get buffer and reads name. Call verify_dir_item to check name_len in replay_xattr_deletes to avoid reading out of boundary. 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>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/tree-log.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 11cf38fb3a49..06c7ceb07282 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2111,6 +2111,7 @@ static int replay_xattr_deletes(struct btrfs_trans_handle *trans,
2111 struct btrfs_path *path, 2111 struct btrfs_path *path,
2112 const u64 ino) 2112 const u64 ino)
2113{ 2113{
2114 struct btrfs_fs_info *fs_info = root->fs_info;
2114 struct btrfs_key search_key; 2115 struct btrfs_key search_key;
2115 struct btrfs_path *log_path; 2116 struct btrfs_path *log_path;
2116 int i; 2117 int i;
@@ -2152,6 +2153,12 @@ process_leaf:
2152 u32 this_len = sizeof(*di) + name_len + data_len; 2153 u32 this_len = sizeof(*di) + name_len + data_len;
2153 char *name; 2154 char *name;
2154 2155
2156 ret = verify_dir_item(fs_info, path->nodes[0],
2157 path->slots[0], di);
2158 if (ret) {
2159 ret = -EIO;
2160 goto out;
2161 }
2155 name = kmalloc(name_len, GFP_NOFS); 2162 name = kmalloc(name_len, GFP_NOFS);
2156 if (!name) { 2163 if (!name) {
2157 ret = -ENOMEM; 2164 ret = -ENOMEM;