From patchwork Wed Mar 8 04:12:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 1753878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=bsko=7a=vger.kernel.org=linux-ext4-owner@ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256 header.s=outgoing header.b=P9nESfTl; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PWf7X1m1Yz1yWm for ; Wed, 8 Mar 2023 15:13:27 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4PWf7W4J90z4x8y for ; Wed, 8 Mar 2023 15:13:27 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4PWf7W4FT4z4xD5; Wed, 8 Mar 2023 15:13:27 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=fail (p=none dis=none) header.from=mit.edu Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256 header.s=outgoing header.b=P9nESfTl; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4PWf7W3Qlfz4x8y for ; Wed, 8 Mar 2023 15:13:27 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229682AbjCHENZ (ORCPT ); Tue, 7 Mar 2023 23:13:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbjCHENX (ORCPT ); Tue, 7 Mar 2023 23:13:23 -0500 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1054E2ED69 for ; Tue, 7 Mar 2023 20:13:20 -0800 (PST) Received: from cwcc.thunk.org (pool-173-48-120-46.bstnma.fios.verizon.net [173.48.120.46]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 3284CrIN013130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 7 Mar 2023 23:12:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1678248774; bh=VGjkpxfGkbQyIgMVSqr1tL9qWwI57H3pwg1+SKgSuBs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=P9nESfTldufA08q8I39Vh+TsNF+nJKQEAPvYTNVai0Kv+MuEHXyhlJaheyiWZZu4b DDw1ysAUK4HFYqsroDpxMF2pBDz62iJBxBzjkjaG/KQYQlW65dC2H4kiGoRRaPGqFn nfTD/RCr2bPOU8m2BLcCLdzaiepkGAyp8xAcin/+3abdqprtkYgQm10AfZYdyihFOI fBg4hJNHKulfswWkARPE8V7wdPT1YHW7lzHsaviFMSzKMH0weZH/F1Em2DW5ONoklV aXheSXb1Ans1mUgznLRUDYrmQwRYpGUcHxs9Z5jMRFvyU5l8PckOsRMisfv6NMTRDX GTyTFLQJpsjig== Received: by cwcc.thunk.org (Postfix, from userid 15806) id E0F9E15C3441; Tue, 7 Mar 2023 23:12:52 -0500 (EST) Date: Tue, 7 Mar 2023 23:12:52 -0500 From: "Theodore Ts'o" To: bugzilla-daemon@kernel.org Cc: linux-ext4@vger.kernel.org, chengzhihao1@huawei.com Subject: [PATCH] ext4: swap i_disksize when swaping the boot loader inode Message-ID: <20230308041252.GC860405@mit.edu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org The following patch fixes the reported issue. From f4e156cef119f3ffcc56874da4fb9299cc14f68e Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 7 Mar 2023 23:06:59 -0500 Subject: [PATCH] ext4: swap i_disksize when swaping the boot loader inode Normally well-behaved of EXT4_IOC_SWAP_BOOT won't actually try to write to the either inode after using the ioctl, but if they do, the fact that we're not swapping ei->i_disksize as well as inode->i_size can trigger warnings. Link: https://bugzilla.kernel.org/show_bug.cgi?id=217159 Signed-off-by: Theodore Ts'o --- fs/ext4/ioctl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 2e8c34036313..e552c5db0c95 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -329,9 +329,13 @@ static void swap_inode_data(struct inode *inode1, struct inode *inode2) ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS); ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS); - isize = i_size_read(inode1); - i_size_write(inode1, i_size_read(inode2)); - i_size_write(inode2, isize); + /* + * Both inodes are locked, so we don't need to fool around + * with i_size_read() and i_size_write(). + */ + isize = inode1->i_size; + inode1->i_size = ei1->i_disksize = inode2->i_size; + inode2->i_size = ei2->i_disksize = isize; } void ext4_reset_inode_seed(struct inode *inode)