Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1368150ybc; Tue, 12 Nov 2019 19:57:46 -0800 (PST) X-Google-Smtp-Source: APXvYqyOTTrLVVF0TeN7BT/MHoveXNe6Az05hf2LPgHhXLMiW4SjJDijNGvjubXUAT4YLdeVrosW X-Received: by 2002:a50:f747:: with SMTP id j7mr1315337edn.247.1573617465634; Tue, 12 Nov 2019 19:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573617465; cv=none; d=google.com; s=arc-20160816; b=WrS8thFOuQTxdHFoGw0aThm0Fn2D79VBNPrxJ1co8JuZ3s4jTy+UP+TPVHvDvOsFYB l2X+fnanwGZ7su2me0ZRxBPa7c2t7wX5Puma984+PHrQ26RqzVtiU9jUN7fm652dV9vs 3bEURioIMXhatKuv/tSayHg8VH40G4RU8mFTd9N3pHH5W1rCxT9I245OVW1iOAfAXdbT FnHZb3nKr+YXaIcaYCALwPq2lRRpWmAZzl+6qERbTn3NRCSKuLDuYigE8k5GYbXEem0D 43HbMw2CVPFy2C1D98ULALbNyXg5fB6TGYU/zDcz9Bj9gB1FZwjAFZOK4xL3xcXogQgx Sh2w== 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=zRv1/UB2sCL12EkZB+tcqFke6PE74yMBhVsNRlKgYJc=; b=zFWQtc0AYD7mVP1SAL1Xoz3lQKhMqhHRGBj/L7gkxRxIapVo3xaqk70klcFX5uhjZd 17FMbvEHGoBk3qVO03wMkWE5F3QQ1J+VvQReUvozwbCRV3exXipkrrlF2J0jI/SRZ1Qu Olbwzak4OCh6AI1R3IkbyAlg41q+gvOiMPE8q+EhbgjwaP4BwJ31HpQTSA/5JwaA4lyq r1krr5ojLnsuVHdsHTwzWgROoJtDQP5Jez05wH+L+aZHkLjOs36NcoYIeYo/Fo2EnTQB 09chc2EUE/AMOOUyJTusfYWWPS36VCIIUiMxoIrNbhRZqu9wd3ccqMfxKokLROSD4HQx qC7w== 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 f10si378059ejq.289.2019.11.12.19.57.21; Tue, 12 Nov 2019 19:57:45 -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 S1727695AbfKMD4R (ORCPT + 99 others); Tue, 12 Nov 2019 22:56:17 -0500 Received: from mout-p-201.mailbox.org ([80.241.56.171]:39380 "EHLO mout-p-201.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727628AbfKMD4Q (ORCPT ); Tue, 12 Nov 2019 22:56:16 -0500 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 47CW4V73MqzQlBG; Wed, 13 Nov 2019 04:56:10 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id ovfePb6AeJGC; Wed, 13 Nov 2019 04:56:05 +0100 (CET) Date: Wed, 13 Nov 2019 14:55:42 +1100 From: Aleksa Sarai To: Al Viro Cc: Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Shuah Khan , Shuah Khan , Ingo Molnar , Peter Zijlstra , Christian Brauner , Eric Biederman , Andy Lutomirski , Andrew Morton , Alexei Starovoitov , Kees Cook , Jann Horn , Tycho Andersen , David Drysdale , Chanho Min , Oleg Nesterov , Rasmus Villemoes , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Christian Brauner , Aleksa Sarai , Linus Torvalds , containers@lists.linux-foundation.org, linux-alpha@vger.kernel.org, linux-api@vger.kernel.org, libc-alpha@sourceware.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 v15 5/9] namei: LOOKUP_IN_ROOT: chroot-like scoped resolution Message-ID: <20191113035542.3ckc7oudahn3xtnj@yavin.dot.cyphar.com> References: <20191105090553.6350-1-cyphar@cyphar.com> <20191105090553.6350-6-cyphar@cyphar.com> <20191113020307.GB26530@ZenIV.linux.org.uk> <20191113024414.wlmvtjstpnkxa36n@yavin.dot.cyphar.com> <20191113025941.GE26530@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="j4f7d32jpyqpzflk" Content-Disposition: inline In-Reply-To: <20191113025941.GE26530@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --j4f7d32jpyqpzflk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2019-11-13, Al Viro wrote: > On Wed, Nov 13, 2019 at 01:44:14PM +1100, Aleksa Sarai wrote: > > On 2019-11-13, Al Viro wrote: > > > On Tue, Nov 05, 2019 at 08:05:49PM +1100, Aleksa Sarai wrote: > > >=20 > > > > @@ -2277,12 +2277,20 @@ static const char *path_init(struct nameida= ta *nd, unsigned flags) > > > > =20 > > > > nd->m_seq =3D read_seqbegin(&mount_lock); > > > > =20 > > > > - /* Figure out the starting path and root (if needed). */ > > > > - if (*s =3D=3D '/') { > > > > + /* Absolute pathname -- fetch the root. */ > > > > + if (flags & LOOKUP_IN_ROOT) { > > > > + /* With LOOKUP_IN_ROOT, act as a relative path. */ > > > > + while (*s =3D=3D '/') > > > > + s++; > > >=20 > > > Er... Why bother skipping slashes? I mean, not only link_path_walk() > > > will skip them just fine, you are actually risking breakage in this: > > > if (*s && unlikely(!d_can_lookup(dentry))) { > > > fdput(f); > > > return ERR_PTR(-ENOTDIR); > > > } > > > which is downstream from there with you patch, AFAICS. > >=20 > > I switched to stripping the slashes at your suggestion a few revisions > > ago[1], and had (wrongly) assumed we needed to handle "/" somehow in > > path_init(). But you're quite right about link_path_walk() -- and I'd be > > more than happy to drop it. >=20 > That, IIRC, was about untangling the weirdness around multiple calls of > dirfd_path_init() and basically went "we might want just strip the slashes > in case of that flag very early in the entire thing, so that later the > normal logics for absolute/relative would DTRT". Ah okay, I'd misunderstood the point you were making in that thread. > Since your check is right next to checking for absolute pathnames (and > not in the very beginning of path_init()), we might as well turn the > check for absolute pathname into *s =3D=3D '/' && !(flags & > LOOKUP_IN_ROOT) and be done with that. Yup, agreed. --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --j4f7d32jpyqpzflk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQSxZm6dtfE8gxLLfYqdlLljIbnQEgUCXct+uwAKCRCdlLljIbnQ EpaMAQCKfJalyFfg/QA8aH/wuTwb0JmHpxt9HKverNfj5BncXAEA8J+s2/4xFPcn vy6IqraafPiOMkqsiqA03ofQ3tR8tQ4= =Qq3t -----END PGP SIGNATURE----- --j4f7d32jpyqpzflk--