Skip to content

Commit 8ee8c2d

Browse files
Su Yuekdave
authored andcommitted
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 <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 26a836c commit 8ee8c2d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/btrfs/tree-log.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,7 @@ static int replay_xattr_deletes(struct btrfs_trans_handle *trans,
21112111
struct btrfs_path *path,
21122112
const u64 ino)
21132113
{
2114+
struct btrfs_fs_info *fs_info = root->fs_info;
21142115
struct btrfs_key search_key;
21152116
struct btrfs_path *log_path;
21162117
int i;
@@ -2152,6 +2153,12 @@ static int replay_xattr_deletes(struct btrfs_trans_handle *trans,
21522153
u32 this_len = sizeof(*di) + name_len + data_len;
21532154
char *name;
21542155

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+
}
21552162
name = kmalloc(name_len, GFP_NOFS);
21562163
if (!name) {
21572164
ret = -ENOMEM;

0 commit comments

Comments
 (0)