From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aleksa Sarai Date: Wed, 13 Nov 2019 03:55:42 +0000 Subject: Re: [PATCH v15 5/9] namei: LOOKUP_IN_ROOT: chroot-like scoped resolution Message-Id: <20191113035542.3ckc7oudahn3xtnj@yavin.dot.cyphar.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="j4f7d32jpyqpzflk" List-Id: 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> In-Reply-To: <20191113025941.GE26530@ZenIV.linux.org.uk> 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 , Alexan --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--