Commit 17768218 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

check: try to call clone with CLONE_NEWPID and CLONE_PARENT

This combination was forbidden in 3.12
commit 40a0d32d1eaffe6aac7324ca92604b6b3977eb0e :
"fork: unify and tighten up CLONE_NEWUSER/CLONE_NEWPID checks"

and then it was permited again in 3.13:
commit 1f7f4dde5c945f41a7abc2285be43d918029ecc5
fork:  Allow CLONE_PARENT after setns(CLONE_NEWPID)

Cc: Adrian Reber <adrian@lisas.de>
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e880dbd9
......@@ -726,6 +726,33 @@ static int check_fdinfo_lock(void)
return 0;
}
struct clone_arg {
/*
* Reserve some space for clone() to locate arguments
* and retcode in this place
*/
char stack[128] __attribute__((aligned (8)));
char stack_ptr[0];
};
static int clone_cb(void *_arg) {
exit(0);
}
static int check_clone_parent_vs_pid()
{
struct clone_arg ca;
pid_t pid;
pid = clone(clone_cb, ca.stack_ptr, CLONE_NEWPID | CLONE_PARENT, &ca);
if (pid < 0) {
pr_err("CLONE_PARENT | CLONE_NEWPID don't work together\n");
return -1;
}
return 0;
}
static int (*chk_feature)(void);
int cr_check(void)
......@@ -780,6 +807,7 @@ int cr_check(void)
ret |= check_mnt_id();
ret |= check_aio_remap();
ret |= check_fdinfo_lock();
ret |= check_clone_parent_vs_pid();
out:
if (!ret)
......
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