summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Gao2018-06-01 17:47:20 -0500
committerJosh Gao2018-07-18 20:11:46 -0500
commitc954ec09c527ae1ad758ddd44b178da66c4c35e0 (patch)
tree842dead3542e166d4039984029d5d30912f9ff28 /debuggerd
parentfcf2c01b5599a96b968afb1528c996d9486937b0 (diff)
downloadplatform-system-core-c954ec09c527ae1ad758ddd44b178da66c4c35e0.tar.gz
platform-system-core-c954ec09c527ae1ad758ddd44b178da66c4c35e0.tar.xz
platform-system-core-c954ec09c527ae1ad758ddd44b178da66c4c35e0.zip
debuggerd_handler: use syscall(__NR_close) instead of close.
Avoid bionic's file descriptor ownership checks by calling the close syscall manually. Test: debuggerd_test Change-Id: I10af6aca0e66fe030fd7a53506ae61c87695641d
Diffstat (limited to 'debuggerd')
-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));