From 24a7df5d38c638489cc4e1b3a8034a3b1ad2cf36 Mon Sep 17 00:00:00 2001 From: Tomislav Novak Date: Wed, 9 Aug 2023 15:19:51 -0700 Subject: [PATCH] debuggerd: fix passing of fdsan_table to crash_dump Commit aosp/1259140 moved fdsan_table into debugger_process_info, which is populated conditionally. This introduced a bug where the process that receives BIONIC_SIGNAL_DEBUGGER (35) does not propagate the fdsan_table pointer to crash_dump: $ adb shell kill -SIG35 $ adb logcat -s DEBUG E DEBUG : failed to read fdsan table entry 0: I/O error Fdsan in warn-only mode uses BIONIC_SIGNAL_DEBUGGER[1], so the generated tombstones don't have any fd ownership info. Fix it by calling get_process_info() irrespective of the signal being handled, taking care to preserve the previous behavior of not showing abort messages set by applications in non-fatal dumps. Test: debuggerd_test Test: send SIG35 to arbitrary process and inspect the log and tombstone Test: crasher fdsan_file [1] https://android.googlesource.com/platform/bionic/+/20ad9129e7115417fcd1da922693947580b7f0a6/libc/bionic/fdsan.cpp#166 Change-Id: I76931ca4825e846fc99f26fa590c045130abb850 --- debuggerd/handler/debuggerd_handler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp index 1e5365d3c..01365f22f 100644 --- a/debuggerd/handler/debuggerd_handler.cpp +++ b/debuggerd/handler/debuggerd_handler.cpp @@ -552,8 +552,14 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* c } debugger_process_info process_info = {}; + if (g_callbacks.get_process_info) { + process_info = g_callbacks.get_process_info(); + } uintptr_t si_val = reinterpret_cast(info->si_ptr); if (signal_number == BIONIC_SIGNAL_DEBUGGER) { + // Applications can set abort messages via android_set_abort_message without + // actually aborting; ignore those messages in non-fatal dumps. + process_info.abort_msg = nullptr; if (info->si_code == SI_QUEUE && info->si_pid == __getpid()) { // Allow for the abort message to be explicitly specified via the sigqueue value. // Keep the bottom bit intact for representing whether we want a backtrace or a tombstone. @@ -562,8 +568,6 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* c info->si_ptr = reinterpret_cast(si_val & 1); } } - } else if (g_callbacks.get_process_info) { - process_info = g_callbacks.get_process_info(); } gwp_asan_callbacks_t gwp_asan_callbacks = {};