Commit graph

53818 commits

Author SHA1 Message Date
Christopher Ferris
23f2a0b166 Add method to get usage stats for a single map.
The new scudo allocator creates a huge map in 64 bit address space. Some
tests would get the usage stats of all maps, but only really cared about
a small set of maps. In this case, provide a method to only get the usage
stats for the maps you care about.

Test: Unit tests pass.
Change-Id: Ie845e47a8c789a57bf689c9f0e5878a921640e30
2019-10-10 15:10:27 -07:00
Nick Desaulniers
67d52aa0f6 [debuggerd] fix -Wreorder-init-list
C++20 wants members to be ordered unlike C99.

Bug: 139945549
Test: mm
Change-Id: I3cbca589511c1e0bbc10c691949e18de77e16031
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-10-10 14:54:35 -07:00
Suren Baghdasaryan
bc605b7b75 Merge "libmeminfo: Report VMA flags in showmap report"
am: 9186612f9a

Change-Id: Ic607f518e33221e9297565fa0d9f65e1bb2555f3
2019-10-10 13:40:15 -07:00
Suren Baghdasaryan
9186612f9a Merge "libmeminfo: Report VMA flags in showmap report" 2019-10-10 20:13:48 +00:00
Josh Gao
6ce44041b5 Move remount to PRODUCT_PACKAGES_DEBUG.
required seems to conflict with apex with the following error:

    build/make/core/main.mk:1338: warning: build/make/target/product/aosp_x86_64.mk produces files inside build/make/target/product/mainline_system.mks artifact path requirement.

Test: treehugger
Change-Id: If1fbb9c4a4be340750ee6daea7aa4621177d8d56
2019-10-10 13:12:21 -07:00
Alessio Balsini
08916b9ea2 Fuzzer for libdm's dm-linear devices creation
Create a fuzzer that fuzzes the parameters used for the creation
of dm-linear tables through libdm.
This fuzzer is based on libdm::DmLinear.

Bug: none
Test: dm_linear_fuzzer
Change-Id: I052144c6eb0db4fa6a37b5e54fbcb8193e5dc88f
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-10 20:59:33 +01:00
Alessio Balsini
5e6dc03fd5 Move TempDevice to test_util.h
TempDevice is useful class for tests, move it to test_util.h to improve
its visibility and make it usable by other tests.

Bug: none
Test: none
Change-Id: Idad5667844b10559b24f8f5e657e47d99e14209e
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-10 20:59:33 +01:00
Florian Mayer
ad427b74c4 Remove useless goto.
Test: build

Change-Id: Ifb8d832de1115eefbf2e09c6d5c8f03244566933
2019-10-10 18:15:24 +01:00
Nikita Ioffe
3f4b0d6113 userspace reboot: stop post-data services and wait for them to be killed
* Refactored code around stopping services a little bit to reuse it
  between full reboot and userspace reboot.
* Add a scope_guard to fallback to full reboot in case userspace reboot
  fails.
* In case of userspace reboot init will also wait for services to be
  terminated/killed and log the ones that didn't react to
  SIGTERM/SIGKILL in time.
* If some of the services didn't react to SIGKILL, fail userspace reboot.

Test: adb reboot userspace
Bug: 135984674
Change-Id: I820c7bc406169333b0f929f0eea028d8384eb2ac
2019-10-10 18:13:42 +01:00
Tom Cherry
a41b154c3c Merge "liblog: use packed structs instead of raw unaligned reads"
am: cad2fc2429

Change-Id: I71f8c128207bf6690e94f5845f0cf98771000bd9
2019-10-10 07:03:07 -07:00
Greg Kaiser
5670fabb94 lmkd: Remove unnecessary conditional
We want poll_handler to be handler_info, so it's more efficient
to just unconditionally assign it.

Test: TreeHugger
Change-Id: I55b5164da1817ef77b5d455eb618f9a2471afc5c
2019-10-10 06:52:23 -07:00
Tom Cherry
cad2fc2429 Merge "liblog: use packed structs instead of raw unaligned reads" 2019-10-10 13:46:54 +00:00
Tom Cherry
bbbf089137 liblog: use packed structs instead of raw unaligned reads
Per jmgao@, we still need to worry about unaligned integer accesses.

In any case, we already have the packed structs for all of the
unaligned data that we're reading, so this change favors using those
packed structs.

Bug: 142256213
Test: x86,arm32,arm64 liblog-unit-tests
Change-Id: I21fc629eac49895d03b5b31daa4cc494b0c4c230
2019-10-09 18:20:49 -07:00
Suren Baghdasaryan
e8f1468b14 libmeminfo: Report VMA flags in showmap report
Add VMA flags into showmap report so that we can distinguish different
sections of an executable or a library.

Bug: 138148041
Test: showmap -v <PID>
Change-Id: Ic1a13accbea447548c75a0c54d750280e40c6de8
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-10-09 16:18:18 -07:00
Suren Baghdasaryan
bee72d2abb Merge "lmkd: Track processes using pidfds"
am: d11c6f7fd8

Change-Id: I7cf396167954f51d3c7a092b5eebc54826f69f88
2019-10-09 11:13:15 -07:00
Suren Baghdasaryan
d11c6f7fd8 Merge "lmkd: Track processes using pidfds" 2019-10-09 17:46:14 +00:00
Hridya Valsaraju
9000ddccfc Merge "Export ion_4.12.h and ion_4.19.h"
am: 524dc3f8ef

Change-Id: Id3c5d84e61db4db3c70dff4822b5cc4805ddaad3
2019-10-09 10:06:38 -07:00
Hridya Valsaraju
524dc3f8ef Merge "Export ion_4.12.h and ion_4.19.h" 2019-10-09 16:58:32 +00:00
Suren Baghdasaryan
c06d551848 Merge "lmkd: Add support for process death notifications"
am: 530098cebc

Change-Id: I9316ebe6e9b8497f2a34dfb5a6423e216a73811f
2019-10-09 09:47:08 -07:00
Suren Baghdasaryan
530098cebc Merge "lmkd: Add support for process death notifications" 2019-10-09 16:18:40 +00:00
Daichi Hirono
446e8a8133 Merge "Add a link from runtime ns to the neuralnetworks ns"
am: b18dc5d287

Change-Id: If606607fd6bae18483212b35da0ec989b0e9b8c2
2019-10-09 08:26:48 -07:00
Tom Cherry
a66512dd6f Merge "liblog: remove alarm in logd_reader.cpp"
am: e3fc9ac7e3

Change-Id: I9708f7b1e84820b1bbf230a8fb5eeea3e88699f0
2019-10-09 08:20:46 -07:00
Treehugger Robot
b18dc5d287 Merge "Add a link from runtime ns to the neuralnetworks ns" 2019-10-09 15:20:03 +00:00
Tom Cherry
e3fc9ac7e3 Merge "liblog: remove alarm in logd_reader.cpp" 2019-10-09 14:48:38 +00:00
Orion Hodson
60239d2069 Move libnative{bridge,loader} to art/
Bug: 137364733
Test: m
Change-Id: I8fc0796745f7310f477fe9f8b0821586742dd9c0
2019-10-09 13:32:35 +01:00
Martin Stjernholm
79a4720e47 Merge "Continue without DEX support if libdexfile_external.so fails to load."
am: 58ee7e3ae1

Change-Id: I59da83cbc2d6cb747498d6c623b86aad10d1bfe3
2019-10-09 05:19:26 -07:00
Martin Stjernholm
58ee7e3ae1 Merge "Continue without DEX support if libdexfile_external.so fails to load." 2019-10-09 12:06:07 +00:00
Orion Hodson
20cc17ba74 Merge "Prepare for libnative{bridge,loader} moving to art/"
am: 2a46301b48

Change-Id: Iafc1d91efdc1fa12ac6b4ffb16cba1cfc346e6fa
2019-10-09 00:56:52 -07:00
Daichi Hirono
e76c0d2816 Add a link from runtime ns to the neuralnetworks ns
libneuralnetworks.so could be preloaded. In that case, it should be
accessible from libnativeloader which runs in the art namespace.

Bug: 141847343
Bug: 142089311
Test: m, cheets2 boots
Change-Id: I8710b624dff131f5cb797d53915f6597e3017c34
2019-10-09 07:43:52 +00:00
Treehugger Robot
2a46301b48 Merge "Prepare for libnative{bridge,loader} moving to art/" 2019-10-09 07:43:46 +00:00
Hridya Valsaraju
f142c4dd41 Export ion_4.12.h and ion_4.19.h
Also, clean-up duplicate copies of the header files.

Bug: 140916230
Test: make, ./ion-unit-tests
Change-Id: Iab06ba622ab1d50e902ae20411bae73d0b00bbc7
2019-10-08 21:36:03 -07:00
Suren Baghdasaryan
11dc734a06 lmkd: Track processes using pidfds
lmkd uses PIDs to track processes, however occasionally a PID of a process
might be reused without lmkd detecting that. This can happen if originally
registered process crashes, PID numbers wrap around and the same PID gets
reused for a different process. In this situation lmkd might kill a wrong
process. To prevent this issue from occurring lmkd will track processes
using their pidfd. During process registration lmkd calls sys_pidfd_open
and stores returned pidfd with the process record. Returned pidfd will not
be reused until lmkd closes it which happens only after the process is
unregistered. This way lmkd ensures that process identification is unique
and can't be reused.

Bug: 135608568
Test: lmkd_unit_test with and without pidfd kernel support
Change-Id: Ida10ea13905c250e47f792cdd6bd2e65aeaa3709
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-10-08 18:15:34 -07:00
Suren Baghdasaryan
f2081a96be lmkd: Add support for process death notifications
With pidfd polling support lmkd can detect process death without periodic
polling. Implement mechanism to detect kernel pidfd support using
pidfd_open syscall existence as an indicator. Implement the logic to use
pidfd to wait for process death.

Bug: 135608568
Test: lmkd_unit_test with and without pidfd kernel support
Change-Id: Ic6db7e50893534467f5130a7f998b66fb4451272
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-10-08 18:15:12 -07:00
Tom Cherry
5398021b9e liblog: remove alarm in logd_reader.cpp
There is an alarm() call that provides a 30 second timeout in case
logd is unavailable.  The main reason for this is in the case that logd
is crashing, debuggerd is ptrace'ing logd, and tombstoned is
attempting to dump log messages.  In this case, with no other checks
and without this alarm, tombstoned will deadlock when dumping log
messages.

However, tombstoned already has two mechanisms to prevent the above
situation from happening:
1) It checks that the thread name that is is dumping is either logd or
   starts with "logd." and skips dumping logs in this case.
2) It does not dump logs if it is running in process for any process.

Calling alarm() or modifying signal handlers from general purpose
libraries is not recommended either, so without a strong reason to
keep this, this change removes it.

This also shortens the liblog.wrap_mode_blocks test time, since the 30
second issue that it ensures does not happen has been fundamentally
removed.

Test: `kill -8 `pidof logd`` succeeds without delay
Test: liblog, logd unit tests
Change-Id: Id8a40544645d220e49f7ba299201af80a0c44de9
2019-10-08 13:05:55 -07:00
Tom Cherry
036b7c2998 Merge "liblog: remove code checking for fd = 0"
am: 5d7969b58a

Change-Id: I240832dbc14fc8ef10f331d80fc84abd8fcfd820
2019-10-08 12:37:01 -07:00
Tom Cherry
5d7969b58a Merge "liblog: remove code checking for fd = 0" 2019-10-08 19:24:02 +00:00
Martin Stjernholm
9062bb4269 Continue without DEX support if libdexfile_external.so fails to load.
libunwindstack may be used in situations where we cannot guarantee that
libdexfile_external.so is available, e.g. from libc_malloc_debug.so in the
bootstrap Bionic, or in APEXes with incomplete linker configs.

Test: atest libunwindstack_unit_test
Test: atest --host libunwindstack_unit_test
Test: rm -f out/host/linux-x86/lib*/libdexfile_external.so && \
  out/host/linux-x86/nativetest64/libunwindstack_unit_test/libunwindstack_unit_test
  (check that DexFile(s)Test tests fail without abort)
Bug; 139408016
Change-Id: I7eeee77ab363d9d39412ece2038ce786394bb34f
2019-10-08 19:21:45 +01:00
Christopher Ferris
1e93edb93b Merge "Handle when bias is different in elf headers."
am: c48c2afa1e

Change-Id: I77d95e4045d5c1c7dab4bda1797f1a338594334d
2019-10-08 10:56:14 -07:00
Christopher Ferris
c48c2afa1e Merge "Handle when bias is different in elf headers." 2019-10-08 17:41:25 +00:00
Elliott Hughes
33f155046d Merge "init: actually report which signal is causing the reboot."
am: 4d7d903e2b

Change-Id: I930bb03395804e293ceca6e5544018809cdbcc7c
2019-10-08 10:41:19 -07:00
Christopher Ferris
819f13116e Handle when bias is different in elf headers.
The original code assumed that the load bias in the program headers
would be exactly the same as in eh_frame/eh_frame_hdr/debug_frame.

This isn't guaranteed, so add a section bias for use when creating
a DwarfSection. In addtion, make the load bias and section bias
a signed value. There is no reason that this value needs to be positive,
so don't force it to be.

Add a new offline test that has a different load bias in eh_frame than
in the executable load.

Add additional unit tests to verify the load bias values are set properly.

Clean up the tests in ElfInterfaceTest, making all tests names follow the
same convention.

Bug: 141888859
Bug: 142094469

Test: New units and old unit tests pass on host and taimen.
Change-Id: Ib878123ab5545f0f315c749cfe0d27b012d873ee
2019-10-08 17:36:06 +00:00
Tom Cherry
29d0e89364 liblog: remove code checking for fd = 0
Fix a typo where I check socket()'s return value for 0 instead of -1
as an error.

Remove code that checks if socket() returns 0 as the actual fd that it
returns.  This should not happen in any well formed program.

Test: liblog unit tests
Change-Id: I1d878e85d9a39155d68c6c84e9cf9b0db8d1b3a4
2019-10-08 10:18:20 -07:00
Elliott Hughes
4d7d903e2b Merge "init: actually report which signal is causing the reboot." 2019-10-08 17:13:59 +00:00
Orion Hodson
a65f314e17 Prepare for libnative{bridge,loader} moving to art/
Add temporary public visibility for libraries.

Update bpfmt for ART's repohooks.

Bug: 137364733
Test: m nothing
Test: copy libs to art/, create a CL, run repohooks, m nothing.

Change-Id: Ib9a280136e4b992fe17b8943cf404c9c803efb8d
2019-10-08 16:44:44 +01:00
Nikita Ioffe
5e0e30db92 Merge "Add a skeleton of userspace reboot"
am: f1933c910d

Change-Id: I099d8bf703e13dacdb9717be77a3222541f02432
2019-10-08 07:51:16 -07:00
Nick Desaulniers
b71825ebce Merge "[liblog] fix -Wreorder-init-list"
am: 5bbe4a1b26

Change-Id: Ib06905d5e7ba024347322849d262191ba1410cd4
2019-10-08 07:45:30 -07:00
Nikita Ioffe
f1933c910d Merge "Add a skeleton of userspace reboot" 2019-10-08 14:42:36 +00:00
Treehugger Robot
5bbe4a1b26 Merge "[liblog] fix -Wreorder-init-list" 2019-10-08 14:24:41 +00:00
Nikita Ioffe
ba6968e636 Add a skeleton of userspace reboot
This CL only draws boundaries between userspace and full reboots, and
adds some functionality that will be required for userspace reboot:

* Whenever device is shutting down is now controlled in reboot.cpp,
  since during userspace reboot this state can change.
* Now it's also possible to restart handling of control messages inside
  property service. In case of userspace reboot, init will restart it
  after stopping post-data services.
* New userspace-reboot-requested trigger is added similar to shutdown
  one for full reboot.

Test: adb reboot
Test: adb reboot userspace
Bug: 135984674
Change-Id: Id55a53ba781d2b90ce40449037b6d8d47e72c476
2019-10-08 12:16:06 +01:00
Martin Stjernholm
87041ac24a Merge "Ensure all namespaces have links to /system/lib(64) for the sanitizer libs."
am: c14b27f22d

Change-Id: I59176f2691bd4185b72390883d87afebc10aa344
2019-10-08 04:13:46 -07:00