Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp192734ybf; Thu, 27 Feb 2020 19:03:22 -0800 (PST) X-Google-Smtp-Source: APXvYqznudI7KRMLVx+CMl6LP/JK1CiH7IwYquteiXRf13+tIpprw8dUilcn6WTRlhp0nSSZYEVU X-Received: by 2002:a05:6830:1385:: with SMTP id d5mr1677916otq.61.1582859002202; Thu, 27 Feb 2020 19:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582859002; cv=none; d=google.com; s=arc-20160816; b=ah8t/g2cYKdlKMI9oq6Qawh36QKWkWQIWfKYNgczLnuN314mnd4wOExCsYVzadct6N /N+y7E802F6IrdSnJm5U6h/IhNSWfQGBaXgyDXTrW8JK0QnJ4X+fbw4M2xenU3RUnV9y NOxrSvj1PBkk3o4THmzcBo7GSEvwuXPw9XnaT+qO0ItazG5NfT7WVLXjBZ18i07HR7hP GDfM/YQXpX1DdPqcC3F2sWSMsl8Z7ikgx+TL4ajyITyhC/HfmPS1b0HoeZ1ZTJ706xQb rhZ38tv2oQRowBzfMdH1NBRZYuTt3MKulC/3KyWlvpuCf2qzp/kgNTPV4+/DR0XgZHfC rz2g== 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=NoDTjt3L02GZc2qGwnIeruvftLZqeMWys+IOSnHyoAY=; b=E3hlbPkoS6jTqJYsUilDoor6yRAsFH3bRgzMoON+Aqie9ZJgdTzuFwcB20OIhsv8MX lOURrLLSmIFBSNguLnNLrioJ6cQhHhiD9NdXGaotkEFd7tk+gIfb5wUtV3ARqPP4Huq7 fDGLPajeInOhCV+UiPcV/WQkKqIh9w633ufMnbCYL5UnXRUdQYeAABBFeoFVytoPuXsg 5v/Ad5LHfu7aMJbhAvyu2gg0wCVIwLCyfwte+tF4GxPA5PxMKxQoKCYmMqPUmwPVEK2Y Ux8h1dTtDFQQLXuE2XN1hVtrt/eU28qdymuQpCOqX9ikdVkAOry/Rvi0y49UbXqoCbfw ZDoQ== 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 t185si954252oib.39.2020.02.27.19.03.10; Thu, 27 Feb 2020 19:03:22 -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 S1730746AbgB1DCD (ORCPT + 99 others); Thu, 27 Feb 2020 22:02:03 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:52602 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730445AbgB1DCC (ORCPT ); Thu, 27 Feb 2020 22:02:02 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7Vua-002Boa-UI; Fri, 28 Feb 2020 03:02:01 +0000 Date: Fri, 28 Feb 2020 03:02:00 +0000 From: Al Viro To: Aleksa Sarai Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds Subject: Re: [RFC][PATCHSET] sanitized pathwalk machinery (v2) Message-ID: <20200228030200.GH23230@ZenIV.linux.org.uk> References: <20200223011154.GY23230@ZenIV.linux.org.uk> <20200225012457.GA138294@ZenIV.linux.org.uk> <20200228012451.upnq5r7fdctrk7pv@yavin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200228012451.upnq5r7fdctrk7pv@yavin> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 28, 2020 at 12:24:51PM +1100, Aleksa Sarai wrote: > > Another one is about LOOKUP_NO_XDEV again: suppose you have process' > > root directly overmounted and cwd in the root of whatever's overmounting > > it. Resolution of .. will stay in cwd - we have no parent within the > > chroot jail we are in, so we move to whatever's overmounting that root. > > Which is the original location. Should we fail on LOOKUP_NO_XDEV here? > > Plain .. in the root of chroot jail (not overmounted by anything) does > > *not*... > > I think LOOKUP_NO_XDEV should block that since you end up crossing a > mountpoint. You are not. Your process' root is overmounted and your current directory is on that overmount. You attempt to resolve ".." there. # cd / # unshare -m # stat . File: . Size: 4096 Blocks: 8 IO Block: 4096 directory Device: 801h/2049d Inode: 2 Links: 25 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-02-26 20:51:06.623409892 -0500 Modify: 2020-02-26 20:43:51.284020000 -0500 Change: 2020-02-26 20:43:51.284020000 -0500 Birth: - # mkdir /tmp/foo # mount -t tmpfs none /tmp/foo/ # for i in *; do test -d $i && mkdir /tmp/foo/$i && mount --rbind $i /tmp/foo/$i; done # cd /tmp/foo/ # mount --move . / # /bin/pwd / # ls bin dev home lib32 libx32 ltp mnt proc run srv tmp var boot etc lib lib64 lost+found media opt root sbin sys usr # ls / 253_metadump etc lib32 media run usr 315.full home lib64 mnt sbin var bin initrd.img libx32 opt srv vmlinuz boot initrd.img.old lost+found proc sys vmlinuz.old dev lib ltp root tmp # stat .. File: .. Size: 500 Blocks: 0 IO Block: 4096 directory Device: 19h/25d Inode: 1875746 Links: 25 Access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-02-27 21:48:45.649705410 -0500 Modify: 2020-02-27 21:46:40.829607188 -0500 Change: 2020-02-27 21:46:40.829607188 -0500 Birth: - # stat . File: . Size: 500 Blocks: 0 IO Block: 4096 directory Device: 19h/25d Inode: 1875746 Links: 25 Access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-02-27 21:48:45.649705410 -0500 Modify: 2020-02-27 21:46:40.829607188 -0500 Change: 2020-02-27 21:46:40.829607188 -0500 Birth: - See what's going on? We have a tmpfs overmounting root; current directory is the root of tmpfs; process root is on ext3. Lookups for . and .. yield exactly the same result here - we stay in the root of tmpfs. Anyway, see #work.dotdot in vfs.git