From e95fd98b12d1d5290f3f14b32a030a982cb60ad8 Mon Sep 17 00:00:00 2001 From: Andrew Vagin Date: Sun, 15 Nov 2015 09:07:04 +0300 Subject: [PATCH] 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: 9d60724eca71 ("restore: restore mntns before creating private vma-s (v3)") Signed-off-by: Andrew Vagin Signed-off-by: Pavel Emelyanov --- cr-restore.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cr-restore.c b/cr-restore.c index c53cb131d..90042a89e 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -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 */ if (current->parent == NULL) { if (restore_finish_stage(CR_STATE_RESTORE_NS) < 0) @@ -1553,11 +1559,6 @@ static int restore_task_with_children(void *_arg) if (create_children_and_session()) 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()) goto err_fini_mnt;