summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'debuggerd/handler/debuggerd_handler.cpp')
-rw-r--r--debuggerd/handler/debuggerd_handler.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index c07a34a70..615fb46ad 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -59,7 +59,16 @@
59#include "protocol.h" 59#include "protocol.h"
60 60
61using android::base::Pipe; 61using android::base::Pipe;
62using android::base::unique_fd; 62
63// We muck with our fds in a 'thread' that doesn't share the same fd table.
64// Close fds in that thread with a raw close syscall instead of going through libc.
65struct FdsanBypassCloser {
66 static void Close(int fd) {
67 syscall(__NR_close, fd);
68 }
69};
70
71using unique_fd = android::base::unique_fd_impl<FdsanBypassCloser>;
63 72
64// see man(2) prctl, specifically the section about PR_GET_NAME 73// see man(2) prctl, specifically the section about PR_GET_NAME
65#define MAX_TASK_NAME_LEN (16) 74#define MAX_TASK_NAME_LEN (16)
@@ -299,7 +308,8 @@ static int debuggerd_dispatch_pseudothread(void* arg) {
299 debugger_thread_info* thread_info = static_cast<debugger_thread_info*>(arg); 308 debugger_thread_info* thread_info = static_cast<debugger_thread_info*>(arg);
300 309
301 for (int i = 0; i < 1024; ++i) { 310 for (int i = 0; i < 1024; ++i) {
302 close(i); 311 // Don't use close to avoid bionic's file descriptor ownership checks.
312 syscall(__NR_close, i);
303 } 313 }
304 314
305 int devnull = TEMP_FAILURE_RETRY(open("/dev/null", O_RDWR)); 315 int devnull = TEMP_FAILURE_RETRY(open("/dev/null", O_RDWR));