Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp671228pxb; Wed, 16 Feb 2022 01:34:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOU/U/aL1Ign/R5Oq6n7iapSk8SWjFaDcPnTLv8bpY7fhnYcicLJgRcdK70E6Yi4U0Wl/f X-Received: by 2002:a17:90b:616:b0:1b8:c05e:bd2e with SMTP id gb22-20020a17090b061600b001b8c05ebd2emr718145pjb.176.1645004057446; Wed, 16 Feb 2022 01:34:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645004057; cv=none; d=google.com; s=arc-20160816; b=SfkmbCZSGs0gesr1Fup3STIur1kkDuxnVAqBnDLzkMJTqIgglV/RGuYaPFdA4D+8YR zxW2teybgOn40HOtbfFGuSOSbZD4aJRgRzWXevL0NpTT4amVzncehQF90wa7BFS5Zp7O e83UVolUt3nGQtjI4neoHuyPzH6NwJkqA3fsms7Go611qm1LAbess4RFChsHQtrDIBCe b2zAi8OPp2FlgywGtdPtE9O1k3SiObsCOX89PyR11NhldWgf4pTlWa42QhuklClFGFgG FXVCMWOXe6WafU6TgJMfdveO4DeR8nliWdRkqVT0mFGZKnGa7U5lebxTvNqhQSGGW6tD St1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=HIWRlgaDSkeBDbWx7Q12aTkk4hl9N3e3axYauo6Q7y8=; b=k7xVoSr7eDVXGTQxbtLSAvUp39jT3pZ2G8kSM+KPfBseBGNY8d9xdCXVcj8o/MMCnI /woJQiNFsNCE7MVe7DYNL56u0+XzboegemboaQL1MKjovMfDDXsvVqRlR7SjqztCXUAx bxk5U7D2z6qIQaaDchZeqcO+nSbZpf/gRoAQ9flw8aM/biS9Et3xk66YLVNiKE892x6d U1HHNmNowYy20ROaq/nIORpqauRzotkm+xc4GsgyxX2M5qh78cmLZcrfYxdrC7nIEZeD 3FuNetTZ9tLHHK4B5o98zRDRg9HYADMnNBd8MyBqfEX8yhw1UiyoT1iQyBAlRP27vYp+ 1ChQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=Oi5KUcrC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h18si13680402plf.517.2022.02.16.01.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 01:34:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=Oi5KUcrC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F5362599C5; Wed, 16 Feb 2022 01:28:42 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232213AbiBPJ2u (ORCPT + 99 others); Wed, 16 Feb 2022 04:28:50 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:60038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231768AbiBPJ2r (ORCPT ); Wed, 16 Feb 2022 04:28:47 -0500 Received: from mail-vs1-xe2e.google.com (mail-vs1-xe2e.google.com [IPv6:2607:f8b0:4864:20::e2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F7A12221A6 for ; Wed, 16 Feb 2022 01:28:32 -0800 (PST) Received: by mail-vs1-xe2e.google.com with SMTP id e5so1717475vsg.12 for ; Wed, 16 Feb 2022 01:28:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HIWRlgaDSkeBDbWx7Q12aTkk4hl9N3e3axYauo6Q7y8=; b=Oi5KUcrCgG1zk1IjbWUdDP4mUwWswxl2Iqqar8TFi1N0tmPHfriBpDgBqL+FFJUdr9 m8GK7sG+3NrUeONujCZCvnXBM3Y/KjoLQqNzqMqA6v/wPZX0EpnVLxMMFv1maRDBf+lm UYI7yL1yNxTTsCV494hxMcR70Yz96KVJmKPpg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HIWRlgaDSkeBDbWx7Q12aTkk4hl9N3e3axYauo6Q7y8=; b=u5fd+s6NYSXBWAjx7dfqc7eh+PUZi9VLch5gg1uAIdbDBgdgH/PZwnWrFs1zWfmFcy WrTUXmlpv5sFxkRnMeaOJe2UEOgob/OjQDTFWcrdMxUlgtfTtW7CiKuNGsJxP2WyJo7r i6yoU68HFFCKvjOLsL8RYoSQgkDl/fEQ9Yd1dK04mIRI5sP0KEoAVt8a5XBiyo7deDSu LOk4NV6MPMPqaROik5rv5ZICHFLGnpxUonPT/d8Zv0UIrszcuY5u39aEZA9YZ3wUXubB J2MLRW7WklwYoAHYDLXzSWc6ARcz9cA/fTVg+e98lV9wnha8NcpZHLypLRSR0DYP852h b1CQ== X-Gm-Message-State: AOAM5317TbcAbm3wYfydpeLp/xDZoIKsebTyg9Afq4fpYz7L/SJQ/or1 a3Tajlbut6iFVwspM49/oP3+lxJyMPBcqrnf3iwyTQ== X-Received: by 2002:a67:e0cc:0:b0:31b:d7bf:8403 with SMTP id m12-20020a67e0cc000000b0031bd7bf8403mr24961vsl.61.1645003711356; Wed, 16 Feb 2022 01:28:31 -0800 (PST) MIME-Version: 1.0 References: <20220214210708.GA2167841@xavier-xps> In-Reply-To: From: Miklos Szeredi Date: Wed, 16 Feb 2022 10:28:20 +0100 Message-ID: Subject: Re: race between vfs_rename and do_linkat (mv and link) To: Al Viro Cc: Matthew Wilcox , Xavier Roche , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Aneesh Kumar K.V" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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, 15 Feb 2022 at 17:20, Al Viro wrote: > > On Tue, Feb 15, 2022 at 04:17:11PM +0000, Matthew Wilcox wrote: > > On Tue, Feb 15, 2022 at 04:06:06PM +0000, Al Viro wrote: > > > On Tue, Feb 15, 2022 at 01:37:40PM +0000, Al Viro wrote: > > > > On Tue, Feb 15, 2022 at 10:56:29AM +0100, Miklos Szeredi wrote: > > > > > > > > > Doing "lock_rename() + lookup last components" would fix this race. > > > > > > "Fucking ugly" is inadequate for the likely results of that approach. > > > It's guaranteed to be a source of headache for pretty much ever after. So this is a fairly special situation. How about adding a new rwsem (could possibly be global or per-fs)? - acquired for read in lock_rename() before inode locks - acquired for write in do_linkat before inode locks, but only on retry Thanks, Miklos