Commit 4d164327 authored by Andrei Vagin's avatar Andrei Vagin Committed by Andrei Vagin

restore: set uid and git onto zero otherwise PR_SET_MM_EXE_FILE can fail

When a non-root user runs "criu restore" and criu has the suid bit,
a process will run with non-zero uid and gid.

Before the 4.13 kernel (4d28df6152aa "prctl: Allow local CAP_SYS_ADMIN
changing exe_file"), PR_SET_MM_EXE_FILE fails if uid or gid isn't zero.
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent ae55a6cc
......@@ -1286,7 +1286,11 @@ static void maybe_clone_parent(struct pstree_item *item,
static bool needs_prep_creds(struct pstree_item *item)
{
return (!item->parent && (root_ns_mask & CLONE_NEWUSER));
/*
* Before the 4.13 kernel, it was impossible to set
* an exe_file if uid or gid isn't zero.
*/
return (!item->parent && ((root_ns_mask & CLONE_NEWUSER) || getuid()));
}
static inline int fork_with_pid(struct pstree_item *item)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment