Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp375202pxb; Tue, 15 Feb 2022 15:52:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPpnlrcGi7goSBAsd7EimwSoWqjJ46oZ1vSnj/WZ4wENsqjC9nGFGo1GdV+2cKifUswUqx X-Received: by 2002:a17:906:7f91:b0:6b9:843f:d539 with SMTP id f17-20020a1709067f9100b006b9843fd539mr312846ejr.410.1644969135239; Tue, 15 Feb 2022 15:52:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644969135; cv=none; d=google.com; s=arc-20160816; b=PMd2brTnayANIksCyId49I/tdrSC2bS02SCU/kdxBJOVZM5u8KCj6p6LgYp3aF5zzG Oj5sMii4u20hxyKwCF3J8O4pR3xRbA1+Rdn7TbLTZ2Rqn3BxipAEcsNXMbdeg5ty/NYz +F3oCap6pLAIunIg4My5NdMK2IBsbnGcpdhaqQK53ZfKPVQNUWWCZCwowV2NAErHJ45Y h6J0j19xWduiXAwpzdAWwc3qZ0eeSMqWMTit8acx1BoAVIVMsBfo9yZIYyRLbyWtml9U HXrPulUxQE+3eh3mYjNqvv41gEFbrPVQNhqCzcfrMUZ3vlBcVcqY9h3XXgdk2tyWunIW 2GSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Qnl/t2ZIT45/U88P5e5mSxYia9tj6ziaNHb242gFaw4=; b=OKjGgD0wt/8/NZLdUeqsDcbbwdAK3RFA9RTnZrlVpmIlwwbz92Nh+ZAwtG4F/7Liea nN8pH9aDgdjJGJLOskwILoLYOrXX0UdoVa5JVjd71m2Aok5IjS+MQk8Z2xYGgsx4EkMT 4+xtiT5FymZEF1aFNMoTvzHCA5gTNvw2GSUdSC6qRtGHp3tgDJ1mUoVzdJgCLl75cOrd un22sI0eeHHZoMJ6TRBWiVwMU4veyuuxxs5WAKWYbs7z/VheeigAlctMR/42LqUMu2AK 90mYfazok/8gasXLPD9kZTXPTwffe0AAAch0I6EpFIwRQOdk8GoTdOlHyd50zP8wvwA7 9r+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 fz1si16724066ejc.316.2022.02.15.15.51.52; Tue, 15 Feb 2022 15:52:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238358AbiBONhx (ORCPT + 99 others); Tue, 15 Feb 2022 08:37:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234825AbiBONhw (ORCPT ); Tue, 15 Feb 2022 08:37:52 -0500 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBFE06E8DE; Tue, 15 Feb 2022 05:37:42 -0800 (PST) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJy1U-001zgX-Bx; Tue, 15 Feb 2022 13:37:40 +0000 Date: Tue, 15 Feb 2022 13:37:40 +0000 From: Al Viro To: Miklos Szeredi Cc: Xavier Roche , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Aneesh Kumar K.V" Subject: Re: race between vfs_rename and do_linkat (mv and link) Message-ID: References: <20220214210708.GA2167841@xavier-xps> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org On Tue, Feb 15, 2022 at 10:56:29AM +0100, Miklos Szeredi wrote: > Doing "lock_rename() + lookup last components" would fix this race. No go - thanks to the possibility of AT_SYMLINK_FOLLOW there. Think of it - we'd need to * lock parents (both at the same time) * look up the last component of source * if it turns a symlink - unlock parents and repeat the entire thing for its body, except when asked not to. * when we are done with the source, look the last component of target up ... and then there is sodding -ESTALE handling, with all the elegance that brings in. > If this was only done on retry, then that would prevent possible > performance regressions, at the cost of extra complexity. Extra compared to the above, that is. How delightful...