Commit graph

89 commits

Author SHA1 Message Date
Richard Uhler
3ff028c7db Merge "debuggerd: Dump list of open files on process crash."
am: b675f7cd32

Change-Id: Iec231fc7eb57fa2c51aabc0fb75b4a09c47004cd
2016-11-30 09:18:57 +00:00
Richard Uhler
53fb32f05c debuggerd: Dump list of open files on process crash.
Test: Open a bunch of files, wait for the process to crash, verify dubuggerd
includes the list of open files the tombstone it generates.
Test: Added OpenFilesListTest to debuggerd_test.

Bug: 32013594

Change-Id: I6f939ae1d04dc58dc99abff0ed930da9e0ef0d1c
2016-11-21 11:40:42 +00:00
Mark Salyzyn
8a7297a09f Merge "system/core: preparation to pull back interfaces from android/log.h"
am: 27d2d49f48

Change-Id: I604bb1d4cf62636663fa92e3d14a55887dbcae23
2016-10-20 18:03:57 +00:00
Mark Salyzyn
cfd5b080af system/core: preparation to pull back interfaces from android/log.h
Point to log/log.h where necessary, define LOG_TAG where necessary.
Accept that private/android_logger.h is suitable replacement for
log/logger.h and android/log.h.

Correct liblog/README

Effectively a cleanup and controlled select revert of
'system/core: drop or replace log/logger.h' and
'system/core: Replace log/log.h with android/log.h'.

Test: compile
Bug: 30465923
Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
2016-10-20 08:11:39 -07:00
Josh Gao
e758b2b3d3 Merge commit 'd3896c106d6a6e4d461be658a9e66efbde31f28d' into nyc-dev-plus-aosp
Change-Id: I77d77be5ba21c55cdf1172d7a7f7b4ba04dcbc81
2016-10-10 16:20:04 -07:00
Josh Gao
218f7fb68e debuggerd: report crashes even when out of file descriptors.
Use nasty clone hacks to let us close random file descriptors to be
able to connect to debuggerd when the fd table is full.

Bug: http://b/32013594
Test: crasher exhaustfd-SIGSEGV
Change-Id: I47772e9a5994da4473bd935b105d9c36827c017a
2016-10-07 18:04:05 -07:00
Mark Salyzyn
6e5ffe2680 Merge "system/core: drop or replace log/logger.h" am: 1f90485804
am: cb670780be

Change-Id: I532a0f6143511f53f3303751f95de115ac034cd7
2016-10-04 18:33:44 +00:00
Mark Salyzyn
37c9451349 system/core: drop or replace log/logger.h
debuggerd does not require log/logger.h, can use android/log.h
In some cases, mark why log/logger.h was required.

Test: Compile and boot smoke test
Bug: 26552300
Bug: 31289077
Bug: 31456426
Change-Id: Ia34987e25a01d81971ec8d785415f732b8376c4f
2016-10-04 09:09:10 -07:00
Elliott Hughes
c3501a4dff Merge "Fix debuggerd argument parsing." am: 99ed65234c
am: 014d9df418

Change-Id: I2565eb9a4b631e51bfe6bd57d328c8cdd2c3eff6
2016-09-16 21:13:17 +00:00
Elliott Hughes
9048608db1 Fix debuggerd argument parsing.
We weren't detecting incorrect input before. Also clean up the help output
to match the style of all the toybox output. Also flush stdout so that we
don't report failure before even saying that we're going to try to contact
debuggerd...

Change-Id: I9e4bfa878f270fe46c3c210c7a7138959a108d67
2016-09-15 17:08:33 -07:00
Elliott Hughes
66e5e2432a Merge "Most accept/accept4 calls in system/core don't actually want the remote address." am: 299d64144b
am: 8615d79d85

Change-Id: I89aeabf6efa8217c9acd3f8a766bbd18f7e994fa
2016-08-23 23:05:59 +00:00
Elliott Hughes
8615d79d85 Merge "Most accept/accept4 calls in system/core don't actually want the remote address."
am: 299d64144b

Change-Id: I3fb9678dfed08f0b1d6e90e547ecae6cdcabc9a1
2016-08-23 23:03:20 +00:00
Elliott Hughes
50a99aa6cb Merge "debuggerd: set SOCK_NONBLOCK in accept rather than later." am: 82b67fff06
am: 0d2ef3dc86

Change-Id: Ie8ae5707455f4d1741ca87ef515ea9a142e05aa5
2016-08-23 20:10:01 +00:00
Elliott Hughes
0d2ef3dc86 Merge "debuggerd: set SOCK_NONBLOCK in accept rather than later."
am: 82b67fff06

Change-Id: I6f2e72a4847fbfac8e1ba78321be7e026f7629bd
2016-08-23 20:05:48 +00:00
Elliott Hughes
3dcfa3fb1c Most accept/accept4 calls in system/core don't actually want the remote address.
So don't write the extra code for it or waste the kernel's time
copying it around.

Change-Id: I93de64064c2d4fe58ba5b5322cfa69bf31a76dad
2016-08-23 12:50:00 -07:00
Elliott Hughes
874c674c60 debuggerd: set SOCK_NONBLOCK in accept rather than later.
Change-Id: I95586984dd7aec798d75b150be238d5f6f7c91da
2016-08-22 14:17:25 -07:00
Josh Gao
27259667ec Merge "debuggerd: remove unnecessary arguments." am: 7a746f3a68
am: 60083bed75

Change-Id: I6f575a9662319db0dffeb121e0400eaa8f8cee55
2016-08-13 00:41:56 +00:00
Josh Gao
60083bed75 Merge "debuggerd: remove unnecessary arguments."
am: 7a746f3a68

Change-Id: I0a01639dd3096372eb5bbbe28362cdbf1c1da4af
2016-08-13 00:38:54 +00:00
Josh Gao
4a984ced34 Merge "debuggerd: remove useless timeout from wait_for_signal." am: 5f2bc28ebf
am: 4c4a172ee9

Change-Id: Ibbf4ff52d9349e8ceee5a6550c997328b204f332
2016-08-12 20:17:41 +00:00
Josh Gao
4c4a172ee9 Merge "debuggerd: remove useless timeout from wait_for_signal."
am: 5f2bc28ebf

Change-Id: Iee4f22c04ad330c91f86ca03583f8e36b2816039
2016-08-12 20:02:10 +00:00
Josh Gao
a04c80255c debuggerd: remove unnecessary arguments.
These were previously required when bionic used tgkill to reraise
signals, but now that we use rt_tgsigqueueinfo to reraise signals, they
are no longer necessary.

Change-Id: I46ba9f14039a727d0a2c4c3a9d93a3532ba8f263
2016-08-12 11:00:18 -07:00
Josh Gao
f5a960a187 debuggerd: remove useless timeout from wait_for_signal.
The watchdog already handles things for us, so the timeout logic in
wait_for_signal is pointless.

Change-Id: Id81ad5f294068216b73e04c4e2ceca072ae1bbc0
2016-08-12 11:00:18 -07:00
Josh Gao
2b50c4a37d Merge \"debuggerd: verify that traced threads belong to the right process.\" into nyc-dev
am: d3d04f4d72

Change-Id: I65cd7507a24b7148dd67d748dede8e664dd70328
2016-07-19 20:34:43 +00:00
Josh Gao
4a875ce6ff debuggerd: verify that traced threads belong to the right process.
Fix two races in debuggerd's PTRACE_ATTACH logic:
  1. The target thread in a crash dump request could exit between the
     /proc/<pid>/task/<tid> check and the PTRACE_ATTACH.
  2. Sibling threads could exit between listing /proc/<pid>/task and the
     PTRACE_ATTACH.

Bug: http://b/29555636
Change-Id: I4dfe1ea30e2c211d2389321bd66e3684dd757591
2016-07-13 16:49:02 -07:00
Josh Gao
88347e1430 Merge changes from topic \'debuggerd_client\'
am: abf88685e3

Change-Id: I2a61e4e8b5ec5a4ab6566ab4f8eb31653255fbc5
2016-06-20 20:47:18 +00:00
Josh Gao
9c02dc5916 debuggerd: add libdebuggerd_client.
Bug: http://b/24414818
Change-Id: I079c534d2c952b6975bf0428eb86cc7a55525737
2016-06-17 13:11:29 -07:00
Christopher Ferris
8b474de4ac Set groups before dropping privileges.
The code for dumping tombstones tries to read the log data. This was
silently failing after the change to drop root privileges. Fix this
by explicitly setting the groups allowed before dropping privileges.

Bug: 28590884
(cherry picked from commit edc2380109)

Change-Id: I225365edccb11f8752027566fd42f3b10ce10260
2016-05-05 15:47:16 -07:00
Christopher Ferris
f89a23f27b Merge "Set groups before dropping privileges." into nyc-dev
am: fd1eee58f9

* commit 'fd1eee58f985b3d528ca352ff278d7b200390ab2':
  Set groups before dropping privileges.

Change-Id: I85c98abb0e7cc3b36ec714899540d65e6ca908c7
2016-05-05 21:57:30 +00:00
Christopher Ferris
edc2380109 Set groups before dropping privileges.
The code for dumping tombstones tries to read the log data. This was
silently failing after the change to drop root privileges. Fix this
by explicitly setting the groups allowed before dropping privileges.

Bug: 28590884
Change-Id: Iaccb1d2928268fc9fc855f6e3814c31ce019badf
2016-05-05 11:13:50 -07:00
Christopher Ferris
e423c24f74 Merge "Fix problem with wait_for_gdb." into nyc-dev
am: a7431cfa57

* commit 'a7431cfa570c6385ecd2041d56ead2603d7b7b80':
  Fix problem with wait_for_gdb.

Change-Id: I6d995c423f4ad9134965a215b1eea4cc7fd338b9
2016-05-05 17:55:41 +00:00
Christopher Ferris
99235e9967 Fix problem with wait_for_gdb.
When someone enables wait_for_gdb, activity manager will kill the
stopped process before a developer can attach to the process. To
allow debugging in this case, change the code to only contact the
activity manager right before continuing the process that is
crashing.

Also, modify the conditions under which to do a gdb attach. The previous
code did a partial attach if perform_dump failed. The new version simply
allows an attach regardless of whether perform_dump passes or fails.

Bug: 28409358
(cherry picked from commit 9818bd2bbe)

Change-Id: I42f464b69332748e16b07d9d00f44b3aa26ce8b7
2016-05-05 10:50:39 -07:00
Christopher Ferris
9818bd2bbe Fix problem with wait_for_gdb.
When someone enables wait_for_gdb, activity manager will kill the
stopped process before a developer can attach to the process. To
allow debugging in this case, change the code to only contact the
activity manager right before continuing the process that is
crashing.

Also, modify the conditions under which to do a gdb attach. The previous
code did a partial attach if perform_dump failed. The new version simply
allows an attach regardless of whether perform_dump passes or fails.

Bug: 28409358
Change-Id: I4fe8d390c212d47e007cbe6543c2d114c3c7aeff
2016-05-04 17:42:30 -07:00
Christopher Ferris
1ba92f874a Connect to activity manager as root.
am: 0fc89f3

* commit '0fc89f34b99f20f0ebc0111df74490f4ebd44076':
  Connect to activity manager as root.

Change-Id: I28ad7d209d6d94be790bd4ffd1e5b31da4cd8589
2016-04-20 21:58:06 +00:00
Christopher Ferris
8fb38ae82d Connect to activity manager as root.
Before dropping root privileges, connect to the activity manager.
Also, only connect to the activity manager if this is a crash.

Bug: 28210681
(cherry picked from commit 0fc89f34b9)

Change-Id: Id25b92e550d71ffe1b9eafe43976ef514a83714b
2016-04-20 14:38:44 -07:00
Christopher Ferris
0fc89f34b9 Connect to activity manager as root.
Before dropping root privileges, connect to the activity manager.
Also, only connect to the activity manager if this is a crash.

Bug: 28210681
Change-Id: Ie266031910519fa2aa6835644a95c1fc56e24d8d
2016-04-20 11:30:33 -07:00
Josh Gao
dac593937f debuggerd: add SIGSYS to the list of handled signals.
am: dfa163d

* commit 'dfa163df500ca71b71be315aa55e8859c946d0fb':
  debuggerd: add SIGSYS to the list of handled signals.
2016-03-26 01:16:25 +00:00
Josh Gao
dfa163df50 debuggerd: add SIGSYS to the list of handled signals.
Processes using seccomp will get SIGSYS when attempting to use a
disallowed syscall. We're currently not handling SIGSYS in bionic's
signal handler, but this change will let us dump a backtrace pointing at
rt_tgsigqueueinfo in our signal handler if seccomp policies block it
during a real crash.

Bug: http://b/27853687
Change-Id: I4e4aacc95eeef7249d895e19dc4ccd77a51c7a17
2016-03-25 14:34:22 -07:00
Josh Gao
6eb4eab106 debuggerd: waitpid for all children, and log the result.
Change-Id: Ic575e6db76ab153b4b238589a8cd299812d0e046
(cherry picked from commit 2808005521)
2016-03-23 14:28:01 -07:00
Josh Gao
a6219eae8d debuggerd: always send SIGCONT after detaching.
Bug: http://b/27330889
Change-Id: I104248af1cde03dbdbacc03c87fe7e2dffd6c037
(cherry picked from commit 24464185eb)
2016-03-23 14:27:57 -07:00
Josh Gao
8aeabe15dd Merge "debuggerd: waitpid for all children, and log the result." 2016-03-23 21:10:38 +00:00
Josh Gao
6e183586e3 Merge "debuggerd: always send SIGCONT after detaching." 2016-03-23 21:09:21 +00:00
Josh Gao
2808005521 debuggerd: waitpid for all children, and log the result.
Change-Id: Ic575e6db76ab153b4b238589a8cd299812d0e046
2016-03-23 14:07:58 -07:00
Josh Gao
24464185eb debuggerd: always send SIGCONT after detaching.
Bug: http://b/27330889
Change-Id: I104248af1cde03dbdbacc03c87fe7e2dffd6c037
2016-03-23 14:07:58 -07:00
Elliott Hughes
ae38923c3e Switch debuggerd over to unique_fd.
Change-Id: I858b9ac6a3ed47b4cc81cfe49f1ceb1e06356a03
2016-03-22 20:03:13 -07:00
Josh Gao
e59c76ab62 debuggerd: don't apply timeout when wait_for_gdb is on.
Change-Id: Ic632dde4a0510c212a4b1c01890df9a41e9771c9
(cherry picked from commit 676a756b7b)
2016-03-17 15:33:24 -07:00
Josh Gao
676a756b7b debuggerd: don't apply timeout when wait_for_gdb is on.
Change-Id: Ic632dde4a0510c212a4b1c01890df9a41e9771c9
2016-03-17 15:29:00 -07:00
Josh Gao
965d6f4d17 debuggerd: don't send SIGSTOP to crashing processes.
This was actually nonfunctional until f5e8f0b, because it was using kill
after privileges were dropped. This doesn't seem necessary after the
changes to the sibling thread ptrace logic, though.

Bug: http://b/27427439
Change-Id: I6bffbc14e0cf5e377bbfa39c945518e0d436c223
(cherry picked from commit b17f228ff6)
2016-03-17 14:15:01 -07:00
Josh Gao
b17f228ff6 debuggerd: don't send SIGSTOP to crashing processes.
This was actually nonfunctional until f5e8f0b, because it was using kill
after privileges were dropped. This doesn't seem necessary after the
changes to the sibling thread ptrace logic, though.

Bug: http://b/27427439
Change-Id: I6bffbc14e0cf5e377bbfa39c945518e0d436c223
2016-03-17 13:47:48 -07:00
Josh Gao
036ff2ce83 debuggerd: monitor the worker process for failure.
Use sigtimedwait on SIGCHLD to watch our forked worker processes for
failure, so that we can guarantee that we always resume/kill the target
process if libunwind crashes.

Bug: http://b/27427439
Change-Id: I5a5da1f1abd7dc9d01223f5b3778e946e2d47d20
(cherry picked from commit 630bc80e18)
2016-03-17 13:11:08 -07:00
Josh Gao
e5dbdd09c7 debuggerd: fork the signal sender once.
Bug: http://b/27427439
Change-Id: I6294ff68a150bc9950a300264c31d2141307ac66
(cherry picked from commit f5e8f0b9cd)
2016-03-17 13:11:05 -07:00