Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1643833pxy; Mon, 2 Aug 2021 06:58:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZmrpdSIIzq3NI9sUM0UmJk/l7X4yTlNn82DVXaIZVJ8l2GQdFS5a7KzEm7fGGsSZ+Mk3j X-Received: by 2002:a92:d912:: with SMTP id s18mr65290iln.172.1627912716387; Mon, 02 Aug 2021 06:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912716; cv=none; d=google.com; s=arc-20160816; b=KTzxmPODN9NcYtrnRzbvLpjdcytiKhjNJFVT1nwyCnwWnGiM0IDF0OXmWMOQjb8ud8 5I1aBhYywDDNNh2u4kiH/wGitfT+wvpStmkax1h4blswXD1U+cS++CPKcEidZKzx/Q7F d9LU/MwhUixoFX9lCmZrQW22vFiiu8f9BYPP4r3og61vX7JuqNZiLBcccrz97FPZQZcN E12EUT3HM9vWsl6KF6GBHiLJBTGs3Gq0ZwmQZLa32c2AQ+rgMim3hfMXlnuWmluDUiyX dXkpCO+4/CCiaHEBjkusqpKDBeirKtuxUMWJpOllhoFL1soyBeg72p1XPsKwhswew9mp RchQ== 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=dBFisSH0E1p86E6ezNBdRlT25AH3XXAwV4bt1a04EJc=; b=sLkF/eiLFNsccVOx13nBZ2jlLkrovMDEoZ7/zLfvwThAFDTgqxvZv/+5UaEKsxFg84 ikCCyrrVR3X1Ga8VR1ZVHQX9BK7X7/INnZxfpvCcOhMHXkH0twmTNQm2G38rMTe87jCN bhCBQ5FwVkZJQ1NwVpFXPp+xh8my502fFbRyyeyq+/4nBcGlbt55/nyUFd9kWz1kp4VQ w65CNgM8nrtFfeBWYyCJtb2u/nkveK9fUkY7gAgEWDE+OzKoUFseCdb7Q+l13XGaxtk3 z0QVEYHNrPANhQsz5nkQF75InzBCEPt0UeMISKoldiBIC7wtdqJKGQE10gf++KRIM9UE da8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CJJEP27J; 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=pass (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 x29si11680418jap.52.2021.08.02.06.58.24; Mon, 02 Aug 2021 06:58:36 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=CJJEP27J; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235866AbhHBN5z (ORCPT + 99 others); Mon, 2 Aug 2021 09:57:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234513AbhHBNvk (ORCPT ); Mon, 2 Aug 2021 09:51:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5242061101; Mon, 2 Aug 2021 13:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912273; bh=dB5qXChcL5U5nIwu+gk/y3fdb2nYynTde59+abisi+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CJJEP27JvU9RjGIeAseTcvzwlHsHXQXBF9TRn3nWjNVKlCi+75/yEVT0PCpYV7FUf OEpu+IFFJGGBbeuxJJmA3cu+l34fsrwkv+Bkq93l5iDhgZ3MUIWAyS8hoSocWy/Swu ECFG6sHhuga0KckbPxxdE5NJ3DpzE/lmY5OQ6lKI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Junxiao Bi , Joseph Qi , Changwei Ge , Gang He , Joel Becker , Jun Piao , Mark Fasheh , Andrew Morton , Linus Torvalds Subject: [PATCH 5.4 08/40] ocfs2: fix zero out valid data Date: Mon, 2 Aug 2021 15:44:48 +0200 Message-Id: <20210802134335.665639525@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134335.408294521@linuxfoundation.org> References: <20210802134335.408294521@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: Junxiao Bi commit f267aeb6dea5e468793e5b8eb6a9c72c0020d418 upstream. If append-dio feature is enabled, direct-io write and fallocate could run in parallel to extend file size, fallocate used "orig_isize" to record i_size before taking "ip_alloc_sem", when ocfs2_zeroout_partial_cluster() zeroout EOF blocks, i_size maybe already extended by ocfs2_dio_end_io_write(), that will cause valid data zeroed out. Link: https://lkml.kernel.org/r/20210722054923.24389-1-junxiao.bi@oracle.com Fixes: 6bba4471f0cc ("ocfs2: fix data corruption by fallocate") Signed-off-by: Junxiao Bi Reviewed-by: Joseph Qi Cc: Changwei Ge Cc: Gang He Cc: Joel Becker Cc: Jun Piao Cc: Mark Fasheh Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -1935,7 +1935,6 @@ static int __ocfs2_change_file_space(str goto out_inode_unlock; } - orig_isize = i_size_read(inode); switch (sr->l_whence) { case 0: /*SEEK_SET*/ break; @@ -1943,7 +1942,7 @@ static int __ocfs2_change_file_space(str sr->l_start += f_pos; break; case 2: /*SEEK_END*/ - sr->l_start += orig_isize; + sr->l_start += i_size_read(inode); break; default: ret = -EINVAL; @@ -1998,6 +1997,7 @@ static int __ocfs2_change_file_space(str ret = -EINVAL; } + orig_isize = i_size_read(inode); /* zeroout eof blocks in the cluster. */ if (!ret && change_size && orig_isize < size) { ret = ocfs2_zeroout_partial_cluster(inode, orig_isize,