From: "Serge E. Hallyn" <serue@us.ibm.com>
To: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: Andrew Morton <akpm@osdl.org>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm 0/8] user ns: Introduction
Date: Fri, 5 Jan 2007 01:00:42 -0600 [thread overview]
Message-ID: <20070105070042.GA24802@sergelap.austin.ibm.com> (raw)
In-Reply-To: <20070105054337.GB1412@sergelap.austin.ibm.com>
Quoting Serge E. Hallyn (serue@us.ibm.com):
> Quoting Andrew Morton (akpm@osdl.org):
> > On Thu, 4 Jan 2007 12:06:35 -0600
> > "Serge E. Hallyn" <serue@us.ibm.com> wrote:
> >
> > > This patchset adds a user namespace, which allows a process to
> > > unshare its user_struct table, allowing for separate accounting
> > > per user namespace.
> >
> > With these patches applied and with CONFIG_USER_NS=n, my selinux-enabled
> > standard FC5 machine throws a complete fit:
...
> >
> > Setting CONFIG_USER_NS=y fixes this.
>
> Ok, I see. The CONFIG_USER_NS split is absolutely horrible. Should
> really get rid of the user_ns pointers altogether when !CONFIG_USER_NS.
> I'll try to fix it up without putting ifdefs all over - planning to send
> a patch tomorrow.
Actually it's not that bad. Following patch fixes what I believe is
the underlying problem, and in any case was a definite bug.
thanks,
-serge
From: Serge E. Hallyn <serue@us.ibm.com>
Subject: [PATCH 1/1] user ns: fix !CONFIG_USER_NS mount denial
Don't do user_ns permission checks when !CONFIG_USER_NS.
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
---
fs/namespace.c | 6 ++----
include/linux/sched.h | 8 ++++++++
include/linux/user_namespace.h | 15 +++++++++++++++
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index 2ed89d4..664c6f2 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -236,10 +236,8 @@ static struct vfsmount *clone_mnt(struct
struct super_block *sb = old->mnt_sb;
struct vfsmount *mnt;
- if (!(old->mnt_flags & MNT_SHARE_NS)) {
- if (old->mnt_user_ns != current->nsproxy->user_ns)
- return ERR_PTR(-EPERM);
- }
+ if (!clone_mnt_userns_permission(old))
+ return ERR_PTR(-EPERM);
mnt = alloc_vfsmnt(old->mnt_devname);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 55ecf81..0542f34 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1588,6 +1588,7 @@ extern int cond_resched(void);
extern int cond_resched_lock(spinlock_t * lock);
extern int cond_resched_softirq(void);
+#ifdef CONFIG_USER_NS
/*
* Check whether a task and a vfsmnt belong to the same uidns.
* Since the initial namespace is exempt from these checks,
@@ -1606,6 +1607,13 @@ static inline int task_mnt_same_uidns(st
return 1;
return 0;
}
+#else
+static inline int task_mnt_same_uidns(struct task_struct *tsk,
+ struct vfsmount *mnt)
+{
+ return 1;
+}
+#endif
/*
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index be3e484..e4ce9cb 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -35,6 +35,16 @@ static inline void put_user_ns(struct us
kref_put(&ns->kref, free_user_ns);
}
+static inline int clone_mnt_userns_permission(struct vfsmount *old)
+{
+ if (!(old->mnt_flags & MNT_SHARE_NS)) {
+ if (old->mnt_user_ns != current->nsproxy->user_ns)
+ return 0;
+ }
+
+ return 1;
+}
+
#else
static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
@@ -59,6 +69,11 @@ static inline int copy_user_ns(int flags
static inline void put_user_ns(struct user_namespace *ns)
{
}
+
+static inline int clone_mnt_userns_permission(struct vfsmount *old)
+{
+ return 1;
+}
#endif
#endif /* _LINUX_USER_H */
--
1.4.1
prev parent reply other threads:[~2007-01-05 7:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-04 18:06 Serge E. Hallyn
2007-01-04 18:10 ` [PATCH -mm 1/8] nsproxy: externalizes exit_task_namespaces Serge E. Hallyn
2007-01-04 18:11 ` [PATCH -mm 2/8] user namespace: add the framework Serge E. Hallyn
2007-01-04 21:16 ` Serge E. Hallyn
2007-01-04 18:11 ` [PATCH -mm 3/8] user ns: add user_namespace ptr to vfsmount Serge E. Hallyn
2007-01-04 18:11 ` [PATCH -mm 4/8] user ns: hook permission Serge E. Hallyn
2007-01-04 18:12 ` [PATCH -mm 5/8] user ns: prepare copy_tree, copy_mnt, and their callers to handle errs Serge E. Hallyn
2007-01-04 19:00 ` Frederik Deweerdt
2007-01-04 19:35 ` Serge E. Hallyn
2007-01-04 18:12 ` [PATCH -mm 6/8] user ns: implement shared mounts Serge E. Hallyn
2007-01-04 18:12 ` [PATCH -mm 7/8] user_ns: handle file sigio Serge E. Hallyn
2007-01-12 5:20 ` Andrew Morton
2007-01-15 7:26 ` Serge E. Hallyn
2007-01-15 15:03 ` Cedric Le Goater
2007-01-15 15:28 ` Serge E. Hallyn
2007-01-15 17:35 ` Cedric Le Goater
2007-01-16 11:04 ` [PATCH -mm] user_ns: remove CONFIG_USER_NS Cedric Le Goater
2007-01-16 14:53 ` Serge E. Hallyn
2007-01-04 18:13 ` [PATCH -mm 8/8] user ns: implement user ns unshare Serge E. Hallyn
2007-01-04 19:07 ` Frederik Deweerdt
2007-01-04 19:43 ` Serge E. Hallyn
2007-01-04 22:03 ` Andrew Morton
2007-01-04 22:07 ` Andrew Morton
2007-01-04 22:23 ` Valdis.Kletnieks
2007-01-04 22:52 ` Serge E. Hallyn
2007-01-05 2:02 ` Valdis.Kletnieks
2007-01-05 4:35 ` Serge E. Hallyn
2007-01-05 4:03 ` [PATCH -mm 0/8] user ns: Introduction Andrew Morton
2007-01-05 5:43 ` Serge E. Hallyn
2007-01-05 7:00 ` Serge E. Hallyn [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=20070105070042.GA24802@sergelap.austin.ibm.com \
--to=serue@us.ibm.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.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
Powered by JetHome