From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70F38C433EF for ; Tue, 15 Feb 2022 16:18:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241448AbiBOQS5 (ORCPT ); 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 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...