Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12b71294 authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Small debuggerd improvements.

Include the ABI in seccomp causes.

Slightly improved command-line usage information.

Fix crasher for seccomp failures.

Bug: N/A
Test: crasher
Change-Id: Ie419ecfe72ee4f5ccf49c927be18350a58a66a90
parent 22cc398d
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,7 @@ cc_binary {
    shared_libs: [
    shared_libs: [
        "libbase",
        "libbase",
        "liblog",
        "liblog",
        "libseccomp_policy",
    ],
    ],
    multilib: {
    multilib: {
        lib32: {
        lib32: {
@@ -69,6 +70,7 @@ cc_binary {
        "libdebuggerd_handler",
        "libdebuggerd_handler",
        "libbase",
        "libbase",
        "liblog",
        "liblog",
        "libseccomp_policy",
    ],
    ],
    multilib: {
    multilib: {
        lib32: {
        lib32: {
+3 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,8 @@
#include <android-base/logging.h>
#include <android-base/logging.h>
#include <log/log.h>
#include <log/log.h>


#include "seccomp_policy.h"

#if defined(STATIC_CRASHER)
#if defined(STATIC_CRASHER)
#include "debuggerd/handler.h"
#include "debuggerd/handler.h"
#endif
#endif
@@ -269,6 +271,7 @@ noinline int do_action(const char* arg) {
        munmap(map, sizeof(int));
        munmap(map, sizeof(int));
        map[0] = '8';
        map[0] = '8';
    } else if (!strcasecmp(arg, "seccomp")) {
    } else if (!strcasecmp(arg, "seccomp")) {
        set_seccomp_filter();
        syscall(99999);
        syscall(99999);
#if defined(__arm__)
#if defined(__arm__)
    } else if (!strcasecmp(arg, "kuser_helper_version")) {
    } else if (!strcasecmp(arg, "kuser_helper_version")) {
+5 −3
Original line number Original line Diff line number Diff line
@@ -34,6 +34,8 @@ using android::base::unique_fd;


static void usage(int exit_code) {
static void usage(int exit_code) {
  fprintf(stderr, "usage: debuggerd [-b] PID\n");
  fprintf(stderr, "usage: debuggerd [-b] PID\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "-b, --backtrace    just a backtrace rather than a full tombstone\n");
  _exit(exit_code);
  _exit(exit_code);
}
}


@@ -56,7 +58,8 @@ static std::thread spawn_redirect_thread(unique_fd fd) {
int main(int argc, char* argv[]) {
int main(int argc, char* argv[]) {
  if (argc <= 1) usage(0);
  if (argc <= 1) usage(0);
  if (argc > 3) usage(1);
  if (argc > 3) usage(1);
  if (argc == 3 && strcmp(argv[1], "-b") != 0) usage(1);
  if (argc == 3 && strcmp(argv[1], "-b") != 0 && strcmp(argv[1], "--backtrace") != 0) usage(1);
  bool backtrace_only = argc == 3;


  pid_t pid;
  pid_t pid;
  if (!android::base::ParseInt(argv[argc - 1], &pid, 1, std::numeric_limits<pid_t>::max())) {
  if (!android::base::ParseInt(argv[argc - 1], &pid, 1, std::numeric_limits<pid_t>::max())) {
@@ -69,9 +72,8 @@ int main(int argc, char* argv[]) {
  }
  }


  std::thread redirect_thread = spawn_redirect_thread(std::move(piperead));
  std::thread redirect_thread = spawn_redirect_thread(std::move(piperead));
  bool backtrace = argc == 3;
  if (!debuggerd_trigger_dump(pid, std::move(pipewrite),
  if (!debuggerd_trigger_dump(pid, std::move(pipewrite),
                              backtrace ? kDebuggerdBacktrace : kDebuggerdTombstone, 0)) {
                              backtrace_only ? kDebuggerdBacktrace : kDebuggerdTombstone, 0)) {
    redirect_thread.join();
    redirect_thread.join();
    errx(1, "failed to dump process %d", pid);
    errx(1, "failed to dump process %d", pid);
  }
  }
+2 −1
Original line number Original line Diff line number Diff line
@@ -214,7 +214,8 @@ static void dump_probable_cause(log_t* log, const siginfo_t& si) {
      cause = "call to kuser_cmpxchg64";
      cause = "call to kuser_cmpxchg64";
    }
    }
  } else if (si.si_signo == SIGSYS && si.si_code == SYS_SECCOMP) {
  } else if (si.si_signo == SIGSYS && si.si_code == SYS_SECCOMP) {
    cause = StringPrintf("seccomp prevented call to disallowed system call %d", si.si_syscall);
    cause = StringPrintf("seccomp prevented call to disallowed %s system call %d",
                         ABI_STRING, si.si_syscall);
  }
  }


  if (!cause.empty()) _LOG(log, logtype::HEADER, "Cause: %s\n", cause.c_str());
  if (!cause.empty()) _LOG(log, logtype::HEADER, "Cause: %s\n", cause.c_str());