Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp586341pxb; Tue, 15 Feb 2022 22:58:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5w3PyYRyit1D4TXz5hBdX49xGb8uZnuKPRO/FWarVND2FPPRcNC/MXmKP/VdoY84zNe2Q X-Received: by 2002:a63:dc08:0:b0:372:be18:dafc with SMTP id s8-20020a63dc08000000b00372be18dafcmr1173156pgg.440.1644994714680; Tue, 15 Feb 2022 22:58:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644994714; cv=none; d=google.com; s=arc-20160816; b=qQA+4sBzA9kGnmjHmMSvV0mgzB00/ogoGj9x987aOeH5f/RVKzcBOzO5YasuAsErG/ TMhjgZz/r8AX6FjxGokl/DRqhTOQquCn9ES0U6j1cKSBinHZXeUxqgIqifs/QOH2UiFx 3qyGmic20WJTtRvaMEcCjsA/vUU6aZefQ/9ApAMLISGtq4RYi5WDcHwloWq5QwHkua79 zFlkOrh/jw45JlGLgXEOZxmA4nx1Ca3mZ0wO/dk9za4X/nQeDwQZ+cT2yofz7jHJkb1k 1+dOPXb/nzH4Ktf5+xiB1jT+jKbm/bL0UAZWAQOoEDhQ6qJ8KQM7k5LypxKpTVfNSs0L yldg== 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=CTD0R2NOgNcJLdbUJz5dAaVgssfgbc+D7nRnw1PVfGQ=; b=avJ2KzBnLoZWSnXJQxEaGgmROiW7dh6ALhKFgoy0q5MXpwODVPmaU97WLKEQAbW3v0 Y0vWJTFtmCbh3RDOpuFbaQ3+/YzEQTa9nE6p57sQ2he7ReitKP5kCyjh+OC0AaKdrM1c a3mvqrBtfBFhlDCn3mTIIh3VWZrPzs/y14CsXPvsgpPzZTL3F0IcfKyZTpP0vELpRIYO MSquBs6+bEtlcCAUHWZIIpVckpKystkkbI0QuuHXKigFef4fhAbybK/69qwRKSUOFSLy e97DLGU6jwIwB226IK5ST89VUcgqVSmPunal6T+UT1Um/qEaOpeYD9q1W3mril1Vk/F2 /RnA== 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: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 y2si4729972pgf.840.2022.02.15.22.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:58:34 -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; 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 495C0237415; Tue, 15 Feb 2022 22:40:40 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241445AbiBOQS5 (ORCPT + 99 others); Tue, 15 Feb 2022 11:18:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237417AbiBOQSz (ORCPT ); Tue, 15 Feb 2022 11:18:55 -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 0C60213FA7; Tue, 15 Feb 2022 08:18:46 -0800 (PST) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nK0XM-0021iO-20; Tue, 15 Feb 2022 16:18:44 +0000 Date: Tue, 15 Feb 2022 16:18:44 +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=-1.9 required=5.0 tests=BAYES_00, 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, Feb 15, 2022 at 04:06:06PM +0000, Al Viro wrote: > Worse, you need to deal with the corner cases. "/" or anything ending on > "." or ".." can be rejected (no links to directories) and thankfully we > do not allow AT_EMPTY for linkat(2), but... procfs symlinks are in the That'd be AT_EMPTY_PATH, obviously, and unfortunately we do allow that. Which brings another fun case to deal with. Same problem with "what's the parent of that thing and how do we make it stable?"... Oh, and you need to cope with O_TMPFILE ones as well - both for that and for procfs symlinks to them. Which is fine from the vfs_link() POV (see I_LINKABLE check in there), but the locking is outside of that, so we need to deal with that joy. And _there_ you have no parent at all - what could it be, anyway? So we'd need to decide what to lock. *AND* we have the possibility of another thread doing link(2) on what used to be O_TMPFILE, which would give it a parent by the time we get to doing the actual operation...