Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1649580pxy; Mon, 2 Aug 2021 07:04:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqXwMxRHZdduKP8WXV2AVE5h02BloGjFmSVhKlGNt+qHDpmvdhfw65gYuYYCuBgsqnWvMA X-Received: by 2002:a17:906:14d0:: with SMTP id y16mr15674622ejc.248.1627913086499; Mon, 02 Aug 2021 07:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913086; cv=none; d=google.com; s=arc-20160816; b=paV/n8mVGQb9J+H2+NwFp3DnEcO/l+azDQJ+Y+m5gyxfc9xP9C4KXyxy+h7K+QUivw 2BOEl7BOq1Z5JP/vr6jlAtjt8i9+f7sAZUZd2A01prlVVUcdDCUgFiBvlU244HVQgzGI 9/3H3n1XzMNAe9Cz+tMbES72/z2C6gDk3Hzvo3eM2xaPXmZVXjfJpt3TwxRxBKBIx3mx kfsitYQZc9Hwoalfdg2El+uhGEHvfbtMLUE+snBHwRKKZXhjpcTkAszNxhAEV9+PdDRZ gF/QuFGvS13mKouUt67Csna3fkSZ0YELqz/apu2OrhKFCZ+pLPyeXrflyWivY3SDgMvn 0O9A== 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=ocmbavS0dJTHE07OeJaRTH1d7nJbRFjxLdh/wO7t2El3BFX07Ofl8EN26yv0C+5Zv0 H8toy8dnCpUAGU5WNljz3EeOn50lRKbEidT6vNMuFkwNhDsU3p5Nc3ONFSa8zeiUY3ay J5/PFQWjo5sKvP8cvdUjCRlesI3w+NaYFiTd/+9tx76gyCeK7f0hUBkz4Y1c+NyjIEuj ry0LSLkoNe91EOwrnY5yxQf/8U82p498U6smhkoPKN2CW7VqhetDuifvGSpw1Wjnyaq2 iCQzCDWGHVC0Ixxerrus5WDbu2ROblGSI4JVz0RzE7Ied7/Q+3efjZuRFU8twcIDCVb8 G35A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NoQXga9p; 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 h5si10087481ede.496.2021.08.02.07.04.23; Mon, 02 Aug 2021 07:04:46 -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=NoQXga9p; 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 S234656AbhHBOBr (ORCPT + 99 others); Mon, 2 Aug 2021 10:01:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:33610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234506AbhHBNxH (ORCPT ); Mon, 2 Aug 2021 09:53:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BCE3861159; Mon, 2 Aug 2021 13:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912328; bh=dB5qXChcL5U5nIwu+gk/y3fdb2nYynTde59+abisi+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NoQXga9pJOZnQRt6MRfuvWZWAeTb2/luA6R5p1gqXNYVYO6B/OvXZK7du0/tOVThj xh3aNJruhJCl5UZfNIE0Y6Zw7KqLvh8D63uIHmiIa1HODzISV9QLkW473YpLD6ZmWi xhzgjFS44iVGLYN2Xsu5IuM0Nbmr7Fg1CDFCAU+s= 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.10 10/67] ocfs2: fix zero out valid data Date: Mon, 2 Aug 2021 15:44:33 +0200 Message-Id: <20210802134339.365252787@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134339.023067817@linuxfoundation.org> References: <20210802134339.023067817@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,