summaryrefslogtreecommitdiffstats
path: root/debuggerd
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2017-02-15 15:21:00 -0800
committerJosh Gao <jmgao@google.com>2017-02-15 16:25:27 -0800
commit8a7e70391207e9f6b65b40f9b2884935ea597436 (patch)
tree7c68190cb65d952a6683395fbfdf463de37ffb56 /debuggerd
parentaf776fd518df4f677bf8c3f4a8d22d23a3479181 (diff)
downloadsystem_core-8a7e70391207e9f6b65b40f9b2884935ea597436.tar.gz
system_core-8a7e70391207e9f6b65b40f9b2884935ea597436.tar.bz2
system_core-8a7e70391207e9f6b65b40f9b2884935ea597436.zip
crash_dump: make output fd O_APPEND.
Bug: http://b/35209835 Test: mma Change-Id: I447e3cfa3361f9c8b4b3335d0abccd1fe4c98e0f
Diffstat (limited to 'debuggerd')
-rw-r--r--debuggerd/crash_dump.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index 0ca90c3df..6819d485a 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -155,6 +155,14 @@ static bool tombstoned_connect(pid_t pid, unique_fd* tombstoned_socket, unique_f
return false;
}
+ // Make the fd O_APPEND so that our output is guaranteed to be at the end of a file.
+ // (This also makes selinux rules consistent, because selinux distinguishes between writing to
+ // a regular fd, and writing to an fd with O_APPEND).
+ int flags = fcntl(tmp_output_fd.get(), F_GETFL);
+ if (fcntl(tmp_output_fd.get(), F_SETFL, flags | O_APPEND) != 0) {
+ PLOG(WARNING) << "failed to set output fd flags";
+ }
+
*tombstoned_socket = std::move(sockfd);
*output_fd = std::move(tmp_output_fd);
return true;