From: Christian Brauner <christian.brauner@ubuntu.com>
To: Jens Axboe <axboe@kernel.dk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
linux-api@vger.kernel.org
Cc: "Jonathan Corbet" <corbet@lwn.net>,
"Serge Hallyn" <serge@hallyn.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Tejun Heo" <tj@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
"Christian Brauner" <christian.brauner@ubuntu.com>,
"Saravana Kannan" <saravanak@google.com>,
"Jan Kara" <jack@suse.cz>, "David Howells" <dhowells@redhat.com>,
"Seth Forshee" <seth.forshee@canonical.com>,
"David Rheinsberg" <david.rheinsberg@gmail.com>,
"Tom Gundersen" <teg@jklm.no>,
"Christian Kellner" <ckellner@redhat.com>,
"Dmitry Vyukov" <dvyukov@google.com>,
"Stéphane Graber" <stgraber@ubuntu.com>,
linux-doc@vger.kernel.org, netdev@vger.kernel.org,
"Steve Barber" <smbarber@google.com>,
"Dylan Reid" <dgreid@google.com>,
"Filipe Brandenburger" <filbranden@gmail.com>,
"Kees Cook" <keescook@chromium.org>,
"Benjamin Elder" <bentheelder@google.com>,
"Akihiro Suda" <suda.kyoto@gmail.com>
Subject: [PATCH v3 7/7] loopfs: only show devices in their correct instance
Date: Fri, 24 Apr 2020 18:20:52 +0200 [thread overview]
Message-ID: <20200424162052.441452-8-christian.brauner@ubuntu.com> (raw)
In-Reply-To: <20200424162052.441452-1-christian.brauner@ubuntu.com>
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 <axboe@kernel.dk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
/* v2 */
unchanged
/* v3 */
unchanged
---
block/partitions/core.c | 1 +
drivers/base/devtmpfs.c | 4 ++--
drivers/block/loopfs/loopfs.c | 4 +++-
include/linux/device.h | 3 +++
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/block/partitions/core.c b/block/partitions/core.c
index bc1ded1331b1..5761f5c38588 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -416,6 +416,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
pdev->class = &block_class;
pdev->type = &part_type;
pdev->parent = ddev;
+ pdev->no_devnode = ddev->no_devnode;
err = blk_alloc_devt(p, &devt);
if (err)
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/loopfs/loopfs.c b/drivers/block/loopfs/loopfs.c
index 9fa60c1bcc05..1bcb0b44c910 100644
--- a/drivers/block/loopfs/loopfs.c
+++ b/drivers/block/loopfs/loopfs.c
@@ -76,8 +76,10 @@ bool loopfs_wants_remove(const struct loop_device *lo)
void loopfs_init(struct gendisk *disk, struct inode *inode)
{
- 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;
+ }
}
/**
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.2
prev parent reply other threads:[~2020-04-24 16:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 16:20 [PATCH v3 0/7] loopfs Christian Brauner
2020-04-24 16:20 ` [PATCH v3 1/7] kobject_uevent: remove unneeded netlink_ns check Christian Brauner
2020-04-24 16:20 ` [PATCH v3 2/7] loopfs: implement loopfs Christian Brauner
2020-04-24 16:20 ` [PATCH v3 3/7] loop: use ns_capable for some loop operations Christian Brauner
2020-04-24 16:20 ` [PATCH v3 4/7] kernfs: handle multiple namespace tags Christian Brauner
2020-04-24 16:20 ` [PATCH v3 5/7] loop: preserve sysfs backwards compatibility Christian Brauner
2020-04-24 16:20 ` [PATCH v3 6/7] loopfs: start attaching correct namespace during loop_add() Christian Brauner
2020-04-24 16:20 ` Christian Brauner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200424162052.441452-8-christian.brauner@ubuntu.com \
--to=christian.brauner@ubuntu.com \
--cc=axboe@kernel.dk \
--cc=bentheelder@google.com \
--cc=ckellner@redhat.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=david.rheinsberg@gmail.com \
--cc=dgreid@google.com \
--cc=dhowells@redhat.com \
--cc=dvyukov@google.com \
--cc=filbranden@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.cz \
--cc=keescook@chromium.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=saravanak@google.com \
--cc=serge@hallyn.com \
--cc=seth.forshee@canonical.com \
--cc=smbarber@google.com \
--cc=stgraber@ubuntu.com \
--cc=suda.kyoto@gmail.com \
--cc=teg@jklm.no \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).