From 89dd114427a114028f249ed9b2824d083f459eb5 Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez Date: Thu, 3 Jun 2021 13:19:40 -0500 Subject: [PATCH] preload/host/spawn_strategy: Override __close Fixes #12. --- src/preload/host/spawn_strategy/no_close_host_fd.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/preload/host/spawn_strategy/no_close_host_fd.cc b/src/preload/host/spawn_strategy/no_close_host_fd.cc index a23a569..cef7e1b 100644 --- a/src/preload/host/spawn_strategy/no_close_host_fd.cc +++ b/src/preload/host/spawn_strategy/no_close_host_fd.cc @@ -16,7 +16,12 @@ 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; } @@ -24,3 +29,5 @@ DECLARE_OVERRIDE_THROW(int, close, int fd) { // 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); }