Commit d3cf1c4f authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

restore: Wait for userns being prepared before moving into cgroups (v3)

When user namespace are stepping in we should wait for their preparation
to complete before start using userns daemon (internally the kernel
checks for uids and if uids are not set -EINVAL will be returned
when usersn calls for sendmsg()).

v2: change stages correctly
v3: Wait prepare_userns() before making any calls to usernsd()

Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent bd057dc3
...@@ -1643,6 +1643,11 @@ static int restore_task_with_children(void *_arg) ...@@ -1643,6 +1643,11 @@ static int restore_task_with_children(void *_arg)
goto err; goto err;
} }
/* Wait prepare_userns */
if (current->parent == NULL &&
restore_finish_stage(CR_STATE_RESTORE_NS) < 0)
goto err;
/* /*
* Call this _before_ forking to optimize cgroups * Call this _before_ forking to optimize cgroups
* restore -- if all tasks live in one set of cgroups * restore -- if all tasks live in one set of cgroups
...@@ -1654,9 +1659,6 @@ static int restore_task_with_children(void *_arg) ...@@ -1654,9 +1659,6 @@ static int restore_task_with_children(void *_arg)
/* Restore root task */ /* Restore root task */
if (current->parent == NULL) { if (current->parent == NULL) {
if (restore_finish_stage(CR_STATE_RESTORE_NS) < 0)
goto err;
pr_info("Calling restore_sid() for init\n"); pr_info("Calling restore_sid() for init\n");
restore_sid(); restore_sid();
......
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