Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1639173pxy; Mon, 2 Aug 2021 06:51:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH19qjqKVRpswSratg6jg45ysDwcjC0VH73npGzZ5Hs76o0PTEWaImbDC2Fz41VgXbYqlX X-Received: by 2002:a05:6602:198:: with SMTP id m24mr1028219ioo.144.1627912277191; Mon, 02 Aug 2021 06:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912277; cv=none; d=google.com; s=arc-20160816; b=uLZrKb6k3MRP+q3SDb54eEHX1pJfjh7iY9V543Ulkaw8r3jOvwuLr+A4+qKKTYnzHE 8tp3tZo5azs8fFdMq3kTuXag3QB5vlLTM0ZnQi1wrocoIDYPj5g1k5JX9adYjMB7ugxX dB/E6wsmF8rGWyzKPzO4QWovYQLVvSyfVZl2I92SOM/fgF7Bf9N+kZJ9o5S+bj+o6kYo 5VkTsSbHunP40CT8oYkEfDJJajH4Ehw2pgbl0+2GqfS0JOUL9BpRlV3zXldEC4Ynb5hg O0fLXIC5zX2s2p4jmKg2UVDEkYglqH2/ZiE8IHG0fiBKO/pjUiBotFoUryqaCaS24+wi 1IYg== 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=U7kQ4gTi1oSETN2dmjmEUVonPnoKzwvIzEog0hxoFIY=; b=W8TbJY8vKZqYGxxl0qNrng3yQnD0jpyNPNZ8N50vFnaMVqhHdbfrFeT3+4wuqgQjQr Vg2Im3sVI4gG4lbBpVLN3aDKdnJMFeCd+NUB/Y5+Jy5zioOyqBb/YIHvgzXdJiX83Yu1 kWTy2SYCG6d0BAk5o6o25Uv2M0bHHH6b3alnK+MtS7uqdpqx0HPsjQaVYahEhJ76pkws goDVIxLfJof0FfER7uOWwzbWqckzG4MDucsjxEbSZeeaBcU0y8XYyB1gwKFl+mC6e7bR FatkU/OeRAKAL+hPKnwm9J1IizwD8TeNvHEAWklfVUFuqfMAUpsmlcB+vAQcpMtNMC68 cdVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MuxdZ0de; 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 w11si13892588ill.114.2021.08.02.06.51.04; Mon, 02 Aug 2021 06:51:17 -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=MuxdZ0de; 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 S234483AbhHBNsx (ORCPT + 99 others); Mon, 2 Aug 2021 09:48:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:57150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234021AbhHBNrS (ORCPT ); Mon, 2 Aug 2021 09:47:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E90A96113D; Mon, 2 Aug 2021 13:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912028; bh=uGggKJwXB1mT2oXtYwnSUtsMjHkK5yv+CjgCzmOphao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MuxdZ0de4oxzJYoyp26LRTtKWFsBgNdf5nfmWeHmh3HLFIByYQ6EAUAGR33HdF+gA SNJZ4fFoHP6RPiSmUIiLY0H4+UcpawB8Ko6GbIi01ywHv1jF6UDAdzrRit67bNz3mG yK1zkXd8Rpo5kGANv4F/dChr9LgtU7YhkzXrb6fg= 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.9 16/32] ocfs2: fix zero out valid data Date: Mon, 2 Aug 2021 15:44:36 +0200 Message-Id: <20210802134333.438972029@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134332.931915241@linuxfoundation.org> References: <20210802134332.931915241@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 @@ -1918,7 +1918,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; @@ -1926,7 +1925,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; @@ -1981,6 +1980,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,