[CRIU] [PATCH 10/14] restore: set PR_SET_DUMPABLE to have access to proc files

Serge Hallyn serge.hallyn at ubuntu.com
Tue Oct 14 07:47:01 PDT 2014


Quoting Andrey Vagin (avagin at openvz.org):
> It is cleared when a process is forked in a new userns.
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  cr-restore.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index 8944b93..0710e87 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1417,9 +1417,15 @@ static int restore_task_with_children(void *_arg)
>  			goto err;
>  
>  		/* UID and GID must be set after restoring /proc/PID/{uid,gid}_maps */
> -		if ((ca->clone_flags & CLONE_NEWUSER) && (setuid(0) || setgid(0))) {
> -			pr_perror("Unable to initialize id-s");
> -			exit(1);
> +		if ((ca->clone_flags & CLONE_NEWUSER)) {
> +			if (setuid(0) || setgid(0)) {
> +				pr_perror("Unable to initialize id-s");
> +				exit(1);
> +			}

This might be done elsewhere, but should you setgroups(0, NULL) as
well?

> +			if (prctl(PR_SET_DUMPABLE, 1, 0)) {
> +				pr_perror("Unable to set PR_SET_DUMPABLE");
> +				exit(1);
> +			}
>  		}
>  
>  		if (prepare_namespace(current, ca->clone_flags))
> -- 
> 1.9.3
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list