Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2048588ybg; Sun, 27 Oct 2019 10:01:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1EryKF78YNqdUofZ1FpwKD7QVY5eZBqJyec9K4izyAMkqp+gZweyAyILy+rh+Omzkn4NH X-Received: by 2002:a05:6402:1acd:: with SMTP id ba13mr14912341edb.141.1572195662889; Sun, 27 Oct 2019 10:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572195662; cv=none; d=google.com; s=arc-20160816; b=l3XakU4kSqpt360/2x+Kc2lr3PB1xNtcT095+pAQ1hXtuiJVTY8n6ZSUuuu3glzaKa s8TBbFPIt2ODALMRSVqul79vUr3BRLJ6ojpnKnVt9NZv5wRwUL5qAxr2JpBjmimrJlI0 qSMZ93qSLDAA3wcCSM0ipwwBgLCLg5bpNOeiN4t/gxB8w5Fc2YcohI2mtY4WL03H/r3R gymC89pqgKca9olBBoCb3VYvkJRg2zcM6vWzBbyKDQ46BORbhLxiC/r9qpuuAQbs6pz6 JCYbWjrQ0CJrQHhMh2VbwQMdm74GPEvvnQpGfEVy9VQyWOrPcENM/i8RDEBIEZpu1YKR eUVA== 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=qoCyNWkM9/GJBstJzgGZGl91bB4zrNUBkBwdryRbauE=; b=lBHbBPxISNHyCKdghdZPJJ1D0lvVvUNeiXBeQhjlYm4A93xyMGAv40HJ+jgfMms30m Ck0WRayal19Aj8TLGlqVJIZv9s8W7XDU6ADrayaHC7c8CY0HYUlCqVyp4c38E/F8Ttcm AIlGT8Txffo0W624yw2U01fUb8E3jylrc01Xsyw3ewdZZcEQ69oo6gn3P4WiEXnYwQOj 6nFf7ccomQhn4cEcj0PPgbmwj1KmeyfZVEsy0W/eKJCq18bQs0WJOSkT8FFBDMY4auxx yNiZP8DOQSkngAQd/TcpSjaoeKVI3NlrSBswDQptwoqXGAAceiaWmqnMdYTLZWpCxb9t nsug== 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 x37si5257858edd.228.2019.10.27.10.00.39; Sun, 27 Oct 2019 10:01:02 -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 S1727574AbfJ0Pl4 (ORCPT + 99 others); Sun, 27 Oct 2019 11:41:56 -0400 Received: from mout-p-201.mailbox.org ([80.241.56.171]:27440 "EHLO mout-p-201.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727056AbfJ0Plz (ORCPT ); Sun, 27 Oct 2019 11:41:55 -0400 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 Cc: Al Viro , Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Shuah Khan , Shuah Khan , Ingo Molnar , Peter Zijlstra , 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 , Linux Containers , alpha , Linux API , GNU C Library , linux-arch , Linux ARM , linux-fsdevel , linux-ia64@vger.kernel.org, Linux Kernel Mailing List , "open list:KERNEL SELFTEST FRAMEWORK" , linux-m68k , linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390 , Linux-sh list , linux-xtensa@linux-xtensa.org, sparclinux@vger.kernel.org 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: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --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--