mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-21 17:20:19 +00:00
clone_noasan: Allow to create CLONE_VM|CLONE_VFORK processes
Picked from patch "[PATCH RFC] namespaces: use CLONE_VFORK with CLONE_VM when it is possible" by Andrew Vagin. Currenly parent touches child's stack, as in moment of clone() call its stack pointer is above the child's (we allocate char stack[128] on parent's stack). This prevents to create CLONE_VM|CLONE_VFORK processes, because the child uses stack addresses occupied by parent. The patch changes clone_noasan() behaviour and allows to do that with the same memory consumption. We give a child memory, which is not used by parent clone(), so parent's and child's stacks have no tntersection. This allows to create CLONE_VM|CLONE_VFORK processes. Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
badf42caa4
commit
ef65d98a78
1 changed files with 7 additions and 9 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#include <sched.h>
|
||||
#include "common/compiler.h"
|
||||
#include "log.h"
|
||||
#include "common/bug.h"
|
||||
|
||||
/*
|
||||
* ASan doesn't play nicely with clone if we use current stack for
|
||||
|
|
@ -19,15 +21,11 @@
|
|||
*/
|
||||
int clone_noasan(int (*fn)(void *), int flags, void *arg)
|
||||
{
|
||||
void *stack_ptr = (void *)round_down((unsigned long)&stack_ptr - 256, 16);
|
||||
BUG_ON((flags & CLONE_VM) && !(flags & CLONE_VFORK));
|
||||
/*
|
||||
* Reserve some space for clone() to locate arguments
|
||||
* and retcode in this place
|
||||
* Reserve some bytes for clone() internal needs
|
||||
* and use as stack the address above this area.
|
||||
*/
|
||||
char stack[128] __stack_aligned__;
|
||||
char *stack_ptr = &stack[sizeof(stack)];
|
||||
int ret;
|
||||
|
||||
ret = clone(fn, stack_ptr, flags, arg);
|
||||
return ret;
|
||||
return clone(fn, stack_ptr, flags, arg);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue