From: Miklos Szeredi <miklos@szeredi.hu>
To: akpm@linux-foundation.org, hch@infradead.org, serue@us.ibm.com,
viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [patch 11/11] unprivileged mounts: copy mount ownership on namespace cloning
Date: Mon, 17 Mar 2008 21:01:04 +0100 [thread overview]
Message-ID: <20080317200159.072705368@szeredi.hu> (raw)
In-Reply-To: 20080317200053.447640802@szeredi.hu
[-- Attachment #1: unprivileged-mounts-clone-inherit-owner.patch --]
[-- Type: text/plain, Size: 1595 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Mount ownership wasn't copied on CLONE_NEWNS. Noticed by Al Viro.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/namespace.c | 7 ++++++-
fs/pnode.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
Index: linux/fs/namespace.c
===================================================================
--- linux.orig/fs/namespace.c 2008-03-17 20:55:53.000000000 +0100
+++ linux/fs/namespace.c 2008-03-17 20:55:53.000000000 +0100
@@ -585,6 +585,11 @@ static struct vfsmount *clone_mnt(struct
struct super_block *sb = old->mnt_sb;
struct vfsmount *mnt;
+ if ((flag & CL_COPYUSER) && (old->mnt_flags & MNT_USER)) {
+ owner = old->mnt_uid;
+ flag |= CL_SETUSER;
+ }
+
if (flag & CL_SETUSER) {
int err = reserve_user_mount();
if (err)
@@ -2141,7 +2146,7 @@ static struct mnt_namespace *dup_mnt_ns(
down_write(&namespace_sem);
/* First pass: copy the tree topology */
new_ns->root = copy_tree(mnt_ns->root, mnt_ns->root->mnt_root,
- CL_COPY_ALL | CL_EXPIRE, 0);
+ CL_COPY_ALL | CL_EXPIRE | CL_COPYUSER, 0);
if (IS_ERR(new_ns->root)) {
up_write(&namespace_sem);
kfree(new_ns);
Index: linux/fs/pnode.h
===================================================================
--- linux.orig/fs/pnode.h 2008-03-17 20:55:52.000000000 +0100
+++ linux/fs/pnode.h 2008-03-17 20:55:53.000000000 +0100
@@ -24,6 +24,7 @@
#define CL_PRIVATE 0x20
#define CL_SETUSER 0x40
#define CL_NOSUID 0x80
+#define CL_COPYUSER 0x100
void set_mnt_shared(struct vfsmount *);
void clear_mnt_shared(struct vfsmount *);
--
next prev parent reply other threads:[~2008-03-17 20:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-17 20:00 [patch 00/11] mount ownership and unprivileged mount syscall (v9) Miklos Szeredi
2008-03-17 20:00 ` [patch 01/11] unprivileged mounts: add user mounts to the kernel Miklos Szeredi
2008-03-17 20:00 ` [patch 02/11] unprivileged mounts: allow unprivileged umount Miklos Szeredi
2008-03-17 20:00 ` [patch 03/11] unprivileged mounts: propagate error values from clone_mnt Miklos Szeredi
2008-03-17 20:00 ` [patch 04/11] unprivileged mounts: account user mounts Miklos Szeredi
2008-03-17 20:00 ` [patch 05/11] unprivileged mounts: allow unprivileged bind mounts Miklos Szeredi
2008-03-17 20:00 ` [patch 06/11] unprivileged mounts: allow unprivileged mounts Miklos Szeredi
2008-03-17 20:01 ` [patch 07/11] unprivileged mounts: add sysctl tunable for "safe" property Miklos Szeredi
2008-03-17 20:01 ` [patch 08/11] unprivileged mounts: make fuse safe Miklos Szeredi
2008-03-17 20:01 ` [patch 09/11] unprivileged mounts: propagation: inherit owner from parent Miklos Szeredi
2008-03-17 20:01 ` [patch 10/11] unprivileged mounts: add "no submounts" flag Miklos Szeredi
2008-03-17 20:01 ` Miklos Szeredi [this message]
2008-03-17 22:51 ` [patch 00/11] mount ownership and unprivileged mount syscall (v9) James Morris
2008-03-18 11:33 ` Miklos Szeredi
2008-03-18 23:04 ` James Morris
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=20080317200159.072705368@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=serue@us.ibm.com \
--cc=viro@zeniv.linux.org.uk \
/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