Skip to content

Commit

Permalink
ext4: add missing xattr hash update
Browse files Browse the repository at this point in the history
When updating an extended attribute, if the padded value sizes are the
same, a shortcut is taken to avoid the bulk of the work. This was fine
until the xattr hash update was moved inside ext4_xattr_set_entry().
With that change, the hash update got missed in the shortcut case.

Thanks to ZhangYi (yizhang089@gmail.com) for root causing the problem.

Fixes: daf8328 ("ext4: eliminate xattr entry e_hash recalculation for removes")

Reported-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
  • Loading branch information
Tahsin Erdogan authored and Theodore Ts'o committed Aug 14, 2017
1 parent b80b32b commit 32aaf19
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/ext4/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
/* Clear padding bytes. */
memset(val + i->value_len, 0, new_size - i->value_len);
}
return 0;
goto update_hash;
}

/* Compute min_offs and last. */
Expand Down Expand Up @@ -1707,6 +1707,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
here->e_value_size = cpu_to_le32(i->value_len);
}

update_hash:
if (i->value) {
__le32 hash = 0;

Expand All @@ -1725,7 +1726,8 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
here->e_name_len,
&crc32c_hash, 1);
} else if (is_block) {
__le32 *value = s->base + min_offs - new_size;
__le32 *value = s->base + le16_to_cpu(
here->e_value_offs);

hash = ext4_xattr_hash_entry(here->e_name,
here->e_name_len, value,
Expand Down

0 comments on commit 32aaf19

Please sign in to comment.