Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp821687pxb; Tue, 3 Nov 2020 13:30:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfHaLfJ3cZGMc4kp8WEeh7vXUKUxzozbH8nO80Vsyk5yNrPxhhu7KVT3lNJJRmqlAPuQVD X-Received: by 2002:a17:906:128d:: with SMTP id k13mr21464635ejb.78.1604439058417; Tue, 03 Nov 2020 13:30:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439058; cv=none; d=google.com; s=arc-20160816; b=zc49LqRidZ+4EuAfTod/DhQHZPkWSHgDLe1NskOVKm8mDo3pkNuzaUiadxWZvg0r0B L308HgobCrxjg2vPTE/o2cIF//bDIn6Hy/dmuZzdfYGA4q5B7sPAOc3wHCWpMmv5Ns+d FMjmKomi8KYnZct0YlcIO1f2zUrhsyHwgL50+nDPlrPZdnov7wV0OXyIY3Y6Zy6zJCTk AeBv9AOvmYnss58f3uTYqyAslGtSikCAeMyl2J8z5lS+JfssoO08q8zY6HlLg2VK8asy KyKJD5EvRAul21nwOQOdjOY6WwU8wbv+gHEayj0uGCHqyWWZrp20Dbxlzy7HZHVstK4j fYpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wgttiiMJoZexeNEijt2kajX+mxBLaWEAyxVikPjTpvM=; b=ND7PK3DekA8FlogAghScdRlbRLRDNV+39Xjf3kPQKTf7C2Q7qGbwLNNpkVoopktTk9 onBFPS5h1GQVvigJwXnwavOe8X0UINx4o4THAjCgj9zW+dr4r0tVHiyWCUdOhJIh9LkW MSod/U42E4YusCDvnvSRZtNs46GV9L76Df4xC3DrrRFxEjzbcOmkxL1xWGhEAd8IyIAy lhJMc4EmUNxYsz2CU5/uTFf5VrpQmCQh0Pz/kuAKGjIHV5zoajSVCc9etFCm53ciJIi5 X8YkXoLtd3r2gtyDvIXqQDi3PnJa7I+SVyEPPAr+3s3roAzEzKcI2MQgmd70rbVRbP7M 6isA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U5ovmsOF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e18si2588eji.106.2020.11.03.13.30.35; Tue, 03 Nov 2020 13:30:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U5ovmsOF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387465AbgKCVB3 (ORCPT + 99 others); Tue, 3 Nov 2020 16:01:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:37722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387439AbgKCVBS (ORCPT ); Tue, 3 Nov 2020 16:01:18 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 46AE621534; Tue, 3 Nov 2020 21:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437277; bh=iA1ttNm06iJLfQ8hdxVhFGVLcLxQCUX4bDZ3azqJbRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U5ovmsOFptVQgRAU9WVp8BED5Leeqihj7p9wQRt1Q96Xga++2JzJt79p4+tZAEOe+ /okRTPv48ycKP9Ro4g5yVKtnouK2/R6k/GogqC2GwEasSU9aHh6YnZ35GMoye19sHx VHkOBIEZRyjb7mLbkQ646GdLqEthuTQgKxc8K4XM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Luo Meng , "Darrick J. Wong" , Theodore Tso Subject: [PATCH 5.4 194/214] ext4: fix invalid inode checksum Date: Tue, 3 Nov 2020 21:37:22 +0100 Message-Id: <20201103203308.841778637@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Meng commit 1322181170bb01bce3c228b82ae3d5c6b793164f upstream. During the stability test, there are some errors: ext4_lookup:1590: inode #6967: comm fsstress: iget: checksum invalid. If the inode->i_iblocks too big and doesn't set huge file flag, checksum will not be recalculated when update the inode information to it's buffer. If other inode marks the buffer dirty, then the inconsistent inode will be flushed to disk. Fix this problem by checking i_blocks in advance. Cc: stable@kernel.org Signed-off-by: Luo Meng Reviewed-by: Darrick J. Wong Link: https://lore.kernel.org/r/20201020013631.3796673-1-luomeng12@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inode.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5271,6 +5271,12 @@ static int ext4_do_update_inode(handle_t if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size); + err = ext4_inode_blocks_set(handle, raw_inode, ei); + if (err) { + spin_unlock(&ei->i_raw_lock); + goto out_brelse; + } + raw_inode->i_mode = cpu_to_le16(inode->i_mode); i_uid = i_uid_read(inode); i_gid = i_gid_read(inode); @@ -5304,11 +5310,6 @@ static int ext4_do_update_inode(handle_t EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode); EXT4_EINODE_SET_XTIME(i_crtime, ei, raw_inode); - err = ext4_inode_blocks_set(handle, raw_inode, ei); - if (err) { - spin_unlock(&ei->i_raw_lock); - goto out_brelse; - } raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF); if (likely(!test_opt2(inode->i_sb, HURD_COMPAT)))