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 v2 6/7] loopfs: start attaching correct namespace during loop_add()
Date: Wed, 22 Apr 2020 16:54:36 +0200 [thread overview]
Message-ID: <20200422145437.176057-7-christian.brauner@ubuntu.com> (raw)
In-Reply-To: <20200422145437.176057-1-christian.brauner@ubuntu.com>
Tag loop devices with the namespace the loopfs instance was mounted in.
This has the consequence that loopfs devices carry the correct sysfs
permissions for all their core files. All other devices files will
continue to be correctly owned by the initial namespaces. Here is sample
output:
root@b1:~# mount -t loop loop /mnt
root@b1:~# ln -sf /mnt/loop-control /dev/loop-control
root@b1:~# losetup -f
/dev/loop8
root@b1:~# ln -sf /mnt/loop8 /dev/loop8
root@b1:~# ls -al /sys/class/block/loop8
lrwxrwxrwx 1 root root 0 Apr 7 13:06 /sys/class/block/loop8 -> ../../devices/virtual/block/loop8
root@b1:~# ls -al /sys/class/block/loop8/
total 0
drwxr-xr-x 9 root root 0 Apr 7 13:06 .
drwxr-xr-x 18 nobody nogroup 0 Apr 7 13:07 ..
-r--r--r-- 1 root root 4096 Apr 7 13:06 alignment_offset
lrwxrwxrwx 1 nobody nogroup 0 Apr 7 13:07 bdi -> ../../bdi/7:8
-r--r--r-- 1 root root 4096 Apr 7 13:06 capability
-r--r--r-- 1 root root 4096 Apr 7 13:06 dev
-r--r--r-- 1 root root 4096 Apr 7 13:06 discard_alignment
-r--r--r-- 1 root root 4096 Apr 7 13:06 events
-r--r--r-- 1 root root 4096 Apr 7 13:06 events_async
-rw-r--r-- 1 root root 4096 Apr 7 13:06 events_poll_msecs
-r--r--r-- 1 root root 4096 Apr 7 13:06 ext_range
-r--r--r-- 1 root root 4096 Apr 7 13:06 hidden
drwxr-xr-x 2 nobody nogroup 0 Apr 7 13:07 holders
-r--r--r-- 1 root root 4096 Apr 7 13:06 inflight
drwxr-xr-x 2 nobody nogroup 0 Apr 7 13:07 integrity
drwxr-xr-x 3 nobody nogroup 0 Apr 7 13:07 mq
drwxr-xr-x 2 root root 0 Apr 7 13:06 power
drwxr-xr-x 3 nobody nogroup 0 Apr 7 13:07 queue
-r--r--r-- 1 root root 4096 Apr 7 13:06 range
-r--r--r-- 1 root root 4096 Apr 7 13:06 removable
-r--r--r-- 1 root root 4096 Apr 7 13:06 ro
-r--r--r-- 1 root root 4096 Apr 7 13:06 size
drwxr-xr-x 2 nobody nogroup 0 Apr 7 13:07 slaves
-r--r--r-- 1 root root 4096 Apr 7 13:06 stat
lrwxrwxrwx 1 nobody nogroup 0 Apr 7 13:07 subsystem -> ../../../../class/block
drwxr-xr-x 2 root root 0 Apr 7 13:06 trace
-rw-r--r-- 1 root root 4096 Apr 7 13:06 uevent
root@b1:~#
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
/* v2 */
unchanged
- Christian Brauner <christian.brauner@ubuntu.com>:
- Adapted commit message otherwise unchanged.
---
drivers/block/loop.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 8e21d4b33e01..2dc53bad4b48 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2212,6 +2212,10 @@ static int loop_add(struct loop_device **l, int i, struct inode *inode)
disk->private_data = lo;
disk->queue = lo->lo_queue;
sprintf(disk->disk_name, "loop%d", i);
+#ifdef CONFIG_BLK_DEV_LOOPFS
+ if (loopfs_i_sb(inode))
+ disk->user_ns = loopfs_i_sb(inode)->s_user_ns;
+#endif
add_disk(disk);
--
2.26.1
next prev parent reply other threads:[~2020-04-22 14:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 14:54 [PATCH v2 0/7] loopfs Christian Brauner
2020-04-22 14:54 ` [PATCH v2 1/7] kobject_uevent: remove unneeded netlink_ns check Christian Brauner
2020-04-22 16:34 ` Greg Kroah-Hartman
2020-04-22 14:54 ` [PATCH v2 2/7] loopfs: implement loopfs Christian Brauner
2020-04-22 21:52 ` Serge E. Hallyn
2020-04-23 11:24 ` Christian Brauner
2020-04-23 16:17 ` Serge E. Hallyn
2020-04-23 16:29 ` Christian Brauner
2020-04-22 14:54 ` [PATCH v2 3/7] loop: use ns_capable for some loop operations Christian Brauner
2020-04-22 20:50 ` Serge E. Hallyn
2020-04-22 14:54 ` [PATCH v2 4/7] kernfs: handle multiple namespace tags Christian Brauner
2020-04-22 22:01 ` Serge E. Hallyn
2020-04-22 14:54 ` [PATCH v2 5/7] loop: preserve sysfs backwards compatibility Christian Brauner
2020-04-23 1:17 ` Serge E. Hallyn
2020-04-23 11:15 ` Christian Brauner
2020-04-23 16:13 ` Serge E. Hallyn
2020-04-22 14:54 ` Christian Brauner [this message]
2020-04-23 1:36 ` [PATCH v2 6/7] loopfs: start attaching correct namespace during loop_add() Serge E. Hallyn
2020-04-22 14:54 ` [PATCH v2 7/7] loopfs: only show devices in their correct instance Christian Brauner
2020-04-23 1:37 ` Serge E. Hallyn
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=20200422145437.176057-7-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
all inboxes | Powered by JetHome®