Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp739747rwd; Thu, 25 May 2023 03:17:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4jl8wevnSDQMHv74S4wlRMx70MqUwSOYvVUVLDWPuZV1Nf2EJIcLLMp3UUPelN3DRmTiC+ X-Received: by 2002:a05:6a21:9988:b0:10c:2349:459e with SMTP id ve8-20020a056a21998800b0010c2349459emr11907707pzb.10.1685009868584; Thu, 25 May 2023 03:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685009868; cv=none; d=google.com; s=arc-20160816; b=BbCaYbfuFRwRgfQqWS4fNDXur2jlNfWJmRgEkYcJtyCwhmQHhOhnVUI9WYLTzs/NZV JP9IDv6npmSk1wgUrqeAMA8HRTj9ekpsmBEoO7ao2HIQdghjpCwcJqGfzmtPdG5Smrxh Jr+aFnqGOp9s8nTvX1cN0m0nZxa9/vRGpwu+obIlKoVZchNI1KCbcfmTqnCC031x+3mp hEeoZ4lUVLWBemtlMg/8B3C14FvG2BeHDbhJtlxsBbDi2E8OMP4r/hEG+QpyasstyZ2N QYIdNrFykxOi+8uxXTwK8E2SzLmfk+Un+2XMYDRc6duOAfnub2EV9GA0IlhBVotDqqP7 vD2g== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=AasYIWFI1S7OWlc46V78pNTXYji7OAdfudjyszTriMw=; b=TPMm8sPR16hWZF4lgir6/udVRmCbFwzYrX/oI03TT1l2FEvwdyxgIzTMQ1KCV7Iqnc qHnIVFAI3uR/uAq3VMKo5ZvqIygTsigZlwdi8jwbiu0Rb6QludrU9OH4zmB9oUakrqO4 kWjZViJKEtpigI5hR0mcZXVl4z2kgmzOS1vcvBYcqwm7fZvIw7x/ntLHvIzvDMhF7Tq9 Sn4FeJ0tCNTwbZR2d1jfUho1egzZe0qZ7gDGMCYAFRFlBFljU3ij1duSs0GaXCO78kag Z2CQ2NIufECNAFHbZZJ0ikEAl8m4EzDEdJIuFUxdybcekaW9wXemQDnc8ddX2FZSQspu 2sTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=mWH844KE; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=JAspCTzd; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l65-20020a639144000000b0051fb9c77447si848832pge.477.2023.05.25.03.17.35; Thu, 25 May 2023 03:17:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=mWH844KE; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=JAspCTzd; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240897AbjEYKQk (ORCPT + 99 others); Thu, 25 May 2023 06:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240870AbjEYKQc (ORCPT ); Thu, 25 May 2023 06:16:32 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1207710B; Thu, 25 May 2023 03:16:26 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1845B21C08; Thu, 25 May 2023 10:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1685009785; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=AasYIWFI1S7OWlc46V78pNTXYji7OAdfudjyszTriMw=; b=mWH844KEiJBA1aZq1NytWIyeLer3NOjjdeY8DR7hO07w3I+IHXnxl+SrS16nEkQV+HZNLb uvQESm3OCthfc02m80uTeMbwRov1icKXWebSgS+qwAJvsf1tB3oxK9S69SMJo7ZzuRL5bx 4aPqc+JZNp4XQyLlMJP9J9WILa14P1I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1685009785; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=AasYIWFI1S7OWlc46V78pNTXYji7OAdfudjyszTriMw=; b=JAspCTzdhb5BLxVjzC9E1jjnrPIVPBwaqQKmWOxQR3nZa5P9WH3EGZHOOPI7Qst34zB4uY Ma/tFSPgjMV0p8Cg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0688813A88; Thu, 25 May 2023 10:16:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WhMeAXk1b2RJdgAAMHmgww (envelope-from ); Thu, 25 May 2023 10:16:25 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 52BCDA075C; Thu, 25 May 2023 12:16:24 +0200 (CEST) From: Jan Kara To: Al Viro Cc: , Christian Brauner , Miklos Szeredi , "Darrick J. Wong" , Ted Tso , Jaegeuk Kim , , linux-f2fs-devel@lists.sourceforge.net, , Jan Kara Subject: [PATCH 0/6] fs: Fix directory corruption when moving directories Date: Thu, 25 May 2023 12:16:06 +0200 Message-Id: <20230525100654.15069-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1241; i=jack@suse.cz; h=from:subject:message-id; bh=+SElWakzHXlPrUsPVn2OpQA3AfdfztYzyPNqGfZYghU=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBkbzVdxe0FvekPZapZQzM3DTu4EGJWLISXiQyJth5w rhLVGYaJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZG81XQAKCRCcnaoHP2RA2ZJ2CA Czq+c06ImKsEJ7Ml6bBcSTNMoqJbKxDWot8ruFWwB69bocSyVn+Et6BD1EWfID+4Su3doANPMimhj5 Cbct+zb2X5MtEVuocqaqTMhapWmj3EEME6oTzvgw7/yrhpeQygsZ7ZP3LvF/cw52EBdg+nLDfjw+4s GHEpw6ZBvokOhfJtpij1FRZIjg621Vq9ryBBY96RL72ubNtjzhSX5CtNTzegajAT9PP9ZR4pk0hI4o /NRB9XJ9gZCT4beVEfp8FVQicy9SeVPvR+Iik7L2lVtqV4WXcPl412g0Hfc5hiZ3yqc9ZHRY9ri3HZ MA/0r7lOkSYS3I/+tUbULxHeoSaINx X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hello, this patch set fixes a problem with cross directory renames originally reported in [1]. To quickly sum it up some filesystems (so far we know at least about ext4, udf, f2fs, ocfs2, likely also reiserfs, gfs2 and others) need to lock the directory when it is being renamed into another directory. This is because we need to update the parent pointer in the directory in that case and if that races with other operation on the directory (in particular a conversion from one directory format into another), bad things can happen. So far we've done the locking in the filesystem code but recently Darrick pointed out [2] that we've missed the RENAME_EXCHANGE case in our ext4 fix. That one is particularly nasty because RENAME_EXCHANGE can arbitrarily mix regular files and directories and proper lock ordering is not achievable in the filesystems alone. This patch set adds locking into vfs_rename() so that not only parent directories but also moved inodes (regardless whether they are directories or not) are locked when calling into the filesystem. Honza [1] https://lore.kernel.org/all/20230117123735.un7wbamlbdihninm@quack3 [2] https://lore.kernel.org/all/20230517045836.GA11594@frogsfrogsfrogs