Skip to content

Commit 54a7081

Browse files
fdmananakdave
authored andcommitted
btrfs: fix iteration of extrefs during log replay
At __inode_add_ref() when processing extrefs, if we jump into the next label we have an undefined value of victim_name.len, since we haven't initialized it before we did the goto. This results in an invalid memory access in the next iteration of the loop since victim_name.len was not initialized to the length of the name of the current extref. Fix this by initializing victim_name.len with the current extref's name length. Fixes: e43eec8 ("btrfs: use struct qstr instead of name and namelen pairs") Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 6561a40 commit 54a7081

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/tree-log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,13 +1148,13 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
11481148
struct fscrypt_str victim_name;
11491149

11501150
extref = (struct btrfs_inode_extref *)(base + cur_offset);
1151+
victim_name.len = btrfs_inode_extref_name_len(leaf, extref);
11511152

11521153
if (btrfs_inode_extref_parent(leaf, extref) != parent_objectid)
11531154
goto next;
11541155

11551156
ret = read_alloc_one_name(leaf, &extref->name,
1156-
btrfs_inode_extref_name_len(leaf, extref),
1157-
&victim_name);
1157+
victim_name.len, &victim_name);
11581158
if (ret)
11591159
return ret;
11601160

0 commit comments

Comments
 (0)