From patchwork Sun Aug 6 20:03:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahsin Erdogan X-Patchwork-Id: 798445 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="KNApK8J0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xQWnQ2Zb0z9sDB for ; Mon, 7 Aug 2017 06:03:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751371AbdHFUD2 (ORCPT ); Sun, 6 Aug 2017 16:03:28 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:34915 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751353AbdHFUD0 (ORCPT ); Sun, 6 Aug 2017 16:03:26 -0400 Received: by mail-pg0-f44.google.com with SMTP id v189so26042546pgd.2 for ; Sun, 06 Aug 2017 13:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=V2gLT4YDJB3YV/STDx0n2rv8jRBY2aASdcWNn2BX6kk=; b=KNApK8J0iPOfpPuwOz1maKOzlwxq1ZL5nkvGgAU5mia63dXCuQfxR+rc2FVgrcVWNO 58cJFrbb+yYfSfHpgslyRqYUUL+rluggi2yEtAwIEYXmBiA8sGKzC934U+PQD4Cy06mp RYQ0SN/gdx+RTqqPC2vMClz9ShEddTAmtoogFtYDPWpKd+XlbYE+KVT+D/JsHtevRsR6 iOQLo0VoeFuCcwdDun5IPTc+2VFlpDY9T9JVuJd3kh8yL6lOD8bU/n9cwxye2rYFTa+I XTCm3Q9vsUmOX5QZE7BIG81f2eR/24MK1hQYeMjkKaZU47m5M4+9Rd+neWGPrrioTaBs fF7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=V2gLT4YDJB3YV/STDx0n2rv8jRBY2aASdcWNn2BX6kk=; b=OG6SkpeVyfNkyskjFsmKWnzdj9w917OwXM2gOiCDuLMUKB2RKXR1Rxt0EbB0Un2eG9 VlMBgyXpXlSajHnJPP3J2IqixdQinuMMFra7Nlcm1nzpqCaiSp237dFsJJctoKO+9gOZ WA5zXkdcHuMsWi0d7tV1XN7P9+xg5iI9dAjlGYRj+yt4tYgRppnLZRNuQTjtrDLpfmn4 7egMMcOxS0qq7SuHnyN9clEx1eyro4rirfvXOlUbV51MchFtmcHGDfChbVA1uJkc/13h eWICSffNt5f714XQyUO5pX+3+qKzTOJgBEkjww9mWRDrY5xSiOHoosTKOCfe9OKUPRJY zRuQ== X-Gm-Message-State: AIVw111aBWTXP6FCn9s1H0wGEFKG1JQkay1symoKz3nDSVQKYi1cATw1 wTlDS8qYjmJktmKZ X-Received: by 10.98.62.130 with SMTP id y2mr9835578pfj.114.1502049804759; Sun, 06 Aug 2017 13:03:24 -0700 (PDT) Received: from tahsin1.svl.corp.google.com ([100.123.230.167]) by smtp.gmail.com with ESMTPSA id l5sm11693977pfg.50.2017.08.06.13.03.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 06 Aug 2017 13:03:24 -0700 (PDT) From: Tahsin Erdogan To: Theodore Ts'o , Andreas Dilger , Miklos Szeredi , zhangyi , linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Tahsin Erdogan Subject: [PATCH] ext4: add missing xattr hash update Date: Sun, 6 Aug 2017 13:03:19 -0700 Message-Id: <20170806200319.21077-1-tahsin@google.com> X-Mailer: git-send-email 2.14.0.rc1.383.gd1ce394fe2-goog Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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,