mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Update naming and lambda capture for stack size
PiperOrigin-RevId: 515254988 Change-Id: I394dc039bcfcbd2ccd7c705a91974f4183b28c39
This commit is contained in:
parent
0d3d5d4bcb
commit
e031c11bdc
|
@ -180,24 +180,26 @@ absl::StatusOr<std::unique_ptr<GlobalForkClient>> StartGlobalForkServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fork the fork-server, and clean-up the resources (close remote sockets).
|
// Fork the fork-server, and clean-up the resources (close remote sockets).
|
||||||
const size_t kStackSize = PTHREAD_STACK_MIN;
|
const size_t stack_size = PTHREAD_STACK_MIN;
|
||||||
int clone_flags = CLONE_VM | CLONE_VFORK | SIGCHLD;
|
int clone_flags = CLONE_VM | CLONE_VFORK | SIGCHLD;
|
||||||
// CLONE_VM does not play well with TSan.
|
// CLONE_VM does not play well with TSan.
|
||||||
if constexpr (sapi::sanitizers::IsTSan()) {
|
if constexpr (sapi::sanitizers::IsTSan()) {
|
||||||
clone_flags &= ~CLONE_VM & ~CLONE_VFORK;
|
clone_flags &= ~CLONE_VM & ~CLONE_VFORK;
|
||||||
}
|
}
|
||||||
char* stack =
|
char* stack =
|
||||||
static_cast<char*>(mmap(NULL, kStackSize, PROT_READ | PROT_WRITE,
|
static_cast<char*>(mmap(NULL, stack_size, PROT_READ | PROT_WRITE,
|
||||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0));
|
MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0));
|
||||||
if (stack == MAP_FAILED) {
|
if (stack == MAP_FAILED) {
|
||||||
return absl::ErrnoToStatus(errno, "Allocating stack failed");
|
return absl::ErrnoToStatus(errno, "Allocating stack failed");
|
||||||
}
|
}
|
||||||
absl::Cleanup stack_dealloc = [stack] { munmap(stack, kStackSize); };
|
absl::Cleanup stack_dealloc = [stack, stack_size] {
|
||||||
|
munmap(stack, stack_size);
|
||||||
|
};
|
||||||
ForkserverArgs args = {
|
ForkserverArgs args = {
|
||||||
.exec_fd = exec_fd,
|
.exec_fd = exec_fd,
|
||||||
.comms_fd = sv[0],
|
.comms_fd = sv[0],
|
||||||
};
|
};
|
||||||
pid_t pid = clone(LaunchForkserver, &stack[kStackSize], clone_flags, &args,
|
pid_t pid = clone(LaunchForkserver, &stack[stack_size], clone_flags, &args,
|
||||||
nullptr, nullptr, nullptr);
|
nullptr, nullptr, nullptr);
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
return absl::ErrnoToStatus(errno, "Forking forkserver process failed");
|
return absl::ErrnoToStatus(errno, "Forking forkserver process failed");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user