add patch add-missing-hash-xattr-update
[ext4-patch-queue.git] / add-missing-hash-xattr-update
blob2d01d0132f4829a471de277bffa31b5c7bd8db6d
1 ext4: add missing xattr hash update
3 From: Tahsin Erdogan <tahsin@google.com>
5 When updating an extended attribute, if the padded value sizes are the
6 same, a shortcut is taken to avoid the bulk of the work. This was fine
7 until the xattr hash update was moved inside ext4_xattr_set_entry().
8 With that change, the hash update got missed in the shortcut case.
10 Thanks to ZhangYi (yizhang089@gmail.com) for root causing the problem.
12 Fixes: daf8328172df ("ext4: eliminate xattr entry e_hash recalculation for removes")
14 Reported-by: Miklos Szeredi <miklos@szeredi.hu>
15 Signed-off-by: Tahsin Erdogan <tahsin@google.com>
16 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
17 ---
18  fs/ext4/xattr.c | 6 ++++--
19  1 file changed, 4 insertions(+), 2 deletions(-)
21 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
22 index 82a5af9f6668..3dd970168448 100644
23 --- a/fs/ext4/xattr.c
24 +++ b/fs/ext4/xattr.c
25 @@ -1543,7 +1543,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
26                         /* Clear padding bytes. */
27                         memset(val + i->value_len, 0, new_size - i->value_len);
28                 }
29 -               return 0;
30 +               goto update_hash;
31         }
33         /* Compute min_offs and last. */
34 @@ -1707,6 +1707,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
35                 here->e_value_size = cpu_to_le32(i->value_len);
36         }
38 +update_hash:
39         if (i->value) {
40                 __le32 hash = 0;
42 @@ -1725,7 +1726,8 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
43                                                      here->e_name_len,
44                                                      &crc32c_hash, 1);
45                 } else if (is_block) {
46 -                       __le32 *value = s->base + min_offs - new_size;
47 +                       __le32 *value = s->base + le16_to_cpu(
48 +                                                       here->e_value_offs);
50                         hash = ext4_xattr_hash_entry(here->e_name,
51                                                      here->e_name_len, value,
52 -- 
53 2.14.0.rc1.383.gd1ce394fe2-goog