Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1038264ybl; Sat, 18 Jan 2020 17:14:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyvKZ96diwAiDP7+JiSQ/sRyJvf2nZPB4a7/qm3kaT6H6QSvhOj9Ra5Qr2Ts5kk5VHc5z2E X-Received: by 2002:a54:4595:: with SMTP id z21mr8703632oib.136.1579396497134; Sat, 18 Jan 2020 17:14:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579396497; cv=none; d=google.com; s=arc-20160816; b=E4lYXu9AZquN7OGVCzl7hadvTRw3HKy8pyh3hYo8Gb3V/BVn5yEhQmwSjpUrU73N7G Db+00723EDzMQKFaKF2zWi74Yc1TpPiq1mAdo+zFk2GxN8UhJGXx6+Fb9HgOzDr3bjl5 +DIhKO34nymN9OzQsmOstu99OVZPENyiqUoiZzkbEcUTl2/WyBXcsrDhCpRsPeCQH4jt 89u7hmGDJTgHLqt8UntVlmiYyhzOcDWlfUnbDaso9Z8YgSijl6BDlCIvexhhQN1JHtZ2 FGeg+ACYV3peIef6+8mWFIDxlO/0NNo6+ZtGbH7ykQeRVXJJ8L+57KEVZ/Ac2DoLEuCQ HeEw== 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=8kn2OldutxkukdjEFOnqyAvk/+SJHYFGbHNI3REBkaY=; b=nhRKyQbNMZ8eErIns8kKTf1xm10XuS4wJUssfP8aiK1uBeTx/FKdK92Uq7lwn7L6/x sGgSpkfW4QlsigOnRedmz0OoVpZ2PYMSZ65wDBnSXkXUoFKaW8zKpZhstlRhG0fgTZMD GVKCyuyNPISDvgSJBQ8S9NfATExlKdXVvo31o8d+g8pDmQv04VCtcc+4V+1pbe0ItAGe YOdz/FNTHTwi4/ce5FDfOHX+ssV6TrAcFJi2W19A/W1YlYphUVOsgLd6yYQq0IP7QnzS vklP4ZEZSblIP44mmYMOe16CLxZ2hGBP2xgAWTMfusNFUKrHE12bgj1nRHFT+x2I4dVT PwTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si15497989otc.130.2020.01.18.17.14.45; Sat, 18 Jan 2020 17:14:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728689AbgASBNz (ORCPT + 99 others); Sat, 18 Jan 2020 20:13:55 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:55418 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727070AbgASBNz (ORCPT ); Sat, 18 Jan 2020 20:13:55 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1isz8j-00BC8q-D7; Sun, 19 Jan 2020 01:12:43 +0000 Date: Sun, 19 Jan 2020 01:12:33 +0000 From: Al Viro To: Aleksa Sarai Cc: Jeff Layton , "J. Bruce Fields" , Shuah Khan , Florian Weimer , David Laight , Christian Brauner , quae@daurnimator.com, dev@opencontainers.org, containers@lists.linux-foundation.org, libc-alpha@sourceware.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v3 0/2] openat2: minor uapi cleanups Message-ID: <20200119011233.GU8904@ZenIV.linux.org.uk> References: <20200115144831.GJ8904@ZenIV.linux.org.uk> <20200118120800.16358-1-cyphar@cyphar.com> <20200118152833.GS8904@ZenIV.linux.org.uk> <20200118180941.GT8904@ZenIV.linux.org.uk> <20200118230313.y4a3s7elierw4wzw@yavin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200118230313.y4a3s7elierw4wzw@yavin> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 19, 2020 at 10:03:13AM +1100, Aleksa Sarai wrote: > > possibly trigger? The only things that ever clean ->root.mnt are > > You're quite right -- the codepath I was worried about was pick_link() > failing (which *does* clear nd->path.mnt, and I must've misread it at > the time as nd->root.mnt). pick_link() (allocation failure of external stack in RCU case, followed by failure to legitimize the link) is, unfortunately, subtle and nasty. We *must* path_put() the link; if we'd managed to legitimize the mount and failed on dentry, the mount needs to be dropped. No way around it. And while everything else there can be left for soon-to-be-reached terminate_walk(), this cannot. We have no good way to pass what we need to drop to the place where that eventual terminate_walk() drops rcu_read_lock(). So we end up having to do what terminate_walk() would've done and do it right there, so we could do that path_put(link) before we bugger off. I'm not happy about that, but I don't see cleaner solutions, more's the pity. However, it doesn't mess with ->root - nor should it, since we don't have LOOKUP_ROOT_GRABBED (not in RCU mode), so it can and should be left alone. > We can drop this check, though now complete_walk()'s main defence > against a NULL nd->root.mnt is that path_is_under() will fail and > trigger -EXDEV (or set_root() will fail at some point in the future). > However, as you pointed out, a NULL nd->root.mnt won't happen with > things as they stand today -- I might be a little too paranoid. :P The only reason why complete_walk() zeroes nd->root in some cases is microoptimization - we *know* we won't be using it later, so we don't care whether it's stale or not and can spare unlazy_walk() a bit of work. All there is to that one. I don't see any reason for adding code that would clear nd->root in later work; if such thing does get added (again, I don't see what purpose could that possibly serve), we'll need to watch out for a lot of things. Starting with LOOKUP_ROOT case... It's not something likely to slip in unnoticed.