userns: Make create_new_namespaces take a user_ns parameter
Modify create_new_namespaces to explicitly take a user namespace parameter, instead of implicitly through the task_struct. This allows an implementation of unshare(CLONE_NEWUSER) where the new user namespace is not stored onto the current task_struct until after all of the namespaces are created. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
@@ -32,7 +32,7 @@ static struct uts_namespace *create_uts_ns(void)
|
||||
* @old_ns: namespace to clone
|
||||
* Return NULL on error (failure to kmalloc), new ns otherwise
|
||||
*/
|
||||
static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
|
||||
static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
|
||||
struct uts_namespace *old_ns)
|
||||
{
|
||||
struct uts_namespace *ns;
|
||||
@@ -43,7 +43,7 @@ static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
|
||||
|
||||
down_read(&uts_sem);
|
||||
memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
|
||||
ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
|
||||
ns->user_ns = get_user_ns(user_ns);
|
||||
up_read(&uts_sem);
|
||||
return ns;
|
||||
}
|
||||
@@ -55,9 +55,8 @@ static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
|
||||
* versa.
|
||||
*/
|
||||
struct uts_namespace *copy_utsname(unsigned long flags,
|
||||
struct task_struct *tsk)
|
||||
struct user_namespace *user_ns, struct uts_namespace *old_ns)
|
||||
{
|
||||
struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
|
||||
struct uts_namespace *new_ns;
|
||||
|
||||
BUG_ON(!old_ns);
|
||||
@@ -66,7 +65,7 @@ struct uts_namespace *copy_utsname(unsigned long flags,
|
||||
if (!(flags & CLONE_NEWUTS))
|
||||
return old_ns;
|
||||
|
||||
new_ns = clone_uts_ns(tsk, old_ns);
|
||||
new_ns = clone_uts_ns(user_ns, old_ns);
|
||||
|
||||
put_uts_ns(old_ns);
|
||||
return new_ns;
|
||||
|
Reference in New Issue
Block a user