Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp865143ybi; Fri, 12 Jul 2019 05:57:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjfONrZj6PwVdbLoPMdNRFAOjJEu6wz4UjpGL7f7mMWlbsCe7FCZYtW4+9ImpapwtT8E6B X-Received: by 2002:a17:902:1003:: with SMTP id b3mr11547157pla.172.1562936273357; Fri, 12 Jul 2019 05:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562936273; cv=none; d=google.com; s=arc-20160816; b=W49kRsS/JHVG46i7+bElWXhvOOcPVRQZDcwovv9AI3VjwG8GBqqcsrabjTKoIsz6gm E7j4Tm2tvCw1LKwWlN3w/8hN670iWo9gqsmwY+PzNEjDR1JxFKB9U7j1MmCA7anyAhBA N867adlBd/5uZdSEz1W6lOnCN6PafQgcelyk52/cj8WW9qDr/qPFwg1wmbMYEcI8S+Wt X4UvafZnCLJYjuHiYEi/xSkWQTb662VWrohWUrFY0ZiA4M2vK75Gaqbkx4VgHm3AI1Dv uPpohaSrSHtoHHex8vxDJEBuVVvxsbUzTqnCzJ23ATyCzDUDuz0Tzj+xk/JnlioML5c5 v9oQ== 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=Hq8Ev1uYLuYDRmLUN93Als5TbnhmjFdafwveG+uXPW8=; b=Onog6STVHeHexO8CxADyQ1PeKh2IBSShcTDwPnitS2bSRloDtKica41dM4FaPHYaWJ K+L7aAeLeUA/mo8cEHWhiDjiAC0O7Yp14WzT6SyIcoAiaGgXSZBtkklR7rQz5/nM3D20 GpaChrlrRWafLTZWeSAUhZiJpbDIFVs4x8vc2t7z88oVbuwnJTA4Lko0aIC/tEXUKjkz QA9ATwY29vT24AT8DX+MVeFKsXUyD8RV3NTeb0GuVvgYuuCra20Ru/6pHR2nH+ELsmU1 1/G+SARmhzwCoS6O3HZDNFNM7B13LdPUQ4qoRTEHzPhoAFHrKg+hGvYTo0Z921484B9m +3Rg== 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 f7si7492043pgv.105.2019.07.12.05.57.37; Fri, 12 Jul 2019 05:57:53 -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 S1727435AbfGLM4Q (ORCPT + 99 others); Fri, 12 Jul 2019 08:56:16 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:38082 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727096AbfGLM4P (ORCPT ); Fri, 12 Jul 2019 08:56:15 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hlv5c-0007Pc-Mt; Fri, 12 Jul 2019 12:55:52 +0000 Date: Fri, 12 Jul 2019 13:55:52 +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: <20190712125552.GL17978@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> <20190712123924.GK17978@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190712123924.GK17978@ZenIV.linux.org.uk> 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 01:39:24PM +0100, Al Viro wrote: > 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. PS: if that's what's going on, I would be tempted to turn the entire path_init() part into this: if (flags & LOOKUP_BENEATH) while (*s == '/') s++; in the very beginning (plus the handling of nd_jump_root() prototype change, but that belongs with nd_jump_root() change itself, obviously). Again, I might be missing something here...