Completing the user namespace
Subsystems (36)
Serge E. Hallyn
Acked-by Serge HallynRe: [PATCH 32/43] userns: signal remove unnecessary map_cred_ns
In reply to a message not in the archiveQuoted 6 lines · Eric W. Beiderman
From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
map_cred_nsis a light wrapper aroundfrom_kuidwith the order of the arguments reversed. Replacemap_cred_nswithfrom_kuidand removemap_cred_ns.
Quoted 63 lines
--- kernel/signal.c | 20 +++++--------------- 1 files changed, 5 insertions(+), 15 deletions(-)kernel/signal.c +5
-15@@ -1019,15 +1019,6 @@ static inline int legacy_queue(struct sigpending *signals, int sig)return (sig <SIGRTMIN ) &&sigismember (&signals->signal, sig); } -/* -* map the uid in struct cred into user namespace *ns -*/ -static inline uid_t map_cred_ns (const struct cred *cred, -struct user_namespace *ns) -{ -return from_kuid_munged (ns, cred->uid); -} -#ifdef CONFIG_USER_NS static inline void userns_fixup_signal_uid (struct siginfo *info,struct task_struct *t) {@@ -1677,8 +1668,8 @@ bool do_notify_parent(struct task_struct *tsk, int sig)*/ rcu_read_lock (); info.si_pid =task_pid_nr_ns (tsk, tsk->parent->nsproxy->pid_ns); - info.si_uid =map_cred_ns (__task_cred (tsk), -task_cred_xxx (tsk->parent, user_ns)); + info.si_uid =from_kuid_munged (task_cred_xxx (tsk->parent, user_ns), +task_uid (tsk));rcu_read_unlock (); info.si_utime =cputime_to_clock_t (tsk->utime + tsk->signal->utime);@@ -1761,8 +1752,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,*/ rcu_read_lock (); info.si_pid =task_pid_nr_ns (tsk, parent->nsproxy->pid_ns); - info.si_uid =map_cred_ns (__task_cred (tsk), -task_cred_xxx (parent, user_ns)); + info.si_uid =from_kuid_munged (task_cred_xxx (parent, user_ns),task_uid (tsk));rcu_read_unlock (); info.si_utime =cputime_to_clock_t (tsk->utime);@@ -2180,8 +2170,8 @@ static int ptrace_signal(int signr, siginfo_t *info, info->si_code =SI_USER ;rcu_read_lock (); info->si_pid =task_pid_vnr (current->parent); - info->si_uid =map_cred_ns (__task_cred (current->parent), -current_user_ns ()); + info->si_uid =from_kuid_munged (current_user_ns (), +task_uid (current->parent));rcu_read_unlock (); }Signature · 6 lines
1.7.2.5 _______________________________________________ Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org https://lists.linuxfoundation.org/mailman/listinfo/containers
Serge E. Hallyn
maintainerRe: [PATCH 30/43] userns: Fail exec for suid and sgid binaries with ids outside our user namespace.
In reply to Eric W. BeidermanQuoted 2 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Oh, perhaps this is the right place in the thread to discuss the issue of what to do with file capabilities? I'm ok waiting until the next iteration to even discuss it, so long as we start by refusing setting of fcaps by any task not in init_user_ns.
Quoted 37 lines
Signed-off-by Eric W. Biederman <[email protected]>--- fs/exec.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)fs/exec.c +5
-0@@ -1291,8 +1291,11 @@ int prepare_binprm(struct linux_binprm *bprm)if (!(bprm->file->f_path.mnt->mnt_flags &MNT_NOSUID )) {/* Set-uid? */ if (mode &S_ISUID ) { +if (!kuid_has_mapping (bprm->cred->user_ns, inode->i_uid)) +return -EPERM ; bprm->per_clear |=PER_CLEAR_ON_SETID ; bprm->cred->euid = inode->i_uid; + }/* Set-gid? */ @@ -1302,6 +1305,8 @@ int prepare_binprm(struct linux_binprm *bprm)* executable. */ if ((mode & (S_ISGID |S_IXGRP )) == (S_ISGID |S_IXGRP )) { +if (!kgid_has_mapping (bprm->cred->user_ns, inode->i_gid)) +return -EPERM ; bprm->per_clear |=PER_CLEAR_ON_SETID ; bprm->cred->egid = inode->i_gid; }Signature · 6 lines
1.7.2.5 _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
Re: [PATCH 30/43] userns: Fail exec for suid and sgid binaries with ids outside our user namespace.
In reply to a message not in the archiveQuoted 2 lines · Eric W. Beiderman
From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
Oh, perhaps this is the right place in the thread to discuss the issue of what to do with file capabilities? I'm ok waiting until the next iteration to even discuss it, so long as we start by refusing setting of fcaps by any task not in init_user_ns.
Quoted 37 lines
--- fs/exec.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)fs/exec.c +5
-0@@ -1291,8 +1291,11 @@ int prepare_binprm(struct linux_binprm *bprm)if (!(bprm->file->f_path.mnt->mnt_flags &MNT_NOSUID )) {/* Set-uid? */ if (mode &S_ISUID ) { +if (!kuid_has_mapping (bprm->cred->user_ns, inode->i_uid)) +return -EPERM ; bprm->per_clear |=PER_CLEAR_ON_SETID ; bprm->cred->euid = inode->i_uid; + }/* Set-gid? */ @@ -1302,6 +1305,8 @@ int prepare_binprm(struct linux_binprm *bprm)* executable. */ if ((mode & (S_ISGID |S_IXGRP )) == (S_ISGID |S_IXGRP )) { +if (!kgid_has_mapping (bprm->cred->user_ns, inode->i_gid)) +return -EPERM ; bprm->per_clear |=PER_CLEAR_ON_SETID ; bprm->cred->egid = inode->i_gid; }Signature · 6 lines
1.7.2.5 _______________________________________________ Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org https://lists.linuxfoundation.org/mailman/listinfo/containers
Re: [PATCH 33/43] userns: Convert binary formats to use kuid/kgid where appropriate
In reply to Eric W. BeidermanQuoted 3 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Signed-off-by Eric W. Biederman <[email protected]>
Ok I'll spare the list the traffic - for patches 33-43,
Thanks, Eric.
-serge
Serge E. Hallyn
Acked-by Serge HallynRe: [PATCH 33/43] userns: Convert binary formats to use kuid/kgid where appropriate
In reply to a message not in the archiveQuoted 3 lines · Eric W. Beiderman
From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
Ok I'll spare the list the traffic - for patches 33-43,
Thanks, Eric.
-serge
Re: [PATCH 16/43] userns: Simplify the user_namespace by making userns->creator a kuid.
In reply to Serge E. HallynQuoted 91 lines · Serge E. Hallyn
Quoted 90 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
- Transform
userns->creatorfrom auser_structreference to a simplekuid_t,kgid_tpair.In
cap_capablethis allows the check to see if we are the creator of a namespace to become the classic suser style euid permission check.This allows us to remove the need for a struct cred in the mapping functions and still be able to dispaly the user namespace creators uid and gid as 0.
- Remove the now unnecessary
delayed_workinfree_user_ns.All that is left for
free_user_nsto do is to callkmem_cache_freeandput_user_ns. Those functions can be called in any context so call them directly fromfree_user_nsremoving the need for delayed work.Signed-off-by Eric W. Biederman <[email protected]>--- include/linux/user_namespace.h | 4 ++-- kernel/user.c | 7 ++++--- kernel/user_namespace.c | 39 ++++++++++++++++++--------------------- security/commoncap.c | 5 +++-- 4 files changed, 27 insertions(+), 28 deletions(-)include/linux/user_namespace.h +2
-2@@ -9,8 +9,8 @@struct user_namespace {struct kref kref;struct user_namespace *parent; -struct user_struct *creator; -struct work_struct destroyer; +kuid_t owner; +kgid_t group; };extern struct user_namespace init_user_ns;kernel/user.c +4
-3@@ -25,7 +25,8 @@ struct user_namespace init_user_ns = { .kref = { .refcount = ATOMIC_INIT(3), }, - .creator = &root_user, + .owner = GLOBAL_ROOT_UID, + .group = GLOBAL_ROOT_GID, };EXPORT_SYMBOL_GPL (init_user_ns);@@ -54,9 +55,9 @@ struct hlist_head uidhash_table[UIDHASH_SZ];*/ static DEFINE_SPINLOCK (uidhash_lock); -/* root_user.__count is 2, 1 for init task cred, 1 for init_user_ns->user_ns */ +/* root_user.__count is 1, for init task cred */ struct user_struct root_user = { - .__count =ATOMIC_INIT (2 ), + .__count =ATOMIC_INIT (1 ), .processes =ATOMIC_INIT (1 ), .files =ATOMIC_INIT (0 ), .sigpending =ATOMIC_INIT (0 ),kernel/user_namespace.c +10
-0@@ -27,6 +27,16 @@ int create_user_ns(struct cred *new) {struct user_namespace *ns, *parent_ns = new->user_ns;struct user_struct *root_user; +kuid_t owner =make_kuid (new->user_ns, new->euid); +kgid_t group =make_kgid (new->user_ns, new->egid); + +/* The creator needs a mapping in the parent user namespace +* or else we won't be able to reasonably tell userspace who +* created a user_namespace. +*/ +if (!kuid_has_mapping (parent_ns, owner) || + !kgid_has_mapping (parent_ns, group)) +return -EPERM ; ns =kmem_cache_alloc (user_ns_cachep,GFP_KERNEL );if (!ns)@@ -43,7 +53,9 @@ int create_user_ns(struct cred *new)
Quoted 5 lines
kernel/user_namespace.c int create_user_ns(struct cred *new) · line 55
Quoted 2 lines
kernel/user_namespace.c +0
-0/* set the new root user in the credentials under preparation */ ns->parent = parent_ns;I think in the past the creator cred pinned the
ns->parent. Do you now need to explicitly pinns->parent(and release it infree_user_ns())?
Yes we do have to explicitly reference count the parent namespace. But that happened in the patch 7:
"userns: Add an explicit reference to the parent user namespace"
Eric
Re: [PATCH 16/43] userns: Simplify the user_namespace by making userns->creator a kuid.
In reply to a message not in the archiveQuoted 91 lines · Serge E. Hallyn
Quoted 90 lines · Eric W. Beiderman
From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
- Transform
userns->creatorfrom auser_structreference to a simplekuid_t,kgid_tpair.In
cap_capablethis allows the check to see if we are the creator of a namespace to become the classic suser style euid permission check.This allows us to remove the need for a struct cred in the mapping functions and still be able to dispaly the user namespace creators uid and gid as 0.
- Remove the now unnecessary
delayed_workinfree_user_ns.All that is left for
free_user_nsto do is to callkmem_cache_freeandput_user_ns. Those functions can be called in any context so call them directly fromfree_user_nsremoving the need for delayed work.--- include/linux/user_namespace.h | 4 ++-- kernel/user.c | 7 ++++--- kernel/user_namespace.c | 39 ++++++++++++++++++--------------------- security/commoncap.c | 5 +++-- 4 files changed, 27 insertions(+), 28 deletions(-)include/linux/user_namespace.h +2
-2@@ -9,8 +9,8 @@struct user_namespace {struct kref kref;struct user_namespace *parent; -struct user_struct *creator; -struct work_struct destroyer; +kuid_t owner; +kgid_t group; };extern struct user_namespace init_user_ns;kernel/user.c +4
-3@@ -25,7 +25,8 @@ struct user_namespace init_user_ns = { .kref = { .refcount = ATOMIC_INIT(3), }, - .creator = &root_user, + .owner = GLOBAL_ROOT_UID, + .group = GLOBAL_ROOT_GID, };EXPORT_SYMBOL_GPL (init_user_ns);@@ -54,9 +55,9 @@ struct hlist_head uidhash_table[UIDHASH_SZ];*/ static DEFINE_SPINLOCK (uidhash_lock); -/* root_user.__count is 2, 1 for init task cred, 1 for init_user_ns->user_ns */ +/* root_user.__count is 1, for init task cred */ struct user_struct root_user = { - .__count =ATOMIC_INIT (2 ), + .__count =ATOMIC_INIT (1 ), .processes =ATOMIC_INIT (1 ), .files =ATOMIC_INIT (0 ), .sigpending =ATOMIC_INIT (0 ),kernel/user_namespace.c +10
-0@@ -27,6 +27,16 @@ int create_user_ns(struct cred *new) {struct user_namespace *ns, *parent_ns = new->user_ns;struct user_struct *root_user; +kuid_t owner =make_kuid (new->user_ns, new->euid); +kgid_t group =make_kgid (new->user_ns, new->egid); + +/* The creator needs a mapping in the parent user namespace +* or else we won't be able to reasonably tell userspace who +* created a user_namespace. +*/ +if (!kuid_has_mapping (parent_ns, owner) || + !kgid_has_mapping (parent_ns, group)) +return -EPERM ; ns =kmem_cache_alloc (user_ns_cachep,GFP_KERNEL );if (!ns)@@ -43,7 +53,9 @@ int create_user_ns(struct cred *new)
Quoted 5 lines
kernel/user_namespace.c int create_user_ns(struct cred *new) · line 55
Quoted 2 lines
kernel/user_namespace.c +0
-0/* set the new root user in the credentials under preparation */ ns->parent = parent_ns;I think in the past the creator cred pinned the
ns->parent. Do you now need to explicitly pinns->parent(and release it infree_user_ns())?
Yes we do have to explicitly reference count the parent namespace. But that happened in the patch 7:
"userns: Add an explicit reference to the parent user namespace"
Eric
Re: [PATCH 18/43] userns: Convert group_info values from gid_t to kgid_t.
In reply to Serge E. HallynQuoted 54 lines · Serge E. Hallyn
Quoted 44 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
As a first step to converting struct cred to be all
kuid_tandkgid_tvalues convert the group values stored ingroup_infoto always bekgid_tvalues. Unless user namespaces are used this change should
have no effect.Signed-off-by Eric W. Biederman <[email protected]>--- arch/s390/kernel/compat_linux.c | 13 ++++++++- fs/nfsd/auth.c | 5 ++- fs/proc/array.c | 5 +++- include/linux/cred.h | 9 ++++--- kernel/groups.c | 48 +++++++++++++++++++----------------- kernel/uid16.c | 14 +++++++++- net/ipv4/ping.c | 11 ++++++-- net/sunrpc/auth_generic.c | 4 +- net/sunrpc/auth_gss/svcauth_gss.c | 7 ++++- net/sunrpc/auth_unix.c | 15 ++++++++--- net/sunrpc/svcauth_unix.c | 18 ++++++++++--- security/keys/permission.c | 3 +- 12 files changed, 103 insertions(+), 49 deletions(-)arch/s390/kernel/compat_linux.c +4
-1@@ -173,11 +173,14 @@ asmlinkage long sys32_setfsgid16(u16 gid)static int groups16_to_user (u16 __user *grouplist,struct group_info *group_info) { +struct user_namespace *user_ns =current_user_ns ();int i;u16 group; +kgid_t kgid;for (i =0 ; i < group_info->ngroups; i++) { - group = (u16 )GROUP_AT (group_info, i); + kgid =GROUP_AT (group_info, i); + group = (u16 )from_kgid_munged (user_ns, kgid);if (put_user (group, grouplist+i))return -EFAULT ; }arch/s390/kernel/compat_linux.c static int groups16_to_user(u16 __user *grouplist, struct group_info *group_info · line 195
Quoted 6 lines
arch/s390/kernel/compat_linux.c +1
-0@@ -187,13 +190,19 @@ static int groups16_to_user(u16 __user *grouplist, struct group_info *group_infostatic int groups16_from_user (struct group_info *group_info,u16 __user *grouplist) { +struct user_namespace *user_ns =current_user_ns ();int i;u16 group;need
Quoted 3 lines
kgid_t kgid;here
Doh! Thank you.
Now I am wondering why s390 has it's own copy of this function instead of using the version in uid16.c.
Quoted 12 lines
Quoted 12 lines
arch/s390/kernel/compat_linux.c +6
-1for (i =0 ; i < group_info->ngroups; i++) {if (get_user (group, grouplist+i))return -EFAULT ; -GROUP_AT (group_info, i) = (gid_t )group; + + kgid =make_kgid (user_ns, (gid_t )group); +if (!gid_valid (kgid)) +return -EINVAL ; + +GROUP_AT (group_info, i) = kgid; }
Quoted 1 line
arch/s390/kernel/compat_linux.c static int groups16_to_user(u16 __user *grouplist, struct group_info *group_info · line 207
Quoted 1 line
arch/s390/kernel/compat_linux.c +0
-0return 0 ;
Eric
Re: [PATCH 22/43] userns: Convert capabilities related permsion checks
In reply to Serge E. HallynQuoted 20 lines · Serge E. Hallyn
Quoted 8 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
- Use
uid_eqwhen comparing kuids
Usegid_eqwhen comparing kgids
- Use__make_kuid(user_ns, 0)to talk about theuser_namespaceroot uid Use__make_kgid(user_ns, 0)to talk about theuser_namespaceroot gidSigned-off-by Eric W. Biederman <[email protected]>Acked-by Serge Hallyn <[email protected]>though, nit,
Quoted 5 lines
--- fs/open.c | 3 ++- security/commoncap.c | 43 ++++++++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 16 deletions(-)
Quoted 12 lines
security/commoncap.c int cap_bprm_set_creds(struct linux_binprm *bprm) · line 476
Quoted 10 lines
security/commoncap.c +2
-0@@ -472,19 +472,24 @@ int cap_bprm_set_creds(struct linux_binprm *bprm)struct cred *new = bprm->cred;bool effective, has_cap = false;int ret; +kuid_t root_uid; +kgid_t root_gid;the
root_gidis assigned but never used.
Thanks snipped. It doesn't look like there will ever be a use for it.
Quoted 9 lines
security/commoncap.c int cap_bprm_set_creds(struct linux_binprm *bprm) · line 485
Quoted 9 lines
security/commoncap.c +3
-0effective = false; ret =get_file_caps (bprm, &effective, &has_cap);if (ret <0 )return ret; + root_uid =make_kuid (new->user_ns,0 ); + root_gid =make_kgid (new->user_ns,0 ); +
Eric
Re: [PATCH 24/43] userns: Convert ptrace, kill, set_priority permission checks to work with kuids and kgids
In reply to Serge E. HallynQuoted 20 lines · Serge E. Hallyn
Quoted 9 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Update the permission checks to use the new
uid_eqandgid_eqhelpers and remove the now unnecessaryuser_nsequality comparison.Signed-off-by Eric W. Biederman <[email protected]>---
kernel/signal.c static int kill_as_cred_perm(const struct cred *cred, · line 1391
Quoted 8 lines
kernel/signal.c +1
-4@@ -1389,10 +1388,8 @@ static int kill_as_cred_perm(const struct cred *cred, struct task_struct *target) {const struct cred *pcred =__task_cred (target); -if (cred->user_ns != pcred->user_ns) -return 0 ; -if (cred->euid != pcred->suid && cred->euid != pcred->uid && - cred->uid != pcred->suid && cred->uid != pcred->uid) + if (uid_eq(cred->euid, pcred->suid) && uid_eq(cred->euid, pcred->uid) &&These should be !uid_eq() right?
Quoted 2 lines
Review static int kill_as_cred_perm(const struct cred *cred, · line 1392
Quoted 1 line
(quoted diff) +1
-0+ uid_eq(cred->uid, pcred->suid) && uid_eq(cred->uid,
pcred->uid))
Yes.
Thank you for catching this. This kind of mistake is unfortunately much to easy to make.
Eric
Re: [PATCH 27/43] userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs
In reply to Serge E. HallynQuoted 28 lines · Serge E. Hallyn
Quoted 27 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Signed-off-by Eric W. Biederman <[email protected]>--- fs/attr.c | 8 ++++---- fs/exec.c | 10 +++++----- fs/fcntl.c | 6 +++--- fs/ioprio.c | 4 ++-- fs/locks.c | 2 +- fs/namei.c | 8 ++++---- include/linux/quotaops.h | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-)fs/attr.c +2
-2@@ -47,14 +47,14 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)/* Make sure a caller can chown. */ if ((ia_valid &ATTR_UID ) && - (current_fsuid () != inode->i_uid || - attr->ia_uid != inode->i_uid) && !capable (CAP_CHOWN )) + (!uid_eq (current_fsuid (), inode->i_uid) || + !uid_eq (attr->ia_uid, inode->i_uid)) && !capable (CAP_CHOWN ))return -EPERM ;
Quoted 8 lines
fs/attr.c int inode_change_ok(const struct inode *inode, struct iattr *attr) · line 57
Quoted 6 lines
fs/attr.c +2
-2/* Make sure caller can chgrp. */ if ((ia_valid & ATTR_GID) && - (current_fsuid() != inode->i_uid || - (!in_group_p(attr->ia_gid) && attr->ia_gid != inode->i_gid)) && + (!uid_eq(current_fsuid(), inode->i_uid) || + (!in_group_p(attr->ia_gid) && gid_eq(attr->ia_gid, inode->i_gid))) &&This should be !gid_eq() ?
Yes. Thank you, it is now fixed in my tree.
Eric
Re: [PATCH 27/43] userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs
In reply to a message not in the archiveQuoted 28 lines · Serge E. Hallyn
Quoted 27 lines · Eric W. Beiderman
From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
--- fs/attr.c | 8 ++++---- fs/exec.c | 10 +++++----- fs/fcntl.c | 6 +++--- fs/ioprio.c | 4 ++-- fs/locks.c | 2 +- fs/namei.c | 8 ++++---- include/linux/quotaops.h | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-)fs/attr.c +2
-2@@ -47,14 +47,14 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)/* Make sure a caller can chown. */ if ((ia_valid &ATTR_UID ) && - (current_fsuid () != inode->i_uid || - attr->ia_uid != inode->i_uid) && !capable (CAP_CHOWN )) + (!uid_eq (current_fsuid (), inode->i_uid) || + !uid_eq (attr->ia_uid, inode->i_uid)) && !capable (CAP_CHOWN ))return -EPERM ;
Quoted 8 lines
fs/attr.c int inode_change_ok(const struct inode *inode, struct iattr *attr) · line 57
Quoted 6 lines
fs/attr.c +2
-2/* Make sure caller can chgrp. */ if ((ia_valid & ATTR_GID) && - (current_fsuid() != inode->i_uid || - (!in_group_p(attr->ia_gid) && attr->ia_gid != inode->i_gid)) && + (!uid_eq(current_fsuid(), inode->i_uid) || + (!in_group_p(attr->ia_gid) && gid_eq(attr->ia_gid, inode->i_gid))) &&This should be !gid_eq() ?
Yes. Thank you, it is now fixed in my tree.
Eric
Re: [PATCH 27/43] userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs
In reply to Serge E. HallynQuoted 15 lines · Serge E. Hallyn
Quoted 13 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Signed-off-by Eric W. Biederman <[email protected]>--- fs/attr.c | 8 ++++---- fs/exec.c | 10 +++++----- fs/fcntl.c | 6 +++--- fs/ioprio.c | 4 ++-- fs/locks.c | 2 +- fs/namei.c | 8 ++++---- include/linux/quotaops.h | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-)
Quoted 9 lines
fs/exec.c void do_coredump(long signr, int exit_code, struct pt_regs *regs) · line 2123
Quoted 6 lines
fs/exec.c +1
-1@@ -2120,7 +2120,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)if (__get_dumpable (cprm.mm_flags) ==2 ) {/* Setuid core dump mode */ flag =O_EXCL ;/* Stop rewrite attacks */ - cred->fsuid =0 ;/* Dump root private */ + cred->fsuid =GLOBAL_ROOT_UID ;/* Dump root private */ Sorry, one more - can this be the per-ns root uid? The coredumps should be ok to belong to privileged users in the namespace right?
I'm not certain it was clear when you were looking at this that this is about dumping core from suid applications, not normal applications.
Looking at the code in commoncap and commit_creds it looks like it is a
bug that we don't call set_dumpable(new, suid_dumpable) in common cap when we use file capabilities. I might be wrong but I think we escape the test in commit_creds in that case.
Having thought about it we can make this per namespace but not in this patch.
Things that I see as missing.
- We likely need to make the suid_dumpable sysctl per namespace. There is a prctl so it is already per process.
- We would need to capture the user_namespace at mm creation time, during exec, so we know which root user we could use.
By it's nature we know an mm can't escape a user namespace so the user namespace an mm is created in will have a root user we can dump core as.
I was wondering if we could relax this to a uid captured at mm creation time (and certainly we can capture the root user), but there are enough weird cases I don't think it is possible to safely allow anything more relaxed that the root of the user_namespace that created the mm.
I don't believe we can't use the user_namespace of current because the application may have been suid and then cloned a new user namespace keeping the mm or perhaps just the uid/euid split.
So in short it is doable but a little tricky so it doesn't belong in a patch with a bunch of boring and safe conversions.
Eric
Re: [PATCH 30/43] userns: Fail exec for suid and sgid binaries with ids outside our user namespace.
In reply to Serge E. HallynQuoted 8 lines · Serge E. Hallyn
Quoted 2 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Oh, perhaps this is the right place in the thread to discuss the issue of what to do with file capabilities? I'm ok waiting until the next iteration to even discuss it, so long as we start by refusing setting of fcaps by any task not in
init_user_ns.
For now we do refuse all callers in the init_user_ns because that path is protected by a capable and not an ns_capable call.
And as a general policy I have pushed all of the changes from capable to ns_capable out till after we get these other user namespace bits so we can get the patches reviewed so hopefully don't enable something that is not safe.
Let's just note here that when we ever get a filesystem mounted in something other than the init_user_ns or otherwise allow file capabilities that do not belong to the init_user_ns we need to an additional exec check to avoid a security issue for processes in the init_user_ns using those credentials.
The other direction the init_user_ns setting file caps on a file and use using them in a child namespace seems safe, and practical because of the way we handle capabilities. Aka if you have a capability in an outer user namespace you also have it in a child user namespace. Which means a file cap exec today will give you just the capabilities in the child user namespace.
Something else to think about when we reach filesystems mounted in different user namespaces (aka unprivileged mounts) are security labels on files in different user namespaces. Not any kind of immediate concern but something we may have to handle eventually.
Eric
Re: [PATCH 33/43] userns: Convert binary formats to use kuid/kgid where appropriate
In reply to Serge E. HallynQuoted 8 lines · Serge E. Hallyn
Quoted 3 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Signed-off-by Eric W. Biederman <[email protected]>Ok I'll spare the list the traffic - for patches 33-43,
Acked-by Serge Hallyn <[email protected]>
I noticed one other significant gotcha with my changes.
Code that has not been converted and needs to be converted fails to build with type errors. -- Good.
Code that has not been converted and needs to be converted is still selectable in make config. -- Bad
make oldmodconfig -- fails with type errors unless everything is converted Bad.
So I am adding/debugging an additional patch that will catch these failure in Kconfig so people don't get nasty surprises.
Eric
Re: [PATCH 33/43] userns: Convert binary formats to use kuid/kgid where appropriate
In reply to a message not in the archiveQuoted 8 lines · Serge E. Hallyn
Quoted 3 lines · Eric W. Beiderman
From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
Ok I'll spare the list the traffic - for patches 33-43,
Acked-by Serge Hallyn <[email protected]>
I noticed one other significant gotcha with my changes.
Code that has not been converted and needs to be converted fails to build with type errors. -- Good.
Code that has not been converted and needs to be converted is still selectable in make config. -- Bad
make oldmodconfig -- fails with type errors unless everything is converted Bad.
So I am adding/debugging an additional patch that will catch these failure in Kconfig so people don't get nasty surprises.
Eric
Re: [PATCH 30/43] userns: Fail exec for suid and sgid binaries with ids outside our user namespace.
In reply to Eric W. BiedermanQuoted 32 lines · Eric W. Biederman
Quoted 8 lines · Serge E. Hallyn
Quoted 2 lines · Eric W. Beiderman
From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
Oh, perhaps this is the right place in the thread to discuss the issue of what to do with file capabilities? I'm ok waiting until the next iteration to even discuss it, so long as we start by refusing setting of fcaps by any task not in
init_user_ns.For now we do refuse all callers in the
init_user_nsbecause that path is protected by a capable and not anns_capablecall.And as a general policy I have pushed all of the changes from capable to
ns_capableout till after we get these other user namespace bits so we can get the patches reviewed so hopefully don't enable something that is not safe.Let's just note here that when we ever get a filesystem mounted in something other than the
init_user_nsor otherwise allow file capabilities that do not belong to theinit_user_nswe need to an additional exec check to avoid a security issue for processes in theinit_user_nsusing those credentials.The other direction the
init_user_nssetting file caps on a file and use using them in a child namespace seems safe, and practical because of the way we handle capabilities. Aka if you have a capability in an outer user namespace you also have it in a child user namespace. Which means a file cap exec today will give you just the capabilities in the child user namespace.
Quoted 4 lines
Something else to think about when we reach filesystems mounted in different user namespaces (aka unprivileged mounts) are security labels on files in different user namespaces. Not any kind of immediate concern but something we may have to handle eventually.
An interesting concern to discuss at the security mini-summit (or just at the UDS session).
-serge
Serge E. Hallyn
maintainerRe: [PATCH 16/43] userns: Simplify the user_namespace by making userns->creator a kuid.
In reply to Eric W. BiedermanQuoted 99 lines · Eric W. Biederman
Quoted 91 lines · Serge E. Hallyn
Quoted 90 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
- Transform
userns->creatorfrom auser_structreference to a simplekuid_t,kgid_tpair.In
cap_capablethis allows the check to see if we are the creator of a namespace to become the classic suser style euid permission check.This allows us to remove the need for a struct cred in the mapping functions and still be able to dispaly the user namespace creators uid and gid as 0.
- Remove the now unnecessary
delayed_workinfree_user_ns.All that is left for
free_user_nsto do is to callkmem_cache_freeandput_user_ns. Those functions can be called in any context so call them directly fromfree_user_nsremoving the need for delayed work.Signed-off-by Eric W. Biederman <[email protected]>--- include/linux/user_namespace.h | 4 ++-- kernel/user.c | 7 ++++--- kernel/user_namespace.c | 39 ++++++++++++++++++--------------------- security/commoncap.c | 5 +++-- 4 files changed, 27 insertions(+), 28 deletions(-)include/linux/user_namespace.h +2
-2@@ -9,8 +9,8 @@struct user_namespace {struct kref kref;struct user_namespace *parent; -struct user_struct *creator; -struct work_struct destroyer; +kuid_t owner; +kgid_t group; };extern struct user_namespace init_user_ns;kernel/user.c +4
-3@@ -25,7 +25,8 @@ struct user_namespace init_user_ns = { .kref = { .refcount = ATOMIC_INIT(3), }, - .creator = &root_user, + .owner = GLOBAL_ROOT_UID, + .group = GLOBAL_ROOT_GID, };EXPORT_SYMBOL_GPL (init_user_ns);@@ -54,9 +55,9 @@ struct hlist_head uidhash_table[UIDHASH_SZ];*/ static DEFINE_SPINLOCK (uidhash_lock); -/* root_user.__count is 2, 1 for init task cred, 1 for init_user_ns->user_ns */ +/* root_user.__count is 1, for init task cred */ struct user_struct root_user = { - .__count =ATOMIC_INIT (2 ), + .__count =ATOMIC_INIT (1 ), .processes =ATOMIC_INIT (1 ), .files =ATOMIC_INIT (0 ), .sigpending =ATOMIC_INIT (0 ),kernel/user_namespace.c +10
-0@@ -27,6 +27,16 @@ int create_user_ns(struct cred *new) {struct user_namespace *ns, *parent_ns = new->user_ns;struct user_struct *root_user; +kuid_t owner =make_kuid (new->user_ns, new->euid); +kgid_t group =make_kgid (new->user_ns, new->egid); + +/* The creator needs a mapping in the parent user namespace +* or else we won't be able to reasonably tell userspace who +* created a user_namespace. +*/ +if (!kuid_has_mapping (parent_ns, owner) || + !kgid_has_mapping (parent_ns, group)) +return -EPERM ; ns =kmem_cache_alloc (user_ns_cachep,GFP_KERNEL );if (!ns)@@ -43,7 +53,9 @@ int create_user_ns(struct cred *new)Quoted 5 lines
kernel/user_namespace.c int create_user_ns(struct cred *new) · line 55
Quoted 2 lines
kernel/user_namespace.c +0
-0/* set the new root user in the credentials under preparation */ ns->parent = parent_ns;I think in the past the creator cred pinned the
ns->parent. Do you now need to explicitly pinns->parent(and release it infree_user_ns())?
Quoted 3 lines
Yes we do have to explicitly reference count the parent namespace. But that happened in the patch 7:
"userns: Add an explicit reference to the parent user namespace"
Perhaps that suffices, but I'm not convinced. The struct cred is pinning it's own ns, but if t1 does clone(CLONE_NEWUSER) to produce t2, which does the same to procduce t3, and then t2 exits, I'm not seeing what will pin t2's userns.
-serge
Serge E. Hallyn
maintainerRe: [PATCH 27/43] userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs
In reply to Eric W. BiedermanQuoted 27 lines · Eric W. Biederman
Quoted 15 lines · Serge E. Hallyn
Quoted 13 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Signed-off-by Eric W. Biederman <[email protected]>--- fs/attr.c | 8 ++++---- fs/exec.c | 10 +++++----- fs/fcntl.c | 6 +++--- fs/ioprio.c | 4 ++-- fs/locks.c | 2 +- fs/namei.c | 8 ++++---- include/linux/quotaops.h | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-)Quoted 9 lines
fs/exec.c void do_coredump(long signr, int exit_code, struct pt_regs *regs) · line 2123
Quoted 6 lines
fs/exec.c +1
-1@@ -2120,7 +2120,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)if (__get_dumpable (cprm.mm_flags) ==2 ) {/* Setuid core dump mode */ flag =O_EXCL ;/* Stop rewrite attacks */ - cred->fsuid =0 ;/* Dump root private */ + cred->fsuid =GLOBAL_ROOT_UID ;/* Dump root private */ Sorry, one more - can this be the per-ns root uid? The coredumps should be ok to belong to privileged users in the namespace right?
Quoted 3 lines
I'm not certain it was clear when you were looking at this that this is about dumping core from suid applications, not normal applications.
Right, that makes sense, but I was thinking we could just find the root uid for the namespace in which current_euid() is valid.
Waiting is fine :)
Quoted 2 lines
Looking at the code in commoncap and
commit_credsit looks like it is a
bug that we don't callset_dumpable(new, suid_dumpable)in common cap
That sounds like a bug, yes.
Quoted 22 lines
when we use file capabilities. I might be wrong but I think we escape the test in
commit_credsin that case.Having thought about it we can make this per namespace but not in this patch.
Things that I see as missing.
- We likely need to make thesuid_dumpablesysctl per namespace. There is a prctl so it is already per process.
- We would need to capture theuser_namespaceat mm creation time, during exec, so we know which root user we could use.By it's nature we know an mm can't escape a user namespace so the user namespace an mm is created in will have a root user we can dump core as.
I was wondering if we could relax this to a uid captured at mm creation time (and certainly we can capture the root user), but there are enough weird cases I don't think it is possible to safely allow anything more relaxed that the root of the
user_namespacethat created the mm.
Quoted 8 lines
I don't believe we can't use the
user_namespaceof current because the application may have been suid and then cloned a new user namespace keeping the mm or perhaps just the uid/euid split.So in short it is doable but a little tricky so it doesn't belong in a patch with a bunch of boring and safe conversions.
Eric
Thanks for elaborating on that. Makes sense to wait.
-serge
Re: [PATCH 27/43] userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs
In reply to a message not in the archiveQuoted 27 lines · Eric W. Biederman
Quoted 15 lines · Serge E. Hallyn
Quoted 13 lines · Eric W. Beiderman
From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
--- fs/attr.c | 8 ++++---- fs/exec.c | 10 +++++----- fs/fcntl.c | 6 +++--- fs/ioprio.c | 4 ++-- fs/locks.c | 2 +- fs/namei.c | 8 ++++---- include/linux/quotaops.h | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-)Quoted 9 lines
fs/exec.c void do_coredump(long signr, int exit_code, struct pt_regs *regs) · line 2123
Quoted 6 lines
fs/exec.c +1
-1@@ -2120,7 +2120,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)if (__get_dumpable (cprm.mm_flags) ==2 ) {/* Setuid core dump mode */ flag =O_EXCL ;/* Stop rewrite attacks */ - cred->fsuid =0 ;/* Dump root private */ + cred->fsuid =GLOBAL_ROOT_UID ;/* Dump root private */ Sorry, one more - can this be the per-ns root uid? The coredumps should be ok to belong to privileged users in the namespace right?
Quoted 3 lines
I'm not certain it was clear when you were looking at this that this is about dumping core from suid applications, not normal applications.
Right, that makes sense, but I was thinking we could just find the root uid for the namespace in which current_euid() is valid.
Waiting is fine :)
Quoted 2 lines
Looking at the code in commoncap and
commit_credsit looks like it is a
bug that we don't callset_dumpable(new, suid_dumpable)in common cap
That sounds like a bug, yes.
Quoted 22 lines
when we use file capabilities. I might be wrong but I think we escape the test in
commit_credsin that case.Having thought about it we can make this per namespace but not in this patch.
Things that I see as missing.
- We likely need to make thesuid_dumpablesysctl per namespace. There is a prctl so it is already per process.
- We would need to capture theuser_namespaceat mm creation time, during exec, so we know which root user we could use.By it's nature we know an mm can't escape a user namespace so the user namespace an mm is created in will have a root user we can dump core as.
I was wondering if we could relax this to a uid captured at mm creation time (and certainly we can capture the root user), but there are enough weird cases I don't think it is possible to safely allow anything more relaxed that the root of the
user_namespacethat created the mm.
Quoted 8 lines
I don't believe we can't use the
user_namespaceof current because the application may have been suid and then cloned a new user namespace keeping the mm or perhaps just the uid/euid split.So in short it is doable but a little tricky so it doesn't belong in a patch with a bunch of boring and safe conversions.
Eric
Thanks for elaborating on that. Makes sense to wait.
-serge
Re: [PATCH 16/43] userns: Simplify the user_namespace by making userns->creator a kuid.
In reply to Serge E. HallynQuoted 100 lines · Serge E. Hallyn
Quoted 99 lines · Eric W. Biederman
Quoted 96 lines · Serge E. Hallyn
Quoted 89 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
- Transform
userns->creatorfrom auser_structreference to a simplekuid_t,kgid_tpair.In
cap_capablethis allows the check to see if we are the creator of a namespace to become the classic suser style euid permission check.This allows us to remove the need for a struct cred in the mapping functions and still be able to dispaly the user namespace creators uid and gid as 0.
- Remove the now unnecessary
delayed_workinfree_user_ns.All that is left for
free_user_nsto do is to callkmem_cache_freeandput_user_ns. Those functions can be called in any context so call them directly fromfree_user_nsremoving the need for delayed work.Signed-off-by Eric W. Biederman <[email protected]>--- include/linux/user_namespace.h | 4 ++-- kernel/user.c | 7 ++++--- kernel/user_namespace.c | 39 ++++++++++++++++++--------------------- security/commoncap.c | 5 +++-- 4 files changed, 27 insertions(+), 28 deletions(-)include/linux/user_namespace.h +2
-2@@ -9,8 +9,8 @@struct user_namespace {struct kref kref;struct user_namespace *parent; -struct user_struct *creator; -struct work_struct destroyer; +kuid_t owner; +kgid_t group; };extern struct user_namespace init_user_ns;kernel/user.c +4
-3@@ -25,7 +25,8 @@ struct user_namespace init_user_ns = { .kref = { .refcount = ATOMIC_INIT(3), }, - .creator = &root_user, + .owner = GLOBAL_ROOT_UID, + .group = GLOBAL_ROOT_GID, };EXPORT_SYMBOL_GPL (init_user_ns);@@ -54,9 +55,9 @@ struct hlist_head uidhash_table[UIDHASH_SZ];*/ static DEFINE_SPINLOCK (uidhash_lock); -/* root_user.__count is 2, 1 for init task cred, 1 for init_user_ns->user_ns */ +/* root_user.__count is 1, for init task cred */ struct user_struct root_user = { - .__count =ATOMIC_INIT (2 ), + .__count =ATOMIC_INIT (1 ), .processes =ATOMIC_INIT (1 ), .files =ATOMIC_INIT (0 ), .sigpending =ATOMIC_INIT (0 ),kernel/user_namespace.c +10
-0@@ -27,6 +27,16 @@ int create_user_ns(struct cred *new) {struct user_namespace *ns, *parent_ns = new->user_ns;struct user_struct *root_user; +kuid_t owner =make_kuid (new->user_ns, new->euid); +kgid_t group =make_kgid (new->user_ns, new->egid); + +/* The creator needs a mapping in the parent user namespace +* or else we won't be able to reasonably tell userspace who +* created a user_namespace. +*/ +if (!kuid_has_mapping (parent_ns, owner) || + !kgid_has_mapping (parent_ns, group)) +return -EPERM ; ns =kmem_cache_alloc (user_ns_cachep,GFP_KERNEL );if (!ns)kernel/user_namespace.c int create_user_ns(struct cred *new) · line 55
Quoted 3 lines
kernel/user_namespace.c +0
-0@@ -43,7 +53,9 @@ int create_user_ns(struct cred *new)/* set the new root user in the credentials under preparation */ ns->parent = parent_ns;I think in the past the creator cred pinned the
ns->parent. Do you now need to explicitly pinns->parent(and release it infree_user_ns())?
Quoted 3 lines
Quoted 3 lines
Yes we do have to explicitly reference count the parent namespace. But that happened in the patch 7:
"userns: Add an explicit reference to the parent user namespace"
Make that patch 8 not patch 7:
"userns: Add an explicit reference to the parent user namespace" Perhaps the patch number reference pointed you to look at the wrong code.
Quoted 4 lines
Perhaps that suffices, but I'm not convinced. The struct cred is pinning it's own ns, but if t1 does
clone(CLONE_NEWUSER)to produce t2, which does the same to procduce t3, and then t2 exits, I'm not seeing what will pin t2's userns.
t3's userns hold's a reference to the departed t2's userns. t2's userns hold's a reference to t1's userns.
free_user_ns does put that userns reference.
It is all there and explict. Usernamespaces refer directly to each other. That was all needed to get struct user out of the usernamespace game.
Eric
Re: [PATCH 16/43] userns: Simplify the user_namespace by making userns->creator a kuid.
Quoted 102 lines · Eric W. Biederman
Quoted 100 lines · Serge E. Hallyn
Quoted 99 lines · Eric W. Biederman
Quoted 96 lines · Serge E. Hallyn
Quoted 89 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
- Transform
userns->creatorfrom auser_structreference to a simplekuid_t,kgid_tpair.In
cap_capablethis allows the check to see if we are the creator of a namespace to become the classic suser style euid permission check.This allows us to remove the need for a struct cred in the mapping functions and still be able to dispaly the user namespace creators uid and gid as 0.
- Remove the now unnecessary
delayed_workinfree_user_ns.All that is left for
free_user_nsto do is to callkmem_cache_freeandput_user_ns. Those functions can be called in any context so call them directly fromfree_user_nsremoving the need for delayed work.Signed-off-by Eric W. Biederman <[email protected]>--- include/linux/user_namespace.h | 4 ++-- kernel/user.c | 7 ++++--- kernel/user_namespace.c | 39 ++++++++++++++++++--------------------- security/commoncap.c | 5 +++-- 4 files changed, 27 insertions(+), 28 deletions(-)include/linux/user_namespace.h +2
-2@@ -9,8 +9,8 @@struct user_namespace {struct kref kref;struct user_namespace *parent; -struct user_struct *creator; -struct work_struct destroyer; +kuid_t owner; +kgid_t group; };extern struct user_namespace init_user_ns;kernel/user.c +4
-3@@ -25,7 +25,8 @@ struct user_namespace init_user_ns = { .kref = { .refcount = ATOMIC_INIT(3), }, - .creator = &root_user, + .owner = GLOBAL_ROOT_UID, + .group = GLOBAL_ROOT_GID, };EXPORT_SYMBOL_GPL (init_user_ns);@@ -54,9 +55,9 @@ struct hlist_head uidhash_table[UIDHASH_SZ];*/ static DEFINE_SPINLOCK (uidhash_lock); -/* root_user.__count is 2, 1 for init task cred, 1 for init_user_ns->user_ns */ +/* root_user.__count is 1, for init task cred */ struct user_struct root_user = { - .__count =ATOMIC_INIT (2 ), + .__count =ATOMIC_INIT (1 ), .processes =ATOMIC_INIT (1 ), .files =ATOMIC_INIT (0 ), .sigpending =ATOMIC_INIT (0 ),kernel/user_namespace.c +10
-0@@ -27,6 +27,16 @@ int create_user_ns(struct cred *new) {struct user_namespace *ns, *parent_ns = new->user_ns;struct user_struct *root_user; +kuid_t owner =make_kuid (new->user_ns, new->euid); +kgid_t group =make_kgid (new->user_ns, new->egid); + +/* The creator needs a mapping in the parent user namespace +* or else we won't be able to reasonably tell userspace who +* created a user_namespace. +*/ +if (!kuid_has_mapping (parent_ns, owner) || + !kgid_has_mapping (parent_ns, group)) +return -EPERM ; ns =kmem_cache_alloc (user_ns_cachep,GFP_KERNEL );if (!ns)kernel/user_namespace.c int create_user_ns(struct cred *new) · line 55
Quoted 3 lines
kernel/user_namespace.c +0
-0@@ -43,7 +53,9 @@ int create_user_ns(struct cred *new)/* set the new root user in the credentials under preparation */ ns->parent = parent_ns;I think in the past the creator cred pinned the
ns->parent. Do you now need to explicitly pinns->parent(and release it infree_user_ns())?
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Yes we do have to explicitly reference count the parent namespace. But that happened in the patch 7:
"userns: Add an explicit reference to the parent user namespace"Make that patch 8 not patch 7:
"userns: Add an explicit reference to the parent user namespace" Perhaps the patch number reference pointed you to look at the wrong code.
D'oh, yup. That explains it better.
And so parent_userns keeps the refcount from the cred 'new' after new->ns = ns; That works, thanks.
Quoted 11 lines
Quoted 4 lines
Perhaps that suffices, but I'm not convinced. The struct cred is pinning it's own ns, but if t1 does
clone(CLONE_NEWUSER)to produce t2, which does the same to procduce t3, and then t2 exits, I'm not seeing what will pin t2's userns.t3's userns hold's a reference to the departed t2's userns. t2's userns hold's a reference to t1's userns.
free_user_nsdoes put that userns reference.It is all there and explict. Usernamespaces refer directly to each
Actually can we make it just one tinge more explicit, and put a comment above the 'new->user_ns = ns'? There's currently the comment
/* Leave the reference to our user_ns with the new cred */
But that's about the initial refcount on the new ns. Perhaps change that to:
/*
* Leave the reference to our new user_ns with the new cred,
* and leave the reference on the old ns to pin new->parent_ns */
Quoted 4 lines
other. That was all needed to get struct user out of the usernamespace game.
Eric
Thanks, Eric. So then
which, given the other nits are addressed, should cover the whole set with my acks.
thanks,
-serge
Serge E. Hallyn
maintainerRe: [PATCH 27/43] userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs
In reply to Eric W. BiedermanQuoted 27 lines · Eric W. Biederman
Quoted 15 lines · Serge E. Hallyn
Quoted 13 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Signed-off-by Eric W. Biederman <[email protected]>--- fs/attr.c | 8 ++++---- fs/exec.c | 10 +++++----- fs/fcntl.c | 6 +++--- fs/ioprio.c | 4 ++-- fs/locks.c | 2 +- fs/namei.c | 8 ++++---- include/linux/quotaops.h | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-)Quoted 9 lines
fs/exec.c void do_coredump(long signr, int exit_code, struct pt_regs *regs) · line 2123
Quoted 6 lines
fs/exec.c +1
-1@@ -2120,7 +2120,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)if (__get_dumpable (cprm.mm_flags) ==2 ) {/* Setuid core dump mode */ flag =O_EXCL ;/* Stop rewrite attacks */ - cred->fsuid =0 ;/* Dump root private */ + cred->fsuid =GLOBAL_ROOT_UID ;/* Dump root private */ Sorry, one more - can this be the per-ns root uid? The coredumps should be ok to belong to privileged users in the namespace right?
Quoted 7 lines
I'm not certain it was clear when you were looking at this that this is about dumping core from suid applications, not normal applications.
Looking at the code in commoncap and
commit_credsit looks like it is a
bug that we don't callset_dumpable(new, suid_dumpable)in common cap when we use file capabilities. I might be wrong but I think we escape
We do, check kernel/cred.c:commit_creds(). So long as the new permitted set is not a subset of the old one.
Tested it to make absolutely sure. When I add file capabilities to a program that otherwise dumps core (int *x = 0; *x = 0;), core dumps are no longer generated.
-serge
Re: [PATCH 27/43] userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs
Quoted 36 lines · Serge E. Hallyn
Quoted 27 lines · Eric W. Biederman
Quoted 15 lines · Serge E. Hallyn
Quoted 13 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Signed-off-by Eric W. Biederman <[email protected]>--- fs/attr.c | 8 ++++---- fs/exec.c | 10 +++++----- fs/fcntl.c | 6 +++--- fs/ioprio.c | 4 ++-- fs/locks.c | 2 +- fs/namei.c | 8 ++++---- include/linux/quotaops.h | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-)Quoted 9 lines
fs/exec.c void do_coredump(long signr, int exit_code, struct pt_regs *regs) · line 2123
Quoted 6 lines
fs/exec.c +1
-1@@ -2120,7 +2120,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)if (__get_dumpable (cprm.mm_flags) ==2 ) {/* Setuid core dump mode */ flag =O_EXCL ;/* Stop rewrite attacks */ - cred->fsuid =0 ;/* Dump root private */ + cred->fsuid =GLOBAL_ROOT_UID ;/* Dump root private */ Sorry, one more - can this be the per-ns root uid? The coredumps should be ok to belong to privileged users in the namespace right?
Quoted 7 lines
I'm not certain it was clear when you were looking at this that this is about dumping core from suid applications, not normal applications.
Looking at the code in commoncap and
commit_credsit looks like it is a
bug that we don't callset_dumpable(new, suid_dumpable)in common cap when we use file capabilities. I might be wrong but I think we escape
Quoted 6 lines
We do, check kernel/cred.c:commit_creds(). So long as the new permitted set is not a subset of the old one.
Tested it to make absolutely sure. When I add file capabilities to a program that otherwise dumps core (int *x = 0; *x = 0;), core dumps are no longer generated.
Thanks for testing. Just reading through I was not certain if we had the change in creds that commit_creds needed to trigger the set_dumpable logic.
Eric
Re: [PATCH 16/43] userns: Simplify the user_namespace by making userns->creator a kuid.
In reply to Serge E. HallynQuoted 131 lines · Serge E. Hallyn
Quoted 102 lines · Eric W. Biederman
Quoted 100 lines · Serge E. Hallyn
Quoted 99 lines · Eric W. Biederman
Quoted 96 lines · Serge E. Hallyn
Quoted 89 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
- Transform
userns->creatorfrom auser_structreference to a simplekuid_t,kgid_tpair.In
cap_capablethis allows the check to see if we are the creator of a namespace to become the classic suser style euid permission check.This allows us to remove the need for a struct cred in the mapping functions and still be able to dispaly the user namespace creators uid and gid as 0.
- Remove the now unnecessary
delayed_workinfree_user_ns.All that is left for
free_user_nsto do is to callkmem_cache_freeandput_user_ns. Those functions can be called in any context so call them directly fromfree_user_nsremoving the need for delayed work.Signed-off-by Eric W. Biederman <[email protected]>--- include/linux/user_namespace.h | 4 ++-- kernel/user.c | 7 ++++--- kernel/user_namespace.c | 39 ++++++++++++++++++--------------------- security/commoncap.c | 5 +++-- 4 files changed, 27 insertions(+), 28 deletions(-)include/linux/user_namespace.h +2
-2@@ -9,8 +9,8 @@struct user_namespace {struct kref kref;struct user_namespace *parent; -struct user_struct *creator; -struct work_struct destroyer; +kuid_t owner; +kgid_t group; };extern struct user_namespace init_user_ns;kernel/user.c +4
-3@@ -25,7 +25,8 @@ struct user_namespace init_user_ns = { .kref = { .refcount = ATOMIC_INIT(3), }, - .creator = &root_user, + .owner = GLOBAL_ROOT_UID, + .group = GLOBAL_ROOT_GID, };EXPORT_SYMBOL_GPL (init_user_ns);@@ -54,9 +55,9 @@ struct hlist_head uidhash_table[UIDHASH_SZ];*/ static DEFINE_SPINLOCK (uidhash_lock); -/* root_user.__count is 2, 1 for init task cred, 1 for init_user_ns->user_ns */ +/* root_user.__count is 1, for init task cred */ struct user_struct root_user = { - .__count =ATOMIC_INIT (2 ), + .__count =ATOMIC_INIT (1 ), .processes =ATOMIC_INIT (1 ), .files =ATOMIC_INIT (0 ), .sigpending =ATOMIC_INIT (0 ),kernel/user_namespace.c +10
-0@@ -27,6 +27,16 @@ int create_user_ns(struct cred *new) {struct user_namespace *ns, *parent_ns = new->user_ns;struct user_struct *root_user; +kuid_t owner =make_kuid (new->user_ns, new->euid); +kgid_t group =make_kgid (new->user_ns, new->egid); + +/* The creator needs a mapping in the parent user namespace +* or else we won't be able to reasonably tell userspace who +* created a user_namespace. +*/ +if (!kuid_has_mapping (parent_ns, owner) || + !kgid_has_mapping (parent_ns, group)) +return -EPERM ; ns =kmem_cache_alloc (user_ns_cachep,GFP_KERNEL );if (!ns)kernel/user_namespace.c int create_user_ns(struct cred *new) · line 55
Quoted 3 lines
kernel/user_namespace.c +0
-0@@ -43,7 +53,9 @@ int create_user_ns(struct cred *new)/* set the new root user in the credentials under preparation */ ns->parent = parent_ns;I think in the past the creator cred pinned the
ns->parent. Do you now need to explicitly pinns->parent(and release it infree_user_ns())?Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Yes we do have to explicitly reference count the parent namespace. But that happened in the patch 7:
"userns: Add an explicit reference to the parent user namespace"Make that patch 8 not patch 7:
"userns: Add an explicit reference to the parent user namespace" Perhaps the patch number reference pointed you to look at the wrong code.D'oh, yup. That explains it better.
And so
parent_usernskeeps the refcount from the cred 'new' afternew->ns= ns; That works, thanks.Quoted 11 lines
Quoted 4 lines
Perhaps that suffices, but I'm not convinced. The struct cred is pinning it's own ns, but if t1 does
clone(CLONE_NEWUSER)to produce t2, which does the same to procduce t3, and then t2 exits, I'm not seeing what will pin t2's userns.t3's userns hold's a reference to the departed t2's userns. t2's userns hold's a reference to t1's userns.
free_user_nsdoes put that userns reference.It is all there and explict. Usernamespaces refer directly to each
Actually can we make it just one tinge more explicit, and put a comment above the '
new->user_ns= ns'? There's currently the comment
Quoted 8 lines
/* Leave the reference to our user_ns with the new cred */But that's about the initial refcount on the new ns. Perhaps change that to:
/*
* Leave the reference to our newuser_nswith the new cred,
* and leave the reference on the old ns to pinnew->parent_ns*/
I have added the following comment. Hopefully that makes it clearer. */
/* Leave the new->user_ns reference with the new user namespace. */
Quoted 4 lines
Quoted 4 lines
other. That was all needed to get struct user out of the usernamespace game.
Quoted 8 lines
Quoted 1 line
Eric
Thanks, Eric. So then
Acked-by Serge Hallyn <[email protected]>which, given the other nits are addressed, should cover the whole set with my acks.
Hmm. I don't have a record of you looking at my patch 23.
"userns: Convert setting and getting uid and gid system calls to use kuid and kgid"
Eric
Re: [PATCH 16/43] userns: Simplify the user_namespace by making userns->creator a kuid.
In reply to a message not in the archiveQuoted 131 lines · Serge E. Hallyn
Quoted 102 lines · Eric W. Biederman
Quoted 100 lines · Serge E. Hallyn
Quoted 99 lines · Eric W. Biederman
Quoted 96 lines · Serge E. Hallyn
Quoted 89 lines · Eric W. Beiderman
From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
- Transform
userns->creatorfrom auser_structreference to a simplekuid_t,kgid_tpair.In
cap_capablethis allows the check to see if we are the creator of a namespace to become the classic suser style euid permission check.This allows us to remove the need for a struct cred in the mapping functions and still be able to dispaly the user namespace creators uid and gid as 0.
- Remove the now unnecessary
delayed_workinfree_user_ns.All that is left for
free_user_nsto do is to callkmem_cache_freeandput_user_ns. Those functions can be called in any context so call them directly fromfree_user_nsremoving the need for delayed work.--- include/linux/user_namespace.h | 4 ++-- kernel/user.c | 7 ++++--- kernel/user_namespace.c | 39 ++++++++++++++++++--------------------- security/commoncap.c | 5 +++-- 4 files changed, 27 insertions(+), 28 deletions(-)include/linux/user_namespace.h +2
-2@@ -9,8 +9,8 @@struct user_namespace {struct kref kref;struct user_namespace *parent; -struct user_struct *creator; -struct work_struct destroyer; +kuid_t owner; +kgid_t group; };extern struct user_namespace init_user_ns;kernel/user.c +4
-3@@ -25,7 +25,8 @@ struct user_namespace init_user_ns = { .kref = { .refcount = ATOMIC_INIT(3), }, - .creator = &root_user, + .owner = GLOBAL_ROOT_UID, + .group = GLOBAL_ROOT_GID, };EXPORT_SYMBOL_GPL (init_user_ns);@@ -54,9 +55,9 @@ struct hlist_head uidhash_table[UIDHASH_SZ];*/ static DEFINE_SPINLOCK (uidhash_lock); -/* root_user.__count is 2, 1 for init task cred, 1 for init_user_ns->user_ns */ +/* root_user.__count is 1, for init task cred */ struct user_struct root_user = { - .__count =ATOMIC_INIT (2 ), + .__count =ATOMIC_INIT (1 ), .processes =ATOMIC_INIT (1 ), .files =ATOMIC_INIT (0 ), .sigpending =ATOMIC_INIT (0 ),kernel/user_namespace.c +10
-0@@ -27,6 +27,16 @@ int create_user_ns(struct cred *new) {struct user_namespace *ns, *parent_ns = new->user_ns;struct user_struct *root_user; +kuid_t owner =make_kuid (new->user_ns, new->euid); +kgid_t group =make_kgid (new->user_ns, new->egid); + +/* The creator needs a mapping in the parent user namespace +* or else we won't be able to reasonably tell userspace who +* created a user_namespace. +*/ +if (!kuid_has_mapping (parent_ns, owner) || + !kgid_has_mapping (parent_ns, group)) +return -EPERM ; ns =kmem_cache_alloc (user_ns_cachep,GFP_KERNEL );if (!ns)kernel/user_namespace.c int create_user_ns(struct cred *new) · line 55
Quoted 3 lines
kernel/user_namespace.c +0
-0@@ -43,7 +53,9 @@ int create_user_ns(struct cred *new)/* set the new root user in the credentials under preparation */ ns->parent = parent_ns;I think in the past the creator cred pinned the
ns->parent. Do you now need to explicitly pinns->parent(and release it infree_user_ns())?Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Yes we do have to explicitly reference count the parent namespace. But that happened in the patch 7:
"userns: Add an explicit reference to the parent user namespace"Make that patch 8 not patch 7:
"userns: Add an explicit reference to the parent user namespace" Perhaps the patch number reference pointed you to look at the wrong code.D'oh, yup. That explains it better.
And so
parent_usernskeeps the refcount from the cred 'new' afternew->ns= ns; That works, thanks.Quoted 11 lines
Quoted 4 lines
Perhaps that suffices, but I'm not convinced. The struct cred is pinning it's own ns, but if t1 does
clone(CLONE_NEWUSER)to produce t2, which does the same to procduce t3, and then t2 exits, I'm not seeing what will pin t2's userns.t3's userns hold's a reference to the departed t2's userns. t2's userns hold's a reference to t1's userns.
free_user_nsdoes put that userns reference.It is all there and explict. Usernamespaces refer directly to each
Actually can we make it just one tinge more explicit, and put a comment above the '
new->user_ns= ns'? There's currently the comment
Quoted 8 lines
/* Leave the reference to our user_ns with the new cred */But that's about the initial refcount on the new ns. Perhaps change that to:
/*
* Leave the reference to our newuser_nswith the new cred,
* and leave the reference on the old ns to pinnew->parent_ns*/
I have added the following comment. Hopefully that makes it clearer. */
/* Leave the new->user_ns reference with the new user namespace. */
Quoted 4 lines
Quoted 4 lines
other. That was all needed to get struct user out of the usernamespace game.
Quoted 8 lines
Quoted 1 line
Eric
Thanks, Eric. So then
Acked-by Serge Hallyn <[email protected]>which, given the other nits are addressed, should cover the whole set with my acks.
Hmm. I don't have a record of you looking at my patch 23.
"userns: Convert setting and getting uid and gid system calls to use kuid and kgid"
Eric
Re: [PATCH 23/43] userns: Convert setting and getting uid and gid system calls to use kuid and kgid
In reply to Eric W. BeidermanQuoted 7 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
Convert setregid, setgid, setreuid, setuid, setresuid, getresuid, setresgid, getresgid, setfsuid, setfsgid, getuid, geteuid, getgid, getegid,
waitpid, waitid, wait4.
Quoted 5 lines
Convert userspace uids and gids into kuids and kgids before being placed on struct cred. Convert struct cred kuids and kgids into userspace uids and gids when returning them.
Signed-off-by Eric W. Biederman <[email protected]>
Quoted 586 lines
--- kernel/exit.c | 6 +- kernel/sys.c | 216 ++++++++++++++++++++++++++++++++++++++----------------- kernel/timer.c | 8 +- kernel/uid16.c | 34 ++++++--- 4 files changed, 178 insertions(+), 86 deletions(-)kernel/exit.c +3
-3@@ -1214,7 +1214,7 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)unsigned long state;int retval, status, traced;pid_t pid =task_pid_vnr (p); -uid_t uid =__task_cred (p)->uid; +uid_t uid =from_kuid_munged (current_user_ns (),__task_cred (p)->uid);struct siginfo __user *infop;if (!likely (wo->wo_flags &WEXITED ))@@ -1427,7 +1427,7 @@ static int wait_task_stopped(struct wait_opts *wo,if (!unlikely (wo->wo_flags &WNOWAIT )) *p_code =0 ; - uid =task_uid (p); + uid =from_kuid_munged (current_user_ns (),__task_cred (p)->uid); unlock_sig:spin_unlock_irq (&p->sighand->siglock);if (!exit_code)@@ -1500,7 +1500,7 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p) }if (!unlikely (wo->wo_flags &WNOWAIT )) p->signal->flags &= ~SIGNAL_STOP_CONTINUED ; - uid =task_uid (p); + uid =from_kuid_munged (current_user_ns (),__task_cred (p)->uid);spin_unlock_irq (&p->sighand->siglock); pid =task_pid_vnr (p);kernel/sys.c +149
-67@@ -555,9 +555,19 @@ void ctrl_alt_del(void)*/ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid) { +struct user_namespace *ns =current_user_ns ();const struct cred *old;struct cred *new;int retval; +kgid_t krgid, kegid; + + krgid =make_kgid (ns, rgid); + kegid =make_kgid (ns, egid); + +if ((rgid != (gid_t) -1 ) && !gid_valid (krgid)) +return -EINVAL ; +if ((egid != (gid_t) -1 ) && !gid_valid (kegid)) +return -EINVAL ; new =prepare_creds ();if (!new)@@ -566,25 +576,25 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid) retval = -EPERM ;if (rgid != (gid_t) -1 ) { -if (old->gid == rgid || - old->egid == rgid || +if (gid_eq (old->gid, krgid) || +gid_eq (old->egid, krgid) ||nsown_capable (CAP_SETGID )) - new->gid = rgid; + new->gid = krgid;else goto error; }if (egid != (gid_t) -1 ) { -if (old->gid == egid || - old->egid == egid || - old->sgid == egid || +if (gid_eq (old->gid, kegid) || +gid_eq (old->egid, kegid) || +gid_eq (old->sgid, kegid) ||nsown_capable (CAP_SETGID )) - new->egid = egid; + new->egid = kegid;else goto error; }if (rgid != (gid_t) -1 || - (egid != (gid_t) -1 && egid != old->gid)) + (egid != (gid_t) -1 && !gid_eq (kegid, old->gid))) new->sgid = new->egid; new->fsgid = new->egid;@@ -602,9 +612,15 @@ error:*/ SYSCALL_DEFINE1(setgid, gid_t, gid) { +struct user_namespace *ns =current_user_ns ();const struct cred *old;struct cred *new;int retval; +kgid_t kgid; + + kgid =make_kgid (ns, gid); +if (!gid_valid (kgid)) +return -EINVAL ; new =prepare_creds ();if (!new)@@ -613,9 +629,9 @@ SYSCALL_DEFINE1(setgid, gid_t, gid) retval = -EPERM ;if (nsown_capable (CAP_SETGID )) - new->gid = new->egid = new->sgid = new->fsgid = gid; -else if (gid == old->gid || gid == old->sgid) - new->egid = new->fsgid = gid; + new->gid = new->egid = new->sgid = new->fsgid = kgid; +else if (gid_eq (kgid, old->gid) ||gid_eq (kgid, old->sgid)) + new->egid = new->fsgid = kgid;else goto error;@@ -672,9 +688,19 @@ static int set_user(struct cred *new)*/ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid) { +struct user_namespace *ns =current_user_ns ();const struct cred *old;struct cred *new;int retval; +kuid_t kruid, keuid; + + kruid =make_kuid (ns, ruid); + keuid =make_kuid (ns, euid); + +if ((ruid != (uid_t) -1 ) && !uid_valid (kruid)) +return -EINVAL ; +if ((euid != (uid_t) -1 ) && !uid_valid (keuid)) +return -EINVAL ; new =prepare_creds ();if (!new)@@ -683,29 +709,29 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid) retval = -EPERM ;if (ruid != (uid_t) -1 ) { - new->uid = ruid; -if (old->uid != ruid && - old->euid != ruid && + new->uid = kruid; +if (!uid_eq (old->uid, kruid) && + !uid_eq (old->euid, kruid) && !nsown_capable (CAP_SETUID )) goto error; }if (euid != (uid_t) -1 ) { - new->euid = euid; -if (old->uid != euid && - old->euid != euid && - old->suid != euid && + new->euid = keuid; +if (!uid_eq (old->uid, keuid) && + !uid_eq (old->euid, keuid) && + !uid_eq (old->suid, keuid) && !nsown_capable (CAP_SETUID )) goto error; } -if (new->uid != old->uid) { +if (!uid_eq (new->uid, old->uid)) { retval =set_user (new);if (retval <0 ) goto error; }if (ruid != (uid_t) -1 || - (euid != (uid_t) -1 && euid != old->uid)) + (euid != (uid_t) -1 && !uid_eq (keuid, old->uid))) new->suid = new->euid; new->fsuid = new->euid;@@ -733,9 +759,15 @@ error:*/ SYSCALL_DEFINE1(setuid, uid_t, uid) { +struct user_namespace *ns =current_user_ns ();const struct cred *old;struct cred *new;int retval; +kuid_t kuid; + + kuid =make_kuid (ns, uid); +if (!uid_valid (kuid)) +return -EINVAL ; new =prepare_creds ();if (!new)@@ -744,17 +776,17 @@ SYSCALL_DEFINE1(setuid, uid_t, uid) retval = -EPERM ;if (nsown_capable (CAP_SETUID )) { - new->suid = new->uid = uid; -if (uid != old->uid) { + new->suid = new->uid = kuid; +if (!uid_eq (kuid, old->uid)) { retval =set_user (new);if (retval <0 ) goto error; } - }else if (uid != old->uid && uid != new->suid) { + }else if (!uid_eq (kuid, old->uid) && !uid_eq (kuid, new->suid)) { goto error; } - new->fsuid = new->euid = uid; + new->fsuid = new->euid = kuid; retval =security_task_fix_setuid (new, old,LSM_SETID_ID );if (retval <0 )@@ -774,9 +806,24 @@ error:*/ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid) { +struct user_namespace *ns =current_user_ns ();const struct cred *old;struct cred *new;int retval; +kuid_t kruid, keuid, ksuid; + + kruid =make_kuid (ns, ruid); + keuid =make_kuid (ns, euid); + ksuid =make_kuid (ns, suid); + +if ((ruid != (uid_t) -1 ) && !uid_valid (kruid)) +return -EINVAL ; + +if ((euid != (uid_t) -1 ) && !uid_valid (keuid)) +return -EINVAL ; + +if ((suid != (uid_t) -1 ) && !uid_valid (ksuid)) +return -EINVAL ; new =prepare_creds ();if (!new)@@ -786,29 +833,29 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid) retval = -EPERM ;if (!nsown_capable (CAP_SETUID )) { -if (ruid != (uid_t) -1 && ruid != old->uid && - ruid != old->euid && ruid != old->suid) +if (ruid != (uid_t) -1 && !uid_eq (kruid, old->uid) && + !uid_eq (kruid, old->euid) && !uid_eq (kruid, old->suid)) goto error; -if (euid != (uid_t) -1 && euid != old->uid && - euid != old->euid && euid != old->suid) +if (euid != (uid_t) -1 && !uid_eq (keuid, old->uid) && + !uid_eq (keuid, old->euid) && !uid_eq (keuid, old->suid)) goto error; -if (suid != (uid_t) -1 && suid != old->uid && - suid != old->euid && suid != old->suid) +if (suid != (uid_t) -1 && !uid_eq (ksuid, old->uid) && + !uid_eq (ksuid, old->euid) && !uid_eq (ksuid, old->suid)) goto error; }if (ruid != (uid_t) -1 ) { - new->uid = ruid; -if (ruid != old->uid) { + new->uid = kruid; +if (!uid_eq (kruid, old->uid)) { retval =set_user (new);if (retval <0 ) goto error; } }if (euid != (uid_t) -1 ) - new->euid = euid; + new->euid = keuid;if (suid != (uid_t) -1 ) - new->suid = suid; + new->suid = ksuid; new->fsuid = new->euid; retval =security_task_fix_setuid (new, old,LSM_SETID_RES );@@ -822,14 +869,19 @@ error:return retval; } -SYSCALL_DEFINE3(getresuid, uid_t __user *, ruid, uid_t __user *, euid, uid_t __user *, suid) +SYSCALL_DEFINE3(getresuid, uid_t __user *, ruidp, uid_t __user *, euidp, uid_t __user *, suidp) {const struct cred *cred =current_cred ();int retval; +uid_t ruid, euid, suid; + + ruid =from_kuid_munged (cred->user_ns, cred->uid); + euid =from_kuid_munged (cred->user_ns, cred->euid); + suid =from_kuid_munged (cred->user_ns, cred->suid); -if (!(retval =put_user (cred->uid, ruid)) && - !(retval =put_user (cred->euid, euid))) - retval =put_user (cred->suid, suid); +if (!(retval =put_user (ruid, ruidp)) && + !(retval =put_user (euid, euidp))) + retval =put_user (suid, suidp);return retval; }@@ -839,9 +891,22 @@ SYSCALL_DEFINE3(getresuid, uid_t __user *, ruid, uid_t __user *, euid, uid_t __u*/ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid) { +struct user_namespace *ns =current_user_ns ();const struct cred *old;struct cred *new;int retval; +kgid_t krgid, kegid, ksgid; + + krgid =make_kgid (ns, rgid); + kegid =make_kgid (ns, egid); + ksgid =make_kgid (ns, sgid); + +if ((rgid != (gid_t) -1 ) && !gid_valid (krgid)) +return -EINVAL ; +if ((egid != (gid_t) -1 ) && !gid_valid (kegid)) +return -EINVAL ; +if ((sgid != (gid_t) -1 ) && !gid_valid (ksgid)) +return -EINVAL ; new =prepare_creds ();if (!new)@@ -850,23 +915,23 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid) retval = -EPERM ;if (!nsown_capable (CAP_SETGID )) { -if (rgid != (gid_t) -1 && rgid != old->gid && - rgid != old->egid && rgid != old->sgid) +if (rgid != (gid_t) -1 && !gid_eq (krgid, old->gid) && + !gid_eq (krgid, old->egid) && !gid_eq (krgid, old->sgid)) goto error; -if (egid != (gid_t) -1 && egid != old->gid && - egid != old->egid && egid != old->sgid) +if (egid != (gid_t) -1 && !gid_eq (kegid, old->gid) && + !gid_eq (kegid, old->egid) && !gid_eq (kegid, old->sgid)) goto error; -if (sgid != (gid_t) -1 && sgid != old->gid && - sgid != old->egid && sgid != old->sgid) +if (sgid != (gid_t) -1 && !gid_eq (ksgid, old->gid) && + !gid_eq (ksgid, old->egid) && !gid_eq (ksgid, old->sgid)) goto error; }if (rgid != (gid_t) -1 ) - new->gid = rgid; + new->gid = krgid;if (egid != (gid_t) -1 ) - new->egid = egid; + new->egid = kegid;if (sgid != (gid_t) -1 ) - new->sgid = sgid; + new->sgid = ksgid; new->fsgid = new->egid;return commit_creds (new);@@ -876,14 +941,19 @@ error:return retval; } -SYSCALL_DEFINE3(getresgid, gid_t __user *, rgid, gid_t __user *, egid, gid_t __user *, sgid) +SYSCALL_DEFINE3(getresgid, gid_t __user *, rgidp, gid_t __user *, egidp, gid_t __user *, sgidp) {const struct cred *cred =current_cred ();int retval; +gid_t rgid, egid, sgid; + + rgid =from_kgid_munged (cred->user_ns, cred->gid); + egid =from_kgid_munged (cred->user_ns, cred->egid); + sgid =from_kgid_munged (cred->user_ns, cred->sgid); -if (!(retval =put_user (cred->gid, rgid)) && - !(retval =put_user (cred->egid, egid))) - retval =put_user (cred->sgid, sgid); +if (!(retval =put_user (rgid, rgidp)) && + !(retval =put_user (egid, egidp))) + retval =put_user (sgid, sgidp);return retval; }@@ -900,18 +970,24 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)const struct cred *old;struct cred *new;uid_t old_fsuid; +kuid_t kuid; + + old =current_cred (); + old_fsuid =from_kuid_munged (old->user_ns, old->fsuid); + + kuid =make_kuid (old->user_ns, uid); +if (!uid_valid (kuid)) +return old_fsuid; new =prepare_creds ();if (!new) -return current_fsuid (); - old =current_cred (); - old_fsuid = old->fsuid; +return old_fsuid; -if (uid == old->uid || uid == old->euid || - uid == old->suid || uid == old->fsuid || +if (uid_eq (kuid, old->uid) ||uid_eq (kuid, old->euid) || +uid_eq (kuid, old->suid) ||uid_eq (kuid, old->fsuid) ||nsown_capable (CAP_SETUID )) { -if (uid != old_fsuid) { - new->fsuid = uid; +if (!uid_eq (kuid, old->fsuid)) { + new->fsuid = kuid;if (security_task_fix_setuid (new, old,LSM_SETID_FS ) ==0 ) goto change_okay; }@@ -933,18 +1009,24 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)const struct cred *old;struct cred *new;gid_t old_fsgid; +kgid_t kgid; + + old =current_cred (); + old_fsgid =from_kgid_munged (old->user_ns, old->fsgid); + + kgid =make_kgid (old->user_ns, gid); +if (!gid_valid (kgid)) +return old_fsgid; new =prepare_creds ();if (!new) -return current_fsgid (); - old =current_cred (); - old_fsgid = old->fsgid; +return old_fsgid; -if (gid == old->gid || gid == old->egid || - gid == old->sgid || gid == old->fsgid || +if (gid_eq (kgid, old->gid) ||gid_eq (kgid, old->egid) || +gid_eq (kgid, old->sgid) ||gid_eq (kgid, old->fsgid) ||nsown_capable (CAP_SETGID )) { -if (gid != old_fsgid) { - new->fsgid = gid; +if (!gid_eq (kgid, old->fsgid)) { + new->fsgid = kgid; goto change_okay; } }@@ -1503,10 +1585,10 @@ static int check_prlimit_permission(struct task_struct *task)if (cred->user_ns == tcred->user_ns && (cred->uid == tcred->euid && cred->uid == tcred->suid && - cred->uid == tcred->uid && + cred->uid == tcred->uid && cred->gid == tcred->egid && cred->gid == tcred->sgid && - cred->gid == tcred->gid)) + cred->gid == tcred->gid))return 0 ;if (ns_capable (tcred->user_ns,CAP_SYS_RESOURCE ))return 0 ;kernel/timer.c +4
-4@@ -1427,25 +1427,25 @@ SYSCALL_DEFINE0(getppid)SYSCALL_DEFINE0 (getuid) {/* Only we change this so SMP safe */ -return current_uid (); +return from_kuid_munged (current_user_ns (),current_uid ()); }SYSCALL_DEFINE0 (geteuid) {/* Only we change this so SMP safe */ -return current_euid (); +return from_kuid_munged (current_user_ns (),current_euid ()); }SYSCALL_DEFINE0 (getgid) {/* Only we change this so SMP safe */ -return current_gid (); +return from_kgid_munged (current_user_ns (),current_gid ()); }SYSCALL_DEFINE0 (getegid) {/* Only we change this so SMP safe */ -return current_egid (); +return from_kgid_munged (current_user_ns (),current_egid ()); }#endif kernel/uid16.c +22
-12@@ -81,14 +81,19 @@ SYSCALL_DEFINE3(setresuid16, old_uid_t, ruid, old_uid_t, euid, old_uid_t, suid)return ret; } -SYSCALL_DEFINE3(getresuid16, old_uid_t __user *, ruid, old_uid_t __user *, euid, old_uid_t __user *, suid) +SYSCALL_DEFINE3(getresuid16, old_uid_t __user *, ruidp, old_uid_t __user *, euidp, old_uid_t __user *, suidp) {const struct cred *cred =current_cred ();int retval; +old_uid_t ruid, euid, suid; -if (!(retval =put_user (high2lowuid (cred->uid), ruid)) && - !(retval =put_user (high2lowuid (cred->euid), euid))) - retval =put_user (high2lowuid (cred->suid), suid); + ruid =high2lowuid (from_kuid_munged (cred->user_ns, cred->uid)); + euid =high2lowuid (from_kuid_munged (cred->user_ns, cred->euid)); + suid =high2lowuid (from_kuid_munged (cred->user_ns, cred->suid)); + +if (!(retval =put_user (ruid, ruidp)) && + !(retval =put_user (euid, euidp))) + retval =put_user (suid, suidp);return retval; }@@ -103,14 +108,19 @@ SYSCALL_DEFINE3(setresgid16, old_gid_t, rgid, old_gid_t, egid, old_gid_t, sgid) } -SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgid, old_gid_t __user *, egid, old_gid_t __user *, sgid) +SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgidp, old_gid_t __user *, egidp, old_gid_t __user *, sgidp) {const struct cred *cred =current_cred ();int retval; +old_gid_t rgid, egid, sgid; + + rgid =high2lowgid (from_kgid_munged (cred->user_ns, cred->gid)); + egid =high2lowgid (from_kgid_munged (cred->user_ns, cred->egid)); + sgid =high2lowgid (from_kgid_munged (cred->user_ns, cred->sgid)); -if (!(retval =put_user (high2lowgid (cred->gid), rgid)) && - !(retval =put_user (high2lowgid (cred->egid), egid))) - retval =put_user (high2lowgid (cred->sgid), sgid); +if (!(retval =put_user (rgid, rgidp)) && + !(retval =put_user (egid, egidp))) + retval =put_user (sgid, sgidp);return retval; }@@ -221,20 +231,20 @@ SYSCALL_DEFINE2(setgroups16, int, gidsetsize, old_gid_t __user *, grouplist)SYSCALL_DEFINE0 (getuid16) { -return high2lowuid (current_uid ()); +return high2lowuid (from_kuid_munged (current_user_ns (),current_uid ())); }SYSCALL_DEFINE0 (geteuid16) { -return high2lowuid (current_euid ()); +return high2lowuid (from_kuid_munged (current_user_ns (),current_euid ())); }SYSCALL_DEFINE0 (getgid16) { -return high2lowgid (current_gid ()); +return high2lowgid (from_kgid_munged (current_user_ns (),current_gid ())); }SYSCALL_DEFINE0 (getegid16) { -return high2lowgid (current_egid ()); +return high2lowgid (from_kgid_munged (current_user_ns (),current_egid ())); }Signature · 6 lines
1.7.2.5 _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
Serge E. Hallyn
maintainerRe: [PATCH 16/43] userns: Simplify the user_namespace by making userns->creator a kuid.
In reply to Eric W. BiedermanQuoted 137 lines · Eric W. Biederman
Quoted 135 lines · Serge E. Hallyn
Quoted 102 lines · Eric W. Biederman
Quoted 100 lines · Serge E. Hallyn
Quoted 99 lines · Eric W. Biederman
Quoted 96 lines · Serge E. Hallyn
Quoted 89 lines · Eric W. Beiderman
From: Eric W. Biederman <[email protected]>
- Transform
userns->creatorfrom auser_structreference to a simplekuid_t,kgid_tpair.In
cap_capablethis allows the check to see if we are the creator of a namespace to become the classic suser style euid permission check.This allows us to remove the need for a struct cred in the mapping functions and still be able to dispaly the user namespace creators uid and gid as 0.
- Remove the now unnecessary
delayed_workinfree_user_ns.All that is left for
free_user_nsto do is to callkmem_cache_freeandput_user_ns. Those functions can be called in any context so call them directly fromfree_user_nsremoving the need for delayed work.Signed-off-by Eric W. Biederman <[email protected]>--- include/linux/user_namespace.h | 4 ++-- kernel/user.c | 7 ++++--- kernel/user_namespace.c | 39 ++++++++++++++++++--------------------- security/commoncap.c | 5 +++-- 4 files changed, 27 insertions(+), 28 deletions(-)include/linux/user_namespace.h +2
-2@@ -9,8 +9,8 @@struct user_namespace {struct kref kref;struct user_namespace *parent; -struct user_struct *creator; -struct work_struct destroyer; +kuid_t owner; +kgid_t group; };extern struct user_namespace init_user_ns;kernel/user.c +4
-3@@ -25,7 +25,8 @@ struct user_namespace init_user_ns = { .kref = { .refcount = ATOMIC_INIT(3), }, - .creator = &root_user, + .owner = GLOBAL_ROOT_UID, + .group = GLOBAL_ROOT_GID, };EXPORT_SYMBOL_GPL (init_user_ns);@@ -54,9 +55,9 @@ struct hlist_head uidhash_table[UIDHASH_SZ];*/ static DEFINE_SPINLOCK (uidhash_lock); -/* root_user.__count is 2, 1 for init task cred, 1 for init_user_ns->user_ns */ +/* root_user.__count is 1, for init task cred */ struct user_struct root_user = { - .__count =ATOMIC_INIT (2 ), + .__count =ATOMIC_INIT (1 ), .processes =ATOMIC_INIT (1 ), .files =ATOMIC_INIT (0 ), .sigpending =ATOMIC_INIT (0 ),kernel/user_namespace.c +10
-0@@ -27,6 +27,16 @@ int create_user_ns(struct cred *new) {struct user_namespace *ns, *parent_ns = new->user_ns;struct user_struct *root_user; +kuid_t owner =make_kuid (new->user_ns, new->euid); +kgid_t group =make_kgid (new->user_ns, new->egid); + +/* The creator needs a mapping in the parent user namespace +* or else we won't be able to reasonably tell userspace who +* created a user_namespace. +*/ +if (!kuid_has_mapping (parent_ns, owner) || + !kgid_has_mapping (parent_ns, group)) +return -EPERM ; ns =kmem_cache_alloc (user_ns_cachep,GFP_KERNEL );if (!ns)kernel/user_namespace.c int create_user_ns(struct cred *new) · line 55
Quoted 3 lines
kernel/user_namespace.c +0
-0@@ -43,7 +53,9 @@ int create_user_ns(struct cred *new)/* set the new root user in the credentials under preparation */ ns->parent = parent_ns;I think in the past the creator cred pinned the
ns->parent. Do you now need to explicitly pinns->parent(and release it infree_user_ns())?Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Yes we do have to explicitly reference count the parent namespace. But that happened in the patch 7:
"userns: Add an explicit reference to the parent user namespace"Make that patch 8 not patch 7:
"userns: Add an explicit reference to the parent user namespace" Perhaps the patch number reference pointed you to look at the wrong code.D'oh, yup. That explains it better.
And so
parent_usernskeeps the refcount from the cred 'new' afternew->ns= ns; That works, thanks.Quoted 11 lines
Quoted 4 lines
Perhaps that suffices, but I'm not convinced. The struct cred is pinning it's own ns, but if t1 does
clone(CLONE_NEWUSER)to produce t2, which does the same to procduce t3, and then t2 exits, I'm not seeing what will pin t2's userns.t3's userns hold's a reference to the departed t2's userns. t2's userns hold's a reference to t1's userns.
free_user_nsdoes put that userns reference.It is all there and explict. Usernamespaces refer directly to each
Actually can we make it just one tinge more explicit, and put a comment above the '
new->user_ns= ns'? There's currently the comment/* Leave the reference to our user_ns with the new cred */But that's about the initial refcount on the new ns. Perhaps change that to:
Quoted 8 lines
Quoted 4 lines
/*
* Leave the reference to our newuser_nswith the new cred,
* and leave the reference on the old ns to pinnew->parent_ns*/I have added the following comment. Hopefully that makes it clearer. */
/* Leave the new->user_ns reference with the new user namespace. */
Great, thanks.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
other. That was all needed to get struct user out of the usernamespace game.
Eric
Thanks, Eric. So then
Quoted 7 lines
Quoted 4 lines
Acked-by Serge Hallyn <[email protected]>which, given the other nits are addressed, should cover the whole set with my acks.
Hmm. I don't have a record of you looking at my patch 23.
"userns: Convert setting and getting uid and gid system calls to use kuid and kgid"
I'd looked at it, but apparently never replied. Took another look to be sure, and replied now.
thanks,
-serge
Please include user-namespace.git in linux-next
In reply to Eric W. BiedermanIn linux-next please include git://pub/scm/linux/kernel/git/ebiederm/user-namespace.git for-next
This tree includes the fixed versions of the 43 patches I sent out for review a few weeks ago, plus an updated Kconfig options so the parts that won't build can't build can't be selected making allyesconfig and allnoconfig safe.
The discussion of this work was covered in lwn at:
http://lwn.net/Articles/491310
There are a bunch more trivial patches to go that still need to be reviewed but the core has been reviewed and tested left/right up/down and sideways and it looks like all of the bugs have fallen out.
Eric
Re: Please include user-namespace.git in linux-next
HI Eric,
Quoted 2 lines · On Fri, 11 May 2012 16:20:54 -0700 ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]…
In linux-next please include
git://pub/scm/linux/kernel/git/ebiederm/user-namespace.gitfor-next
I assume you left out "git.kernel.org/" :-)
Included from today.
Thanks for adding your subsystem tree as a participant of linux-next. As you may know, this is not a judgment of your code. The purpose of linux-next is for integration testing and to lower the impact of conflicts between subsystems in the next merge window.
You will need to ensure that the patches/commits in your tree/series have been:
* submitted under GPL v2 (or later) and include the Contributor's Signed-off-by,
* posted to the relevant mailing list,
* reviewed by you (or another maintainer of your subsystem tree),
* successfully unit tested, and
* destined for the current or next Linux merge window.
Basically, this should be just what you would send to Linus (or ask him to fetch). It is allowed to be rebased if you deem it necessary.
Signature · 15 lines
Cheers, Stephen Rothwell [email protected] Legal Stuff: By participating in linux-next, your subsystem tree contributions are public and will be included in the linux-next trees. You may be sent e-mail messages indicating errors or other issues when the patches/commits from your subsystem tree are merged and tested in linux-next. These messages may also be cross-posted to the linux-next mailing list, the linux-kernel mailing list, etc. The linux-next tree project and IBM (my employer) make no warranties regarding the linux-next project, the testing procedures, the results, the e-mails, etc. If you don't agree to these ground rules, let me know and I'll remove your tree from participation in linux-next.
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linuxfoundation.org/mailman/listinfo/containers
Re: Please include user-namespace.git in linux-next
In reply to Eric W. BiedermanI think something is wrong with commit e1c972b6 "userns: Add negative depends on entries to avoid building code that is userns unsafe".
With gcc 4.4.6 on CentOS 6.2, "make allnoconfig" where UIDGID_CONVERTED should become y is showing
Symbol: USER_NS [=n]
Type : boolean
Prompt: User namespace (EXPERIMENTAL)
Defined at init/Kconfig:880
Depends on: NAMESPACES [=y] && EXPERIMENTAL [=n] && UIDGID_CONVERTED [=n] Location:
-> General setup
-> Namespaces support (NAMESPACES [=y]) Selects: UIDGID_STRICT_TYPE_CHECKS [=n]
.
I think this commit meant "!FOO" rather than "FOO = n", othwewise there is no way for linux-next-20120518 to enable USER_NS.
----------------------------------------
PATCH: user_ns: Fix wrong dependency in UIDGID_CONVERTED.
"depends on FOO = n" should be "depends on !FOO".
----------
init/Kconfig +96 -96
@@ -917,110 +917,110 @@ config UIDGID_CONVERTED # List of kernel pieces that need user namespace work # Features - depends on SYSVIPC = n - depends on IMA = n - depends on EVM = n - depends on KEYS = n - depends on AUDIT = n - depends on AUDITSYSCALL = n - depends on TASKSTATS = n - depends on TRACING = n - depends on FS_POSIX_ACL = n - depends on QUOTA = n - depends on QUOTACTL = n - depends on DEBUG_CREDENTIALS = n - depends on BSD_PROCESS_ACCT = n - depends on DRM = n - depends on PROC_EVENTS = n + depends on !SYSVIPC + depends on !IMA + depends on !EVM + depends on !KEYS + depends on !AUDIT + depends on !AUDITSYSCALL + depends on !TASKSTATS + depends on !TRACING + depends on !FS_POSIX_ACL + depends on !QUOTA + depends on !QUOTACTL + depends on !DEBUG_CREDENTIALS + depends on !BSD_PROCESS_ACCT + depends on !DRM + depends on !PROC_EVENTS # Networking - depends on NET = n - depends on NET_9P = n - depends on IPX = n - depends on PHONET = n - depends on NET_CLS_FLOW = n - depends on NETFILTER_XT_MATCH_OWNER = n - depends on NETFILTER_XT_MATCH_RECENT = n - depends on NETFILTER_XT_TARGET_LOG = n - depends on NETFILTER_NETLINK_LOG = n - depends on INET = n - depends on IPV6 = n - depends on IP_SCTP = n - depends on AF_RXRPC = n - depends on LLC2 = n - depends on NET_KEY = n - depends on INET_DIAG = n - depends on DNS_RESOLVER = n - depends on AX25 = n - depends on ATALK = n + depends on !NET + depends on !NET_9P + depends on !IPX + depends on !PHONET + depends on !NET_CLS_FLOW + depends on !NETFILTER_XT_MATCH_OWNER + depends on !NETFILTER_XT_MATCH_RECENT + depends on !NETFILTER_XT_TARGET_LOG + depends on !NETFILTER_NETLINK_LOG + depends on !INET + depends on !IPV6 + depends on !IP_SCTP + depends on !AF_RXRPC + depends on !LLC2 + depends on !NET_KEY + depends on !INET_DIAG + depends on !DNS_RESOLVER + depends on !AX25 + depends on !ATALK # Filesystems - depends on USB_DEVICEFS = n - depends on USB_GADGETFS = n - depends on USB_FUNCTIONFS = n - depends on DEVTMPFS = n - depends on XENFS = n - - depends on 9P_FS = n - depends on ADFS_FS = n - depends on AFFS_FS = n - depends on AFS_FS = n - depends on AUTOFS4_FS = n - depends on BEFS_FS = n - depends on BFS_FS = n - depends on BTRFS_FS = n - depends on CEPH_FS = n - depends on CIFS = n - depends on CODA_FS = n - depends on CONFIGFS_FS = n - depends on CRAMFS = n - depends on DEBUG_FS = n - depends on ECRYPT_FS = n - depends on EFS_FS = n - depends on EXOFS_FS = n - depends on FAT_FS = n - depends on FUSE_FS = n - depends on GFS2_FS = n - depends on HFS_FS = n - depends on HFSPLUS_FS = n - depends on HPFS_FS = n - depends on HUGETLBFS = n - depends on ISO9660_FS = n - depends on JFFS2_FS = n - depends on JFS_FS = n - depends on LOGFS = n - depends on MINIX_FS = n - depends on NCP_FS = n - depends on NFSD = n - depends on NFS_FS = n - depends on NILFS2_FS = n - depends on NTFS_FS = n - depends on OCFS2_FS = n - depends on OMFS_FS = n - depends on QNX4FS_FS = n - depends on QNX6FS_FS = n - depends on REISERFS_FS = n - depends on SQUASHFS = n - depends on SYSV_FS = n - depends on UBIFS_FS = n - depends on UDF_FS = n - depends on UFS_FS = n - depends on VXFS_FS = n - depends on XFS_FS = n - - depends on !UML || HOSTFS = n + depends on !USB_DEVICEFS + depends on !USB_GADGETFS + depends on !USB_FUNCTIONFS + depends on !DEVTMPFS + depends on !XENFS + + depends on !9P_FS + depends on !ADFS_FS + depends on !AFFS_FS + depends on !AFS_FS + depends on !AUTOFS4_FS + depends on !BEFS_FS + depends on !BFS_FS + depends on !BTRFS_FS + depends on !CEPH_FS + depends on !CIFS + depends on !CODA_FS + depends on !CONFIGFS_FS + depends on !CRAMFS + depends on !DEBUG_FS + depends on !ECRYPT_FS + depends on !EFS_FS + depends on !EXOFS_FS + depends on !FAT_FS + depends on !FUSE_FS + depends on !GFS2_FS + depends on !HFS_FS + depends on !HFSPLUS_FS + depends on !HPFS_FS + depends on !HUGETLBFS + depends on !ISO9660_FS + depends on !JFFS2_FS + depends on !JFS_FS + depends on !LOGFS + depends on !MINIX_FS + depends on !NCP_FS + depends on !NFSD + depends on !NFS_FS + depends on !NILFS2_FS + depends on !NTFS_FS + depends on !OCFS2_FS + depends on !OMFS_FS + depends on !QNX4FS_FS + depends on !QNX6FS_FS + depends on !REISERFS_FS + depends on !SQUASHFS + depends on !SYSV_FS + depends on !UBIFS_FS + depends on !UDF_FS + depends on !UFS_FS + depends on !VXFS_FS + depends on !XFS_FS + + depends on !UML || !HOSTFS # The rare drivers that won't build - depends on AIRO = n - depends on AIRO_CS = n - depends on TUN = n - depends on INFINIBAND_QIB = n - depends on BLK_DEV_LOOP = n - depends on ANDROID_BINDER_IPC = n + depends on !AIRO + depends on !AIRO_CS + depends on !TUN + depends on !INFINIBAND_QIB + depends on !BLK_DEV_LOOP + depends on !ANDROID_BINDER_IPC # Security modules - depends on SECURITY_TOMOYO = n - depends on SECURITY_APPARMOR = n + depends on !SECURITY_TOMOYO + depends on !SECURITY_APPARMOR config UIDGID_STRICT_TYPE_CHECKS bool "Require conversions between uid/gids and their internal representation"
Re: Please include user-namespace.git in linux-next
Quoted 2 lines · Tetsuo Handa
I think something is wrong with commit
e1c972b6"userns: Add negative depends on entries to avoid building code that is userns unsafe".
My apologies for the delayed reply.
Quoted 11 lines
With gcc 4.4.6 on CentOS 6.2, "make allnoconfig" where
UIDGID_CONVERTEDshould become y is showingSymbol:
USER_NS[=n]
Type : boolean
Prompt: User namespace (EXPERIMENTAL)
Defined at init/Kconfig:880
Depends on: NAMESPACES [=y] && EXPERIMENTAL [=n] &&UIDGID_CONVERTED[=n] Location:-> General setup -> Namespaces support (NAMESPACES [=y])
Quoted 7 lines
Selects:
UIDGID_STRICT_TYPE_CHECKS[=n].
I think this commit meant "!FOO" rather than "FOO = n", othwewise there is no way for linux-next-20120518 to enableUSER_NS.
----------------------------------------
PATCH:user_ns: Fix wrong dependency inUIDGID_CONVERTED.
It turns out to be more subtle than that. The issue is that I have "depends on USB_DEVICEFS = n" and then USB_DEVICEFS was removed.
"depends on FOO = n" is the only way I found that will succeed when in verifying that FOO is neither enabled nor modular. "depends on !FOO" appears to succeed when FOO = m which is not at all what I want.
After both trees are merged I will have to remove that "depends on USB_DEVICEFS = n" dependency.
I can't see any possible way to do hand this before then.
Eric