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

restore: call close_old_fds() before forking children

If processes share a file descriptor table, they all have their own set
of service descriptors. close_old_fds() closes all file descriptors
execpt service descriptors

Fixes: 9d60724e ("restore: restore mntns before creating private vma-s (v3)")
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 70171818
...@@ -1504,6 +1504,12 @@ static int restore_task_with_children(void *_arg) ...@@ -1504,6 +1504,12 @@ static int restore_task_with_children(void *_arg)
} }
} }
if (!(ca->clone_flags & CLONE_FILES)) {
ret = close_old_fds(current);
if (ret)
goto err_fini_mnt;
}
/* Restore root task */ /* Restore root task */
if (current->parent == NULL) { if (current->parent == NULL) {
if (restore_finish_stage(CR_STATE_RESTORE_NS) < 0) if (restore_finish_stage(CR_STATE_RESTORE_NS) < 0)
...@@ -1553,11 +1559,6 @@ static int restore_task_with_children(void *_arg) ...@@ -1553,11 +1559,6 @@ static int restore_task_with_children(void *_arg)
if (create_children_and_session()) if (create_children_and_session())
goto err_fini_mnt; goto err_fini_mnt;
if (!(ca->clone_flags & CLONE_FILES)) {
ret = close_old_fds(current);
if (ret)
goto err_fini_mnt;
}
if (unmap_guard_pages()) if (unmap_guard_pages())
goto err_fini_mnt; goto err_fini_mnt;
......
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