Skip to content

Commit

Permalink
preload/host/spawn_strategy: Override __close
Browse files Browse the repository at this point in the history
Fixes #12.
  • Loading branch information
refi64 committed Jun 3, 2021
1 parent ae8b042 commit 89dd114
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/preload/host/spawn_strategy/no_close_host_fd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@

bool zypak::preload::block_supervisor_fd_close = false;

DECLARE_OVERRIDE_THROW(int, close, int fd) {
// Chrome 92 introduces its own close override:
// https://chromium-review.googlesource.com/q/I918d79c343c0027ee1ce4353c7acbe7c0e79d1dd This will
// mean that an override of "close" here will not take effect anymore. In order to work around it,
// we can also override glibc's __close instead, which Chromium's close override calls into.

DECLARE_OVERRIDE_THROW(int, __close, int fd) {
if (fd == zypak::sandbox::kZypakSupervisorFd && zypak::preload::block_supervisor_fd_close) {
return 0;
}

// Just use the syscall to avoid tons of latency from indirection.
return syscall(__NR_close, fd);
}

DECLARE_OVERRIDE_THROW(int, close, int fd) { return __close_override_detail::__close(fd); }

0 comments on commit 89dd114

Please sign in to comment.