debuggerd: show syscall in SYS_SECCOMP one-liners.

The current logging...
```
F libc    : Fatal signal 31 (SIGSYS), code 1 (SYS_SECCOMP) in tid 6640 (logcat), pid 6640 (logcat)
```
...isn't super useful if crash_dump then fails, because you have no idea
what syscall caused the problem.

We already include the fault address in this line for relevant cases,
so include the syscall number in this case.

Bug: http://b/262391724
Test: treehugger
Change-Id: I45ad7d99c9904bab32b65efeb19be232e59ab3a4
This commit is contained in:
Elliott Hughes 2023-01-03 21:22:18 +00:00
parent b333a400c9
commit d32733dbc7

View file

@ -187,27 +187,29 @@ static bool get_main_thread_name(char* buf, size_t len) {
* mutex is being held, so we don't want to use any libc functions that
* could allocate memory or hold a lock.
*/
static void log_signal_summary(const siginfo_t* info) {
static void log_signal_summary(const siginfo_t* si) {
char main_thread_name[MAX_TASK_NAME_LEN + 1];
if (!get_main_thread_name(main_thread_name, sizeof(main_thread_name))) {
strncpy(main_thread_name, "<unknown>", sizeof(main_thread_name));
}
if (info->si_signo == BIONIC_SIGNAL_DEBUGGER) {
if (si->si_signo == BIONIC_SIGNAL_DEBUGGER) {
async_safe_format_log(ANDROID_LOG_INFO, "libc", "Requested dump for pid %d (%s)", __getpid(),
main_thread_name);
return;
}
// Many signals don't have an address or sender.
char addr_desc[32] = ""; // ", fault addr 0x1234"
if (signal_has_si_addr(info)) {
async_safe_format_buffer(addr_desc, sizeof(addr_desc), ", fault addr %p", info->si_addr);
}
// Many signals don't have a sender or extra detail, but some do...
pid_t self_pid = __getpid();
char sender_desc[32] = {}; // " from pid 1234, uid 666"
if (signal_has_sender(info, self_pid)) {
get_signal_sender(sender_desc, sizeof(sender_desc), info);
if (signal_has_sender(si, self_pid)) {
get_signal_sender(sender_desc, sizeof(sender_desc), si);
}
char extra_desc[32] = {}; // ", fault addr 0x1234" or ", syscall 1234"
if (si->si_signo == SIGSYS && si->si_code == SYS_SECCOMP) {
async_safe_format_buffer(extra_desc, sizeof(extra_desc), ", syscall %d", si->si_syscall);
} else if (signal_has_si_addr(si)) {
async_safe_format_buffer(extra_desc, sizeof(extra_desc), ", fault addr %p", si->si_addr);
}
char thread_name[MAX_TASK_NAME_LEN + 1]; // one more for termination
@ -221,8 +223,8 @@ static void log_signal_summary(const siginfo_t* info) {
async_safe_format_log(ANDROID_LOG_FATAL, "libc",
"Fatal signal %d (%s), code %d (%s%s)%s in tid %d (%s), pid %d (%s)",
info->si_signo, get_signame(info), info->si_code, get_sigcode(info),
sender_desc, addr_desc, __gettid(), thread_name, self_pid, main_thread_name);
si->si_signo, get_signame(si), si->si_code, get_sigcode(si), sender_desc,
extra_desc, __gettid(), thread_name, self_pid, main_thread_name);
}
/*