Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1286641ybc; Tue, 12 Nov 2019 18:06:02 -0800 (PST) X-Google-Smtp-Source: APXvYqw94rKxBvgyynPlrniSQRhslOePnWAMQcFImX84Wo0p8DfH6wRTFDGsOLsF4T21JoZlKZH5 X-Received: by 2002:a17:906:95c1:: with SMTP id n1mr473497ejy.158.1573610762416; Tue, 12 Nov 2019 18:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573610762; cv=none; d=google.com; s=arc-20160816; b=iTfsJt/rsoQb+eTTucpHU5HAZnBSgLVObACu6dmBzeEmDdMgjCMLie5OboOg5HoFGD fzWHSLyipPfLpMUSuYAeqyVjSWFYTgcj2cPhfBKuObbtlqAB44bRTQEOPZcfl7EKry56 di6s/HBqcgV4fJfMSPoOhNypGbI+73tGNd3V4xTQoMBTiSCX3Vvt9sRSTDIvmEVQPff3 g5JZxm1DDu7r31xeOmjO/XCkob02RosmZU7HrOKYGtHSviwR1Wxa5Vw5DL63M5FEzo33 Rebi3lH4VXpJ29wZLVRlTu5Is3U5ybk/L6UlYM1ZDWK00L0GwBdDxRURH2AvAqX/yNDd 4DCg== 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=AyS3EbSq4yB7yuvgcTJjrlX4zy+RM3cY80dltlJUNUI=; b=WCij3ks/hYhw8zANt6KswKR4+5CNb0slu6gK0MwyGMhmY90z0vaBwfo2taqWK0y/QP Py5AmqQzCgwhwZFxsR94GRfhnye4s0Ekaak1tBWhy4Vu6WQKZvLgdb3fKXQKPZ5L/i/J g6foatW4OHBErHRh1uW8VjPWBO87Tszd43hS4ux4QG+nJJOYo2kG9XYHDn4bz1e0P3l6 Sb+j8q4Yn7l4HTVDlVbawdL8tHBqRNf3KziOuW0SUeX1lO3MGW/j6r/eeGuFFbkGFW66 IF3L/Uo6rZWYLTUBL68YciqhY6lh237Ooe0QmAmflWYG3YsMazNz277LPhmWvcaUvkJ8 uQ6A== 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 rp9si250253ejb.40.2019.11.12.18.05.38; Tue, 12 Nov 2019 18:06:02 -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 S1728872AbfKMCDt (ORCPT + 99 others); Tue, 12 Nov 2019 21:03:49 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:39298 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728300AbfKMCDm (ORCPT ); Tue, 12 Nov 2019 21:03:42 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iUhzv-0008C3-Ic; Wed, 13 Nov 2019 02:03:07 +0000 Date: Wed, 13 Nov 2019 02:03:07 +0000 From: Al Viro To: Aleksa Sarai 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: <20191113020307.GB26530@ZenIV.linux.org.uk> References: <20191105090553.6350-1-cyphar@cyphar.com> <20191105090553.6350-6-cyphar@cyphar.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191105090553.6350-6-cyphar@cyphar.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 05, 2019 at 08:05:49PM +1100, Aleksa Sarai wrote: > @@ -2277,12 +2277,20 @@ static const char *path_init(struct nameidata *nd, unsigned flags) > > nd->m_seq = read_seqbegin(&mount_lock); > > - /* Figure out the starting path and root (if needed). */ > - if (*s == '/') { > + /* Absolute pathname -- fetch the root. */ > + if (flags & LOOKUP_IN_ROOT) { > + /* With LOOKUP_IN_ROOT, act as a relative path. */ > + while (*s == '/') > + s++; 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.