Commit 36ad24a1 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Andrei Vagin

user_ns: Prepare creds of newly created task

Sockets are sent via SCM_CREDENTIALS, and this kernel interface
needs to have uid and gid mapped (see __scm_send() in kernel).
So, set them before send_fds() use.

Also, move prep_usernsd_transport() below to be after this
for uniformity.
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 8fadf2b3
......@@ -1242,6 +1242,11 @@ static void maybe_clone_parent(struct pstree_item *item,
}
}
static bool needs_prep_creds(struct pstree_item *item)
{
return (!item->parent && (root_ns_mask & CLONE_NEWUSER));
}
static inline int fork_with_pid(struct pstree_item *item)
{
struct cr_clone_arg ca;
......@@ -1637,6 +1642,9 @@ static int restore_task_with_children(void *_arg)
goto err;
}
if (needs_prep_creds(current) && (prepare_userns_creds()))
goto err;
/*
* Call this _before_ forking to optimize cgroups
* restore -- if all tasks live in one set of cgroups
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment