From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20024CA9EAF for ; Sun, 27 Oct 2019 15:44:12 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9015E214AF for ; Sun, 27 Oct 2019 15:44:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9015E214AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cyphar.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 471MbD1c2yzDqjQ for ; Mon, 28 Oct 2019 02:44:08 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=cyphar.com (client-ip=2001:67c:2050::465:201; helo=mout-p-201.mailbox.org; envelope-from=cyphar@cyphar.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=cyphar.com Received: from mout-p-201.mailbox.org (unknown [IPv6:2001:67c:2050::465:201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 471MXw0ry8zDqLh for ; Mon, 28 Oct 2019 02:42:04 +1100 (AEDT) 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 471MXZ3cz5zQl8s; Sun, 27 Oct 2019 16:41:50 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id HKUBceS7i6hF; Sun, 27 Oct 2019 16:41:40 +0100 (CET) Date: Mon, 28 Oct 2019 02:41:15 +1100 From: Aleksa Sarai To: Linus Torvalds Subject: Re: [PATCH RESEND v14 2/6] namei: LOOKUP_IN_ROOT: chroot-like path resolution Message-ID: <20191027154115.ex55njkysey4m6pu@yavin.dot.cyphar.com> References: <20191026185700.10708-1-cyphar@cyphar.com> <20191026185700.10708-3-cyphar@cyphar.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="x254sstnuxqz6cbi" Content-Disposition: inline In-Reply-To: X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ia64@vger.kernel.org, Linux-sh list , Peter Zijlstra , Rasmus Villemoes , Alexei Starovoitov , Linux Kernel Mailing List , David Howells , "open list:KERNEL SELFTEST FRAMEWORK" , sparclinux@vger.kernel.org, Jiri Olsa , linux-arch , linux-s390 , Tycho Andersen , Aleksa Sarai , Shuah Khan , Alexander Shishkin , Ingo Molnar , Linux ARM , linux-mips@vger.kernel.org, linux-xtensa@linux-xtensa.org, Kees Cook , Arnd Bergmann , Jann Horn , linux-m68k , Al Viro , Andy Lutomirski , Shuah Khan , Namhyung Kim , David Drysdale , Christian Brauner , "J. Bruce Fields" , GNU C Library , linux-parisc@vger.kernel.org, Linux API , Chanho Min , Jeff Layton , Oleg Nesterov , Eric Biederman , alpha , linux-fsdevel , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Linux Containers Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" --x254sstnuxqz6cbi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2019-10-27, Linus Torvalds wrote: > On Sat, Oct 26, 2019 at 2:58 PM Aleksa Sarai wrote: > > > > + /* LOOKUP_IN_ROOT treats absolute paths as being relative-to-di= rfd. */ > > + if (flags & LOOKUP_IN_ROOT) > > + while (*s =3D=3D '/') > > + s++; > > + > > /* Figure out the starting path and root (if needed). */ > > if (*s =3D=3D '/') { > > error =3D nd_jump_root(nd); >=20 > So I'm still hung up on this. >=20 > I guess I can't help it, but I look at the above, and it makes me go > "whoever wrote those tests wasn't thinking". >=20 > It just annoys me how it tests for '/' completely unnecessarily. >=20 > If LOOKUP_IN_ROOT is true, we know the subsequent test for '/' is not > going to match, because we just removed it. So I look at that code and > go "that code is doing stupid things". Okay, fair enough. > That's why I suggested moving the LOOKUP_IN_ROOT check inside the '/' tes= t. >=20 > Alternatively, just make the logic be >=20 > if (flags & LOOKUP_IN_ROOT) { > .. remove '/'s ... > } else if (*s =3D=3D '/') { > .. handl;e root .. >=20 > and remove the next "else" clause I've gone with the latter since I think it reads better. --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --x254sstnuxqz6cbi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQSxZm6dtfE8gxLLfYqdlLljIbnQEgUCXbW6lwAKCRCdlLljIbnQ EoPNAP0TH7raCw5NCLFnqJEAJ2bl+pDz8oGtxQKGtoXC7HohOQEAqFv71cuFJjle mvHPyKwhvNv8coIv55o8qUxny+XxIAg= =0iVb -----END PGP SIGNATURE----- --x254sstnuxqz6cbi--