Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3754372rdh; Tue, 28 Nov 2023 03:03:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFg+qhf37su0I2lhGu4ZgRvaxJd2jCNyKgZCqGQgpppYH09UvVPVVUIc1NUPJIuWPoMegEt X-Received: by 2002:a17:902:d2c6:b0:1cf:cf34:d4fa with SMTP id n6-20020a170902d2c600b001cfcf34d4famr7778039plc.28.1701169400245; Tue, 28 Nov 2023 03:03:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701169400; cv=none; d=google.com; s=arc-20160816; b=mzsgADPxdQ4bw+Fju/Xrxgs2XRwwbrv5QRaEUv7o5ay4kujEPxw4JlI56eKIgQjDzT 8Ukqq79Q5nJMv80HEQK5JzVikXQpLWhLa6DmGBDD5ke5O091pSDu6z7JIGAQ+A0hQtQZ m9WUvECbg3NZjus3wnR5gaDymWNiNTQob602/DC5LkvF+2cmzcGBg4tnmEzKpkjberkj bOlWEKB70l+HyPybU7upa5rYmD7NobiO7uMJvdozZL3vhT3CUqWSVymfsgIV6LRIqtOq u7Zkv3cZnhFqAI1yOimq05xw97G2C+MQiL76ow3uIlCAT9f5fvchypaUKBnhptGGkm0u u59Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=kVD9cpIxQxlHQBTO+E9xaUGf8SVgbYHSIaOxapk5BPo=; fh=uCdozlQblfCL7ZaJaLqUSQ0x3zdZBLehz97Yt0joaSs=; b=SG1mcjgE5QtW1WY2vnnUMvr/rcT5RwoMcE/Dm6KNzMJ7/ku907ND75vEwE+53ktiXu 3UP+vd9j7ZmQQKHsIxPH+jngxR7lFPiSMxu6GVew2Jb5rQvVEwTD5jH7qTcRvoZoqbZO Usb2W4V5QAqsB0PGCXfDY2wkAKSNGe8BTp9MKBAs9xxT+lZVYOLsCtRTwIkI2f+1yzSY aKmiZmlAvgFYwf+GxIwTQu3BgS0+tGR/EjH2TF31EoUoxsO9GiCvffvfE634uKKUEYBB ofu/EqoiB4rMiJy5g3WcGoT0uQiDpQovYEaZ2/qvwCccmmk8H2dsbKl/6YsK3EFdgPI3 M7yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id j7-20020a170902da8700b001d0050e2466si405463plx.23.2023.11.28.03.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 03:03:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8FCC680579B4; Tue, 28 Nov 2023 03:03:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344294AbjK1LC6 (ORCPT + 99 others); Tue, 28 Nov 2023 06:02:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344194AbjK1LC5 (ORCPT ); Tue, 28 Nov 2023 06:02:57 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DDB4D6 for ; Tue, 28 Nov 2023 03:03:03 -0800 (PST) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 23ACC2195A; Tue, 28 Nov 2023 11:03:02 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 1A1FA139FC; Tue, 28 Nov 2023 11:03:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id UV1cBubIZWUVcAAAn2gu4w (envelope-from ); Tue, 28 Nov 2023 11:03:02 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id A8438A07CB; Tue, 28 Nov 2023 12:03:01 +0100 (CET) Date: Tue, 28 Nov 2023 12:03:01 +0100 From: Jan Kara To: Chao Yu Cc: jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Jan Kara , Al Viro Subject: Re: [PATCH] f2fs: fix to avoid dirent corruption Message-ID: <20231128110301.pk3qbhopptmhvxet@quack3> References: <20231128092516.2882629-1-chao@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231128092516.2882629-1-chao@kernel.org> X-Spamd-Bar: ++++++++++++++ X-Spam-Score: 14.12 X-Rspamd-Server: rspamd1 Authentication-Results: smtp-out1.suse.de; dkim=none; spf=softfail (smtp-out1.suse.de: 2a07:de40:b281:104:10:150:64:98 is neither permitted nor denied by domain of jack@suse.cz) smtp.mailfrom=jack@suse.cz; dmarc=none X-Rspamd-Queue-Id: 23ACC2195A X-Spamd-Result: default: False [14.12 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(2.75)[0.917]; MIME_GOOD(-0.10)[text/plain]; MID_RHS_NOT_FQDN(0.50)[]; DMARC_NA(1.20)[suse.cz]; R_SPF_SOFTFAIL(4.60)[~all:c]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; NEURAL_SPAM_LONG(3.50)[1.000]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.52)[80.29%] X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 28 Nov 2023 03:03:13 -0800 (PST) On Tue 28-11-23 17:25:16, Chao Yu wrote: > As Al reported in link[1]: > > f2fs_rename() > ... > if (old_dir != new_dir && !whiteout) > f2fs_set_link(old_inode, old_dir_entry, > old_dir_page, new_dir); > else > f2fs_put_page(old_dir_page, 0); > > You want correct inumber in the ".." link. And cross-directory > rename does move the source to new parent, even if you'd been asked > to leave a whiteout in the old place. > > [1] https://lore.kernel.org/all/20231017055040.GN800259@ZenIV/ > > With below testcase, it may cause dirent corruption, due to it missed > to call f2fs_set_link() to update ".." link to new directory. > - mkdir -p dir/foo > - renameat2 -w dir/foo bar > > [ASSERT] (__chk_dots_dentries:1421) --> Bad inode number[0x4] for '..', parent parent ino is [0x3] > [FSCK] other corrupted bugs [Fail] > > Fixes: 7e01e7ad746b ("f2fs: support RENAME_WHITEOUT") > Cc: Jan Kara > Reported-by: Al Viro > Signed-off-by: Chao Yu Thanks for fixing this! Makes sense to me so feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/f2fs/namei.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > index 3b1793cfb002..ede6afb81762 100644 > --- a/fs/f2fs/namei.c > +++ b/fs/f2fs/namei.c > @@ -1105,7 +1105,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, > } > > if (old_dir_entry) { > - if (old_dir != new_dir && !whiteout) > + if (old_dir != new_dir) > f2fs_set_link(old_inode, old_dir_entry, > old_dir_page, new_dir); > else > -- > 2.40.1 > -- Jan Kara SUSE Labs, CR