Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp850031ybi; Fri, 12 Jul 2019 05:41:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcuAWgDNtZ2jQkY+THdUUh7CM88XlxJRymLWFNfdpMCzWzfnRQOstpiDQuq9GipAJ8dvHw X-Received: by 2002:a63:6c46:: with SMTP id h67mr341441pgc.248.1562935276636; Fri, 12 Jul 2019 05:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562935276; cv=none; d=google.com; s=arc-20160816; b=PpQsDI3f02IMgbjLCI8cdvjwZTCQ8OWxH0LKFB2oCBR/Tot6YF2ekCr9WdHzk5u+6H L7Mb5LHysfV8EY711lE14KOBKgKwXXIrZgg2IHAngqfr7gu4+9LzKIgRzc9VPAjnaB0m oJlDnXtLaRrArLKQbsjFcooJwOyAgZwM3YjULRVA7S+uKotWMGAHsfxlMvu5enKsUS4f oKef1nbsnvMkpEZrvjGyPpBKMrGTzmT6ZQ4OdRV/tE+ApSyMM3QO8C6PMTM/qqW8j4/U sMuLQ3Nt5A+72lE8DabfoPAl2oKPbNjdVKIzX7TrAH1vx9bLG5PhAeTQhIrJyKO1ZnR6 RrYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=kzWVVMPJZnHwnpQzTaCtvC2wY5I6/FWSBD2xeEYCwSo=; b=NV2zFL3pNsE/l1ziAELnuFvpbM8LzVG+XkkJkhbq0ig/NwV1+S3tYFnw+r1K4XB1fU B5UaarMehrWVVddXfkeOG8pq5MjeC5shbW1WpSMclyLIZ2MkjJVM+HMSMD94ZRpPJ74n KQjEo5F92IOSvMSwSwKpguR7RaTOH0evcNGPWzbjw/6AwjfrgNV2Vs4ICEpfOEOpjXP9 HTWiuI9MN/2xZMiAxUhc27YcU9j6jsRg9fRg0P8WwljCDJpdImax/d5d0M8l92Q88OgD 1BUhr+WISiTkTFACbf5AF2rCcVV34skGz9yGTnGbLyoxYeOQubD/7rrgLtldKFkj0nW8 qVRA== 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 g9si7767900plm.207.2019.07.12.05.41.01; Fri, 12 Jul 2019 05:41:16 -0700 (PDT) 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 S1727899AbfGLMkB (ORCPT + 99 others); Fri, 12 Jul 2019 08:40:01 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:37880 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729066AbfGLMj6 (ORCPT ); Fri, 12 Jul 2019 08:39:58 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hlupg-0006xX-Tg; Fri, 12 Jul 2019 12:39:25 +0000 Date: Fri, 12 Jul 2019 13:39:24 +0100 From: Al Viro To: Aleksa Sarai Cc: Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Shuah Khan , Shuah Khan , Christian Brauner , David Drysdale , Andy Lutomirski , Linus Torvalds , Eric Biederman , Andrew Morton , Alexei Starovoitov , Kees Cook , Jann Horn , Tycho Andersen , Chanho Min , Oleg Nesterov , Aleksa Sarai , containers@lists.linux-foundation.org, linux-alpha@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, sparclinux@vger.kernel.org Subject: Re: [PATCH v9 05/10] namei: O_BENEATH-style path resolution flags Message-ID: <20190712123924.GK17978@ZenIV.linux.org.uk> References: <20190706145737.5299-1-cyphar@cyphar.com> <20190706145737.5299-6-cyphar@cyphar.com> <20190712043341.GI17978@ZenIV.linux.org.uk> <20190712105745.nruaftgeat6irhzr@yavin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190712105745.nruaftgeat6irhzr@yavin> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 12, 2019 at 08:57:45PM +1000, Aleksa Sarai wrote: > > > @@ -2350,9 +2400,11 @@ static const char *path_init(struct nameidata *nd, unsigned flags) > > > s = ERR_PTR(error); > > > return s; > > > } > > > - error = dirfd_path_init(nd); > > > - if (unlikely(error)) > > > - return ERR_PTR(error); > > > + if (likely(!nd->path.mnt)) { > > > > Is that a weird way of saying "if we hadn't already called dirfd_path_init()"? > > Yes. I did it to be more consistent with the other "have we got the > root" checks elsewhere. Is there another way you'd prefer I do it? "Have we got the root" checks are inevitable evil; here you are making the control flow in a single function hard to follow. I *think* what you are doing is absolute pathname, no LOOKUP_BENEATH: set_root error = nd_jump_root(nd) else error = dirfd_path_init(nd) return unlikely(error) ? ERR_PTR(error) : s; which should be a lot easier to follow (not to mention shorter), but I might be missing something in all of that.