[CRIU] [PATCH] files-reg: fix /proc/<pid>/* ownership for linkat restore

Andrew Vagin avagin at virtuozzo.com
Thu Dec 17 05:07:22 PST 2015


On Thu, Dec 17, 2015 at 03:25:41PM +0300, Dmitry Safonov wrote:
> After linkat_hard with setfsuid permissions of files in
> /proc/<pid>/* changes to root because of pid_getattr @ fs/proc/base.c
> will fail to check has_pid_permissions() in ptrace_may_access()
> Fix it with PR_SET_DUMPABLE.
> 
> Cc: Andrew Vagin <avagin at virtuozzo.com>
> Signed-off-by: Dmitry Safonov <dsafonov at odin.com>
> ---
>  files-reg.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/files-reg.c b/files-reg.c
> index 425dc04..082e46c 100644
> --- a/files-reg.c
> +++ b/files-reg.c
> @@ -6,6 +6,7 @@
>  #include <sys/mman.h>
>  #include <sys/types.h>
>  #include <sys/stat.h>
> +#include <sys/prctl.h>
>  #include <sys/vfs.h>
>  #include <ctype.h>
>  
> @@ -1100,6 +1101,7 @@ static int linkat_hard(int odir, char *opath, int ndir, char *npath, uid_t owner
>  			 */
>  	}
>  	errno = errno_save;
> +	prctl(PR_SET_DUMPABLE, 1, 0);

We need to check its error code.

>  
>  	return ret;
>  }
> -- 
> 2.6.3
> 


More information about the CRIU mailing list