lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 3 Oct 2008 20:37:31 -0500 From: "Serge E. Hallyn" <serue@...ibm.com> To: James Morris <jmorris@...hat.com> Cc: David Howells <dhowells@...hat.com>, Andrew Morton <akpm@...l.org>, Linux Containers <containers@...ts.osdl.org>, lkml <linux-kernel@...r.kernel.org> Subject: [PATCH 3/3] user namespaces: reset task's credentials on CLONE_NEWUSER Currently, creating a new user namespace does not reset the task's uid or gid. Since generally that is done as root because it requires CAP_SYS_ADMIN, and since the first uid in the new namespace is 0, one usually doesn't notice. However, if one does capset cap_sys_admin=ep ns_exec su - hallyn ns_exec -U /bin/sh id then one will see hallyn's userid, and all preexisting groups. With this patch, cloning a new user namespace will set the task's uid and gid to 0, and reset the group_info to the empty set assigned to init. Signed-off-by: Serge E. Hallyn <serue@...ibm.com> --- kernel/user_namespace.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) 4a159b503ed06f6d999b80680538a51ee39d6bd5 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index d59f193..3fbf520 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -9,6 +9,7 @@ #include <linux/nsproxy.h> #include <linux/slab.h> #include <linux/user_namespace.h> +#include <linux/init_task.h> /* * Clone a new ns copying an original user ns, setting refcount to 1 @@ -47,6 +48,17 @@ int create_new_userns(int flags, struct put_user_ns(ns); task_switch_uid(tsk, ns->root_user); + tsk->uid = tsk->euid = tsk->suid = tsk->fsuid = 0; + tsk->gid = tsk->egid = tsk->sgid = tsk->fsgid = 0; + + /* this can't be safe for unshare, can it? it's safe + * for fork, though. I'm tempted to limit clone_newuser to + * fork only */ + task_lock(tsk); + put_group_info(tsk->group_info); + tsk->group_info = &init_groups; + get_group_info(tsk->group_info); + task_unlock(tsk); return 0; } -- 1.1.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists