daemon: Ensure the child stack is aligned on a 16-byte boundary.
* nix/libstore/build.cc (DerivationGoal::startBuilder): When calling 'clone', ensure that the stack is aligned on a 16-byte boundary.
This commit is contained in:
parent
73a203450d
commit
a1aa5dabaa
|
@ -26,6 +26,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
|
@ -2008,11 +2009,11 @@ void DerivationGoal::startBuilder()
|
||||||
char stack[32 * 1024];
|
char stack[32 * 1024];
|
||||||
int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | SIGCHLD;
|
int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | SIGCHLD;
|
||||||
if (!fixedOutput) flags |= CLONE_NEWNET;
|
if (!fixedOutput) flags |= CLONE_NEWNET;
|
||||||
#ifdef __aarch64__
|
/* Ensure proper alignment on the stack. On aarch64, it has to be 16
|
||||||
pid = clone(childEntry, stack + sizeof(stack) - 16, flags, this);
|
bytes. */
|
||||||
#else
|
pid = clone(childEntry,
|
||||||
pid = clone(childEntry, stack + sizeof(stack) - 8, flags, this);
|
(char *)(((uintptr_t)stack + sizeof(stack) - 8) & ~(uintptr_t)0xf),
|
||||||
#endif
|
flags, this);
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
throw SysError("cloning builder process");
|
throw SysError("cloning builder process");
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue