From 7f2c3c2d10fd38067afbf4b71306e2c88ed5d88c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 14 Aug 2017 08:31:01 -0400 Subject: [PATCH] add patch add-missing-hash-xattr-update --- add-missing-hash-xattr-update | 55 +++++++++++++++++++++++++++++++++++++++++++ series | 1 + timestamps | 7 +++--- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 add-missing-hash-xattr-update diff --git a/add-missing-hash-xattr-update b/add-missing-hash-xattr-update new file mode 100644 index 00000000..2d01d013 --- /dev/null +++ b/add-missing-hash-xattr-update @@ -0,0 +1,55 @@ +ext4: add missing xattr hash update + +From: Tahsin Erdogan + +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: daf8328172df ("ext4: eliminate xattr entry e_hash recalculation for removes") + +Reported-by: Miklos Szeredi +Signed-off-by: Tahsin Erdogan +Signed-off-by: Theodore Ts'o +--- + fs/ext4/xattr.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c +index 82a5af9f6668..3dd970168448 100644 +--- a/fs/ext4/xattr.c ++++ b/fs/ext4/xattr.c +@@ -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. */ +@@ -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; + +@@ -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, +-- +2.14.0.rc1.383.gd1ce394fe2-goog + + diff --git a/series b/series index 53e3a53a..8063030a 100644 --- a/series +++ b/series @@ -1,6 +1,7 @@ # v4.13-rc4 fix-clang-build-regression +add-missing-hash-xattr-update #################################################### # unstable patches diff --git a/timestamps b/timestamps index 0a7b8399..b6641091 100755 --- a/timestamps +++ b/timestamps @@ -33,7 +33,8 @@ touch -d @1502684568 cleaner touch -d @1502684568 load-jmap-from-journal touch -d @1502684569 add-ext4-journal-lazy-mount-option touch -d @1502684569 disable-writeback -touch -d @1502713301 series touch -d @1502713758 fix-clang-build-regression -touch -d @1502713758 status -touch -d @1502713760 timestamps +touch -d @1502713806 add-missing-hash-xattr-update +touch -d @1502713841 series +touch -d @1502713844 status +touch -d @1502713851 timestamps -- 2.11.4.GIT