Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp120571lqo; Thu, 16 May 2024 00:41:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYAywrXbvRPIHdkrwIvr2kYwAcUuPysT95mzjTphzr+B+OeeCZcI0B7jvOaXSo2pMryecSxFwjT/6IeUBED52DV5L1WPZpqx9Z3K2ZRw== X-Google-Smtp-Source: AGHT+IFzOsQILiMr6BVPiDxogGG3U8JTNTu/+T5rMaIR1XvZLsx9BMT21VfgEKh0y17IXh5ZXXd7 X-Received: by 2002:a50:8ace:0:b0:574:ec40:3ada with SMTP id 4fb4d7f45d1cf-574ec403b18mr4575994a12.40.1715845276063; Thu, 16 May 2024 00:41:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715845276; cv=pass; d=google.com; s=arc-20160816; b=FovMr/8mLgcMDT0+MoNkHGpWtVZYmf93vO93RfpNS0gBTsB9mTsUrXTTHcFjDDamyM J3IzoJkKwxeZ1bOT9z09pDmJen09eONpcL8uyprAbfpKQMSbbKDAjbtSjLvPc+qL+JAf phsXb9OAduzz+UfxOAvyX6pnwZrKjdJJzdU9ueH+JPgiJI5I3xURWbF5ZNlgn9FWIdSs cHgbEVF1eCXOnUxb3VEwbUeVdJKCp2T3GmRRkEbjE0yHT6iYJkaBDha264trt6Dq0U+y 9xf7MJ3bekuxOdI+gWmkcB1vE49OLQWP4w1ZrIA4EtPj7JnI8owAoWvR/BJp5reYTSoV 2RAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=36UIQ8mNFTwawUbpDgYzIUQBkZIwQ0iiwnSj0yY2iWA=; fh=0HaASOXEjGqpxPrGhdU7uT3vKkOGyiI675Dvy1SUF+c=; b=oeMf3CrbP4YikxjEJiQcpceFTH/T4PO0yE25aSVN5IY0qAQZTlbLJqa7JfGxnYo06O 81bqicyaRqkW86O5yv8fou9LT57rpO6jjEtk39mLMkkE0Wo1HcbJVR0p/Ii/O5asVPcj jstRqWe6tvABzpsITSsDF8iwIcjU1HgKGe8CqlkMWmTAQBET/uar3MfOaR50pMU6LRb5 M+Yi5IuFviK3KZJ/5Vc0Esg49o527pxRWUCrpxUAZk5/y2y/yqSpimF1b2FAA2dnrHS6 rfuluc/u9r0fr2UZhy3QIvFXDWdx+uXz1MYZqhazusUm2yis3sgWwfsqeg8di2k1bFu9 TP2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-180710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180710-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c32c7bfsi8272639a12.449.2024.05.16.00.41.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 00:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-180710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180710-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C71C21F21256 for ; Thu, 16 May 2024 07:41:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B005130AD8; Thu, 16 May 2024 07:40:42 +0000 (UTC) Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8839028DD1; Thu, 16 May 2024 07:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715845241; cv=none; b=rr8i1XSKusDv/uVaMB8Dk+81PdTfJCqoDE+5hjxrfAg6t3xpGdcD5hikpvTvHoaglEbDABXSLqRam/3PsdSWUq0FYaytwVus9JQTFk2+c/csGWOEOBPb/C8vM+8ntNOCMp52Z/AJvrpvJN8CuhFGE3Df8VcW/FWkk9XOrhZbSQI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715845241; c=relaxed/simple; bh=mEaKmv5UPk7MYJdN06YN/FyqoRm0lwQ1F7u9FB8ErgE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=HyuIUGD9fBuGyTX0HPzJTZo2GOe8xH5S18G1YgPqAidmm88lPDyFYxG4Dl30qTLtusNXskFGC5zR9IVwf81KW9mQITTdjjcha2GNDFlHdzxt7QtOWjXsfUoU8Mq9B6BUr9Et1Ra13OOf969pDvOUwTEFYbv1eIDSIt3LOgJ+wkU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Vg27Z0qxDz4f3jYK; Thu, 16 May 2024 15:40:26 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id CA0161A0B17; Thu, 16 May 2024 15:40:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBFtuEVmQuY4Mw--.31554S4; Thu, 16 May 2024 15:40:32 +0800 (CST) From: Zhang Yi To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, djwong@kernel.org, hch@infradead.org, brauner@kernel.org, david@fromorbit.com, chandanbabu@kernel.org, jack@suse.cz, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [PATCH v2 0/3] iomap/xfs: fix stale data exposure when truncating realtime inodes Date: Thu, 16 May 2024 15:29:58 +0800 Message-Id: <20240516073001.1066373-1-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgBXKBFtuEVmQuY4Mw--.31554S4 X-Coremail-Antispam: 1UD129KBjvJXoWxJry5KFWDAw48AFy7WF4rXwb_yoW8GFyxpF s5Kry3Wr18Cry3Za4fua1qv345J3W0yrWUuFyxtwnxZasFqFyIyr10ka10gayDKrykXr4U Wr15JFZ7uFn5Ar7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvY14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2 Y2ka0xkIwI1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4 xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43 MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I 0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v2 6r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0J UZa9-UUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ Changes since v1: - In iomap_truncate_page() and dax_truncate_page(), for the case of truncate blocksize is not power of 2, use do_dive() to calculate the offset. This series fix a stale data exposure issue reported by Chandan when running fstests generic/561 on xfs with realtime device[1]. The real problem is xfs_setattr_size() doesn't zero out enough range when truncating a realtime inode, please see the third patch or [1] for details. The first two patches modify iomap_truncate_page() and dax_truncate_page() to pass filesystem identified blocksize, and drop the assumption of i_blocksize() as Dave suggested. The third patch fix the issue by modifying xfs_truncate_page() to pass the correct blocksize, and make sure zeroed range have been flushed to disk before updating i_size. [1] https://lore.kernel.org/linux-xfs/87ttj8ircu.fsf@debian-BULLSEYE-live-builder-AMD64/ Thanks, Yi. Zhang Yi (3): iomap: pass blocksize to iomap_truncate_page() fsdax: pass blocksize to dax_truncate_page() xfs: correct the zeroing truncate range fs/dax.c | 11 ++++++----- fs/ext2/inode.c | 4 ++-- fs/iomap/buffered-io.c | 11 ++++++----- fs/xfs/xfs_iomap.c | 36 ++++++++++++++++++++++++++++++++---- fs/xfs/xfs_iops.c | 10 ---------- include/linux/dax.h | 4 ++-- include/linux/iomap.h | 4 ++-- 7 files changed, 50 insertions(+), 30 deletions(-) -- 2.39.2