Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1642853pxy; Mon, 2 Aug 2021 06:56:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5jneIwnzFoLfxk/7dJtSI8kFtwzljdN0uwFb8LsT8xiza14NZi1sLdBgra9mwFGU4BU1R X-Received: by 2002:a05:6602:20c9:: with SMTP id 9mr1034074ioz.34.1627912619546; Mon, 02 Aug 2021 06:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912619; cv=none; d=google.com; s=arc-20160816; b=IYSx4AtpYw3YZ6Qfz8YREAT/rysoBl55saeUA9/J/Ge0eUFLI2qwuyEPv2pjF3S9d3 WfXzpeHL702Q8IMvOuqEIZqKAQPt2St+5PZxnhwDwaBaFueQR8vKmhUFUyXQJkIfXvcA Q3OzM5yiiDMNNwrCtJrT6zaX4cZ+RWN9642HxiaAe82JVr6gxXsT5OgtwKOAccUiQnmE vt82TVOvKX/CP6sWaUvNRSE+x8Y3j3OL7syQHnTNkbDctsk2YH3zexV0lBxC7rZuFS+D FUe+YKvhcdaUJ3oy/eBb+8MiiBzWru/nEAviG5JcVSGtrkHRoYlEb0mefH9dqoZ1wG2z exQg== 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=01KP6wfZOD3KL/RBHW/p509NC2J89K5bq4vkCbgD8fk=; b=WSd7eUcS6VIYBX29FbnGf6Eah4yvi5LoWMDVB+Gy2CNtoHkiFYBtFvrZg0ujt5fPgj zw0mvSsjVoU9QCzKGhvl/0ylIqcgvzgvKc6LeMI7wwBjaTmpHY5dEq6OY0GQoQpjIZVE ZveUblFAH+gl0PD37ha9pKurMHBXxJcWrb1Y+TtLdD/KzBbaKaTeJZmAO+TaJAo05oLr b+DHW6eMc+3mumyyZf8uUncS1arMDeT5044xy37+ij+ZntGjdUIl4bXNWqEqMSU4yuaI 96YuXrPNs+qZwhxWOM5m1gPVZBheH1F4et7os4fL7l93lYgXP/lTVUnGPBBgHlKyIxQD o5zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fgxRA5FY; 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 e101si11817995jai.50.2021.08.02.06.56.48; Mon, 02 Aug 2021 06:56:59 -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=fgxRA5FY; 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 S235898AbhHBNye (ORCPT + 99 others); Mon, 2 Aug 2021 09:54:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:60514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234371AbhHBNtt (ORCPT ); Mon, 2 Aug 2021 09:49:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D636260527; Mon, 2 Aug 2021 13:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912180; bh=cuT1ovZiZklR2yQqdQN3LsYBKEjN1BFIptv5ws/+e7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fgxRA5FY/Y3BnroNCJSAs/SkYqNHKZIYAqQ9ZDyp95lCEnFzgzFfsqscwEWwrNxB7 uQtHGTUMb2hI6xZuJFudbn8u9UgicEkyvtejL+zO7QuL1GbxdNw2gu/C0udeE1odWM 8Z9sb74z43RyLNqHHkvo3keoW4ZsIcpf+huBRMhU= 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 4.19 06/30] ocfs2: fix zero out valid data Date: Mon, 2 Aug 2021 15:44:44 +0200 Message-Id: <20210802134334.281588173@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134334.081433902@linuxfoundation.org> References: <20210802134334.081433902@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 @@ -1943,7 +1943,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; @@ -1951,7 +1950,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; @@ -2006,6 +2005,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,