Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4482314ivc; Tue, 3 Nov 2020 13:11:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzRDmwx/4ay4dsHF8Nrx8FUlC9prVxjiFOscTSSN9BElENy3r2cx0+HwywXirdCh8mlYPX X-Received: by 2002:a17:906:c407:: with SMTP id u7mr9469199ejz.261.1604437906066; Tue, 03 Nov 2020 13:11:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437906; cv=none; d=google.com; s=arc-20160816; b=pYyFOyu9oRdsuJbCvL8R/6+nQC41R15EwJFd4PNlU3TLvdyoGr6kaKyWvC5sxmrTO9 BN1PgrYxq+IUQU02gQY184/L+KK/u+Je3ClAgQgvCwLGtTQ05XZ4uH38/5/oUar/dRTr iU8CQpNyBoKuxTHHdKEdydA+HhM11V3UC33gprYAMZnwkpYhWhDxCth/DovYkBWTdX93 gqufUqOaUWXBOlKTXjdRg3dq8KvWcuzbvfh7qA5ANFzTQet5nvvEgsBnpXO7kXEBLSP1 yFqPQEiYtYsHCdno/SsAY6kNh478E4S3wIFszdrKbdtxIrAthDCR0C04ea7SkdoiCTjh liEw== 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=mBXKg98X5igdNxDTEmZ5Z2VSGUg5TgRZgPeBJYpvvMR+zwae+MWgrdnqWtMzVUVOdW lD9ajPnApT5qld12YPz/I6ZnH0fsCwB4wd2W8Rfi9K2ozJl7L/57bArM+HwP5PdarsjW 0dq5WqqLdlOKGkRTkW9jxOz0ZI0e9nYCwSfdcfKsHErcUI+wIlc8TXPGLiGNujWqT19v j9QVR88hM5CMao8DMk1kssJjz7pNAAYAIFBYYjgvgbqONPG4S0vQKAk/T7K3/bTy9V18 JMLtaUAdOk0vN0h3YEW4s2s/+kjSiDaeDSBMi5vfFRVg1elR2bkafzdIeeMSfTXeHiEb j0CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=widc2iW0; 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 zc3si17895ejb.158.2020.11.03.13.11.23; Tue, 03 Nov 2020 13:11:46 -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=widc2iW0; 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 S2388535AbgKCVIq (ORCPT + 99 others); Tue, 3 Nov 2020 16:08:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:48182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388599AbgKCVIo (ORCPT ); Tue, 3 Nov 2020 16:08:44 -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 7B8CB21534; Tue, 3 Nov 2020 21:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437723; bh=iA1ttNm06iJLfQ8hdxVhFGVLcLxQCUX4bDZ3azqJbRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=widc2iW0gfK3Ni/FLF5V7mdZ2Y6Oqq4QvO1fiLy0bn0zF8vo6JSZrpviD3idRJsNW 6yJ16LhVykoaJAtLm3VjoH63XmaMA6aFn3txQI5D2J8JrAr9moBhTZ8YKSQrwdC3OJ Cpnq2zgHCXh76GlIBH8tQN240PMtdQI5oKNqGSQk= 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 4.19 175/191] ext4: fix invalid inode checksum Date: Tue, 3 Nov 2020 21:37:47 +0100 Message-Id: <20201103203248.994841173@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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)))