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

Pavel Emelyanov xemul at parallels.com
Thu Oct 30 05:11:03 PDT 2014


On 10/14/2014 03:38 PM, Andrey Vagin wrote:
> 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);
> +			}
> +			if (prctl(PR_SET_DUMPABLE, 1, 0)) {
> +				pr_perror("Unable to set PR_SET_DUMPABLE");
> +				exit(1);
> +			}

Can we have the code under this if () in a separate helper, please?

>  		}
>  
>  		if (prepare_namespace(current, ca->clone_flags))
> 



More information about the CRIU mailing list