[CRIU] Fix cpuset restore-in-root bug
Pavel Emelyanov
xemul at parallels.com
Wed Oct 8 08:09:04 PDT 2014
On 10/08/2014 07:05 PM, Tycho Andersen wrote:
> On Wed, Oct 08, 2014 at 06:46:37PM +0400, Pavel Emelyanov wrote:
>>
>> Yes, you're right. I meant the prepare_fds() one -- it closes proc service
>> fd and tty one. I think the cgyard can be closed even earlier, but this place
>> is at least about fds :)
>
> Yes, this works for me:
Great! Patch applied. Thanks for the report and help with the fix :)
>
>>From a6ef413cbcf6cbbf8b5182f7f4caf8f51256faf5 Mon Sep 17 00:00:00 2001
> From: Tycho Andersen <tycho.andersen at canonical.com>
> Date: Tue, 7 Oct 2014 17:25:26 -0500
> Subject: [PATCH] restore: don't race when closing cg yard
>
> TASK_HELPERs are created with CLONE_FILES, so if we always close the cg yard
> here, it will close it for the other helpers and cause problems. Instead, we
> close it much later, in code only called by alive tasks, to ensure that there
> is no conflict.
>
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
> cr-restore.c | 8 --------
> files.c | 7 +++++++
> 2 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/cr-restore.c b/cr-restore.c
> index fd35bef..c8cb428 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1461,14 +1461,6 @@ static int restore_task_with_children(void *_arg)
> if (create_children_and_session())
> goto err_fini_mnt;
>
> - /*
> - * This must be done after forking to allow child
> - * to get the cgroup fd so it can move into the
> - * correct /tasks file if it is in a different cgroup
> - * set than its parent
> - */
> - close_service_fd(CGROUP_YARD);
> -
> if (restore_task_mnt_ns(current))
> goto err_fini_mnt;
>
> diff --git a/files.c b/files.c
> index b975cd4..ce83736 100644
> --- a/files.c
> +++ b/files.c
> @@ -949,6 +949,13 @@ int prepare_fds(struct pstree_item *me)
>
> pr_info("Opening fdinfo-s\n");
>
> + /*
> + * This must be done after forking to allow child
> + * to get the cgroup fd so it can move into the
> + * correct /tasks file if it is in a different cgroup
> + * set than its parent
> + */
> + close_service_fd(CGROUP_YARD);
> close_pid_proc(); /* flush any proc cached fds we may have */
>
> if (rsti(me)->fdt) {
>
More information about the CRIU
mailing list