Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1326282ybz; Wed, 22 Apr 2020 18:39:52 -0700 (PDT) X-Google-Smtp-Source: APiQypJD7yecMVb6scodjkPSPeL7WcSvv9PbwQTrPJGPXSv8fWsrlMKwaZlqqu2yIF90DcMZmGL4 X-Received: by 2002:a17:906:359b:: with SMTP id o27mr854374ejb.282.1587605992212; Wed, 22 Apr 2020 18:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587605992; cv=none; d=google.com; s=arc-20160816; b=mEBlZEUAq0Bmlp1++2tqT7vge0036cIz55+EKB5bPRFh2LhLrapvl4YQHlZimLFpk2 K2G8v1l204MeJj92qMqV49bu/8Up5RJw/Sn/Wz7bCDn9bNmQzJUJcE5QB4V9+RzXP8gW vekZht35qJWJ2Vr37GzD30YnXe8wIdfiDm8OYZvRbVk5m4wSCTGNFtusCsU5JByTNXxt aHEKCKeJIuq/laecgptP2K9sIujkyLu/7bbJDDbrHqwHDHSoa6pDiyUHH2NdgriA+jyE rtP2Yht7Tfc2f7istH71xAUFmse4uyYpVu9OabXixZSTmPslBmwAIvbiCxASGSEDg/5m Aviw== 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=WxeQYUN9BwNr4tMTj+LYCtc9RtZ+JjoCp3vrQmEtBsM=; b=OaKplF5oe8fw2OukD1TzwARmz2pDgcNEzE0gqCJzZ2XQONZaf77r2M5ShdvDAi7uGr C2KSGtATnsHk3tDl7Io+KpkGNFkeG/uvdk/vwSCEdeYW39kkfP7tVPjiHXSzfTrqMjfr iLEnyQSI+A8DZLJdOgBQTjkOjv+UbxuLIRydwq6+ykPIfrUEzwzA1qyO0ivDXya6agKc 5ahnRmzpFaGhydvlbUJdyBfrXnTtzUzRBsKTl+u5NBRLp4pu0eySxv3+naI526c3qLcG 2khMqXnRSMZXDw/sMtSSF0TpXIrphOWfgheOJklHcUXSZhV3rXIRYiqOkPlIzMj18xuR YIww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si451922eji.408.2020.04.22.18.39.23; Wed, 22 Apr 2020 18:39:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726458AbgDWBh5 (ORCPT + 99 others); Wed, 22 Apr 2020 21:37:57 -0400 Received: from mail.hallyn.com ([178.63.66.53]:53220 "EHLO mail.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbgDWBh5 (ORCPT ); Wed, 22 Apr 2020 21:37:57 -0400 Received: by mail.hallyn.com (Postfix, from userid 1001) id 44E5B9D0; Wed, 22 Apr 2020 20:37:54 -0500 (CDT) Date: Wed, 22 Apr 2020 20:37:54 -0500 From: "Serge E. Hallyn" To: Christian Brauner Cc: Jens Axboe , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-api@vger.kernel.org, Jonathan Corbet , Serge Hallyn , "Rafael J. Wysocki" , Tejun Heo , "David S. Miller" , Saravana Kannan , Jan Kara , David Howells , Seth Forshee , David Rheinsberg , Tom Gundersen , Christian Kellner , Dmitry Vyukov , =?iso-8859-1?Q?St=E9phane?= Graber , linux-doc@vger.kernel.org, netdev@vger.kernel.org, Steve Barber , Dylan Reid , Filipe Brandenburger , Kees Cook , Benjamin Elder , Akihiro Suda Subject: Re: [PATCH v2 7/7] loopfs: only show devices in their correct instance Message-ID: <20200423013754.GC2982@mail.hallyn.com> References: <20200422145437.176057-1-christian.brauner@ubuntu.com> <20200422145437.176057-8-christian.brauner@ubuntu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200422145437.176057-8-christian.brauner@ubuntu.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 22, 2020 at 04:54:37PM +0200, Christian Brauner wrote: > Since loopfs devices belong to a loopfs instance they have no business > polluting the host's devtmpfs mount and should not propagate out of the > namespace they belong to. > > Cc: Jens Axboe > Cc: Greg Kroah-Hartman > Signed-off-by: Christian Brauner Reviewed-by: Serge Hallyn > --- > /* v2 */ > unchanged > --- > drivers/base/devtmpfs.c | 4 ++-- > drivers/block/loop.c | 4 +++- > include/linux/device.h | 3 +++ > 3 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c > index c9017e0584c0..77371ceb88fa 100644 > --- a/drivers/base/devtmpfs.c > +++ b/drivers/base/devtmpfs.c > @@ -111,7 +111,7 @@ int devtmpfs_create_node(struct device *dev) > const char *tmp = NULL; > struct req req; > > - if (!thread) > + if (!thread || dev->no_devnode) > return 0; > > req.mode = 0; > @@ -138,7 +138,7 @@ int devtmpfs_delete_node(struct device *dev) > const char *tmp = NULL; > struct req req; > > - if (!thread) > + if (!thread || dev->no_devnode) > return 0; > > req.name = device_get_devnode(dev, NULL, NULL, NULL, &tmp); > diff --git a/drivers/block/loop.c b/drivers/block/loop.c > index 2dc53bad4b48..5548151b9f11 100644 > --- a/drivers/block/loop.c > +++ b/drivers/block/loop.c > @@ -2213,8 +2213,10 @@ static int loop_add(struct loop_device **l, int i, struct inode *inode) > disk->queue = lo->lo_queue; > sprintf(disk->disk_name, "loop%d", i); > #ifdef CONFIG_BLK_DEV_LOOPFS > - if (loopfs_i_sb(inode)) > + if (loopfs_i_sb(inode)) { > disk->user_ns = loopfs_i_sb(inode)->s_user_ns; > + disk_to_dev(disk)->no_devnode = true; > + } > #endif > > add_disk(disk); > diff --git a/include/linux/device.h b/include/linux/device.h > index ac8e37cd716a..c69ef1c5a0ef 100644 > --- a/include/linux/device.h > +++ b/include/linux/device.h > @@ -523,6 +523,8 @@ struct dev_links_info { > * sync_state() callback. > * @dma_coherent: this particular device is dma coherent, even if the > * architecture supports non-coherent devices. > + * @no_devnode: whether device nodes associated with this device are kept out > + * of devtmpfs (e.g. due to separate filesystem) > * > * At the lowest level, every device in a Linux system is represented by an > * instance of struct device. The device structure contains the information > @@ -622,6 +624,7 @@ struct device { > defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) > bool dma_coherent:1; > #endif > + bool no_devnode:1; > }; > > static inline struct device *kobj_to_dev(struct kobject *kobj) > -- > 2.26.1