Commit graph

57061 commits

Author SHA1 Message Date
Tom Cherry
3f67fb8e45 init: fix todo in a test
Structured bindings with templated containers work now, so no need for
the workaround or TODO.

Test: init unit tests
Change-Id: I6a286de9859d8a97df480a7ac2862a3a10bd9fb3
2020-04-10 10:08:24 -07:00
Tom Cherry
ad7d6b210d Revert "logd: iterator corruption paranoia"
This reverts commit 3614a0c5d4.

The original commit was added to check if what should be impossible
cases were happening.  In the years after it was added, it doesn't
appear that these cases have happened.  Recent reverts removed the
commits that caused the paranoia in the first place, making these
cases even more impossible.

Test: logging unit tests
Change-Id: I687c4d7876a38485e940f004dbd5ae6a1e15fb4c
2020-04-10 09:38:51 -07:00
Tom Cherry
7ef143fc84 Merge "liblog: support extended logger_entry headers" 2020-04-10 15:18:03 +00:00
Yurii Zubrytskyi
6fc26dff7c [adb] Don't copy features set on each get()
The features are already cached in a static and don't change.
Let's return the cached set instead of copying it every time.

Bug: 150183149
Test: manual
Change-Id: Ifdca852cc3b32e09e50ea4771f7878987c46cce8
2020-04-09 22:26:48 -07:00
Yurii Zubrytskyi
83c7ad22a1 Merge "[zip] Stop calculating crc if it's not checked" 2020-04-10 05:07:30 +00:00
Jiyong Park
49c52979ba Merge changes I8fd2a3c9,Id08058f3
* changes:
  Set apex_available property
  Set apex_available property
2020-04-10 01:14:55 +00:00
Tom Cherry
d3ecc66b9c liblog: support extended logger_entry headers
logger_entry has a hdr_size field meant for backwards compatibility,
however there are a few checks that expect it to be a specific size.
More problematically, it has a variable length array element, msg[0]
at the end, that would be incorrect if the header size was not kept
static.

This change fixes up those issues to facilitate future additions.

Bug: 119867234
Test: logging works with extended size headers, logging unit tests
Test: newly added unit tests with extended size header
Change-Id: I14b2b0855d219d11f374b53a5aa8e05cd6a65eef
2020-04-09 15:48:44 -07:00
Steven Moreland
90540ad53a Merge "Note selinux trans error happens in permissive." 2020-04-09 21:52:08 +00:00
Yifan Hong
559270448d Merge "BatteryMonitor: report current_now in uA" 2020-04-09 21:40:01 +00:00
Steven Moreland
9e987cbb1a Note selinux trans error happens in permissive.
There was an email thread about this recently, and I've been asked many
times.

For instance, if this error wasn't attributed, denials a service is
hitting would be attributed to init, and that's a recipe for disaster.
Secondarily, thinking about SELinux whenever you write a new service is
good.

Bug: N/A
Test: N/A
Change-Id: Ib9d2c5d8947375a0d4c33ecf3d075caef6b41f70
2020-04-09 12:48:46 -07:00
Tom Cherry
56cd920ff8 Merge changes If1a62a90,Ibce79cf1,Ia2bbf01a,I1763be56,I56762747, ...
* changes:
  logd: don't send logs before the start time on the first flushTo()
  Revert "logd: drop mSequence from LogBufferElement"
  Revert "logd: regression in handling watermark boundary."
  Revert "logd: logcat --clear respect pruneMargin"
  logd: wait for timeout via CLOCK_MONOTONIC
  Revert "logd: wakeup wrap timeout if realtime changes drastically"
  logd: do not attempt to sort log messages by time
2020-04-09 17:24:12 +00:00
Tom Cherry
65ab7fed70 logd: don't send logs before the start time on the first flushTo()
Logs in logd's buffer are not in time order.

If a client connects and requests logs from a given timestamp, we
start at the beginning of the buffer and find the first entry that has
happened since that timestamp and use its sequence number to flush
logs from.  This ensures that we get all logs accumulated in the
buffer since that time stamp and not just the most recent.

However there may be other logs in the buffer that happened before the
timestamp and have likely been already served to the client, therefore
we do not flush those.

We only do this for the first flush, since once we have flushed all of
the logs in the buffer, if another log comes in with a timestamp
earlier than the requested timestamp, it must be out of order and not
seen yet, since it is new even to logd.

Note! This is still broken.  There is a race that logs before the
timestamp may come in out of order since the last time the client
disconnected and before it reconnects.  The *only* solution to this
problem is that clients need to request logs after a given sequence
number.  That will be done as a separate liblog API change, while
these changes put in the ground work to make that possible.

Note 2: the security log implementation, which is one of the most
important users of this, already captures logs from seconds before the
last previous log to work around issues with timestamps.  That
workaround mitigates the above issue.

Test: logs work with logcat -t
Change-Id: If1a62a90c082d98c4cf2eb5c92ae3b7e89850cf2
2020-04-09 17:23:52 +00:00
Tom Cherry
10d086e26e Revert "logd: drop mSequence from LogBufferElement"
This reverts commit 5a34d6ea43.

There is a long standing bug that logd will leak memory during its
prune process if the time on the device changes significantly forwards
then backwards.  This is due to using the timestamp of each log
message to determine what log messages are yet to be processed by a
reader thread.

Various attempts have been made to rectify this, but the only solution
that safely fixes this issue is to go back to using sequence numbers
on the log messages.

Bug: 64675203
Bug: 77971811
Bug: 149340579
Bug: 150923384
Test: logcat output looks sane
Change-Id: Ibce79cf184eb29a4914f3e42a8cb2868d04dc165
2020-04-09 17:23:45 +00:00
Tom Cherry
7514558b81 Revert "logd: regression in handling watermark boundary."
This reverts commit 5836379b21.

Bug: 149340579
Test: logcat output looks sane
Change-Id: Ia2bbf01a20fec59b989d206a089d8e65062816ef
2020-04-09 17:23:34 +00:00
Tom Cherry
5e2665500f Revert "logd: logcat --clear respect pruneMargin"
This reverts commit 0878a7c167.

This is a partial revert of the above commit.  It simply removes
pruneMargin from these calculations since it is going away.

Bug: 149340579
Test: --clear works well
Change-Id: I1763be56fae7052058a800fad3b295c73cdcadf6
2020-04-09 17:22:25 +00:00
Steven Moreland
1ec8c39c3f Merge "init_kill_services_test: reboot device first." 2020-04-09 00:23:20 +00:00
Yifan Hong
e5bd5f914f BatteryMonitor: report current_now in uA
/sys/class/power_supply/*/current_now should return uA and the HAL
expects uA too.

Test: VtsHalHealthV2_0TargetTest
Bug: 136717180
Change-Id: I675be1ae645413b9494af4a5d49955aad5bd4f2e
2020-04-08 16:24:17 -07:00
Yurii Zubrytskyi
8d8f637ee5 [zip] Stop calculating crc if it's not checked
Crc calculation shows up in the profiler in 2-5% range, and is
never currently validated. Let's disable it for good.
For a well-compressible test data the difference is even nicer:

Benchmark                       Time          CPU        Iteration
------------------------------------------------------------------
ziparchive-benchmarks:
before:
  #ExtractEntry/2            1943244 ns    1926758 ns          375
  #ExtractEntry/16           1877295 ns    1867049 ns          375
  #ExtractEntry/1024         1888772 ns    1879976 ns          373
after:
  #ExtractEntry/2             817003 ns     812870 ns          874
  #ExtractEntry/16            814029 ns     809813 ns          875
  #ExtractEntry/1024          804904 ns     800972 ns          879

Bug: 153392568
Test: atest, manual
Change-Id: I917abecab01301f1d09a5bf3b542d24b3875e359
2020-04-08 13:55:54 -07:00
Steven Moreland
32876f356d init_kill_services_test: reboot device first.
This test is killing critical device services, and if it runs
repeatedly or some of the critical services have already died, it'll
force the device to reboot again and potentially consider the test a
failure.

This forces the test to reboot first, so that it is in a fresh state and
we can avoid this type of flake on the device.

Bug: 153444614
Test: atest init_kill_services_test
Change-Id: Ia81a319af1d209f58e70f824bb8eb7f11973637c
2020-04-08 20:23:18 +00:00
Christopher Ferris
e1948bf744 Merge "Avoid re-mapping dex file that's in local memory." 2020-04-08 19:27:25 +00:00
Tom Cherry
c9fa42c0b8 logd: wait for timeout via CLOCK_MONOTONIC
There are well known issues with CLOCK_REALTIME jumping drastically.

Test: --wrap works successfully
Change-Id: I5676274783ac9aa9374d2b9254e0109d883cc5a8
2020-04-08 12:20:06 -07:00
Tom Cherry
cda0ee3db0 Revert "logd: wakeup wrap timeout if realtime changes drastically"
This reverts commit 5e001776f4.

The next commit will use CLOCK_MONOTONIC for the timeout, so changes
to CLOCK_REALTIME will no longer be an issue.

Test: logcat output looks sane
Change-Id: I84e5b2db3c25ea6a7024557dba7fa6cc8c9237e5
2020-04-08 12:14:08 -07:00
Treehugger Robot
51abcc5633 Merge "first_stage_init: load modules in modules.load.recovery in recovery" 2020-04-08 17:41:09 +00:00
Tom Cherry
65abf3953e logd: do not attempt to sort log messages by time
Sorting does not work in all cases:
* It only sorts messages up to 5 seconds backwards in time
* CLOCK_REALTIME, which is used as the time that is sorted, can jump
  drastically
* Buffers are not sorted if there is a reader holding a region lock

Removing sorting entirely will give more consistent behavior from
logd.

Test: logcat still seems sane
Change-Id: I0923ab2fb377cda941c1e4972689df46f395ac99
2020-04-08 10:31:29 -07:00
Jiyong Park
937b4bf173 Set apex_available property
The marked library(ies) were available to the APEXes via the
hand-written whitelist in build/soong/apex/apex.go. Trying to remove the
whitelist by adding apex_available property to the Android.bp of the
libraries.

Bug: 150999716
Test: m
Change-Id: I8fd2a3c9b69454c6018c72f5198898bc90dc4d0d
2020-04-08 23:49:40 +09:00
Jiyong Park
e3d371e319 Set apex_available property
The marked library(ies) were available to the APEXes via the
hand-written whitelist in build/soong/apex/apex.go. Trying to remove the
whitelist by adding apex_available property to the Android.bp of the
libraries.

Bug: 150999716
Test: m
Change-Id: Id08058f3105463558c6c82298344a33af0efb2d3
2020-04-08 22:37:42 +09:00
Treehugger Robot
51de894ce4 Merge "Allow ExtractToMemory to accept an empty buffer for empty entries" 2020-04-08 04:06:41 +00:00
Sim Sun
273d3f08aa Avoid re-mapping dex file that's in local memory.
If the Dex file we're trying to examine is already within the unwinder's
address space, we don't need to load it from disk or copy it across
processes.

This avoids using up virtual address space to map in dex files, and
also should be a bit faster to read since it won't go out to the file.

Patch by Chris Sarbora

Test: Ran new unit tests.
Test: Ran 137-cfi art test.
Change-Id: I949457856f051cca11b9020e9da3a41bbf6e5c8e
2020-04-07 18:07:38 -07:00
Josh Gao
89cce05891 Merge changes from topic "adbd_lz4"
* changes:
  adb: add dry-run option to push/sync.
  adb: implement LZ4 compression.
  adb: fix use of wrong union variant.
  adb: fix front_size, front_data.
  adb: add interfaces for Encoder/Decoder.
2020-04-07 21:30:30 +00:00
Josh Gao
edd7771583 Merge "adb: add option to disable kill-server." 2020-04-07 20:36:47 +00:00
Elliott Hughes
a0c191867f Merge "Add missing static for macOS inline." 2020-04-07 19:43:29 +00:00
Tianjie
088c403e23 Allow ExtractToMemory to accept an empty buffer for empty entries
We don't actually need to extract the empty entries. Since the old
code support extracting the empty entry to a empty buffer, add the
support back in ExtractToMemory.

Bug: 153393683
Test: unittests pass

Change-Id: Idb9f0f4e6e4ffd4b44b80ddd3f54069bb7cedd7b
2020-04-07 12:25:16 -07:00
Nikita Ioffe
9cd3c84dc1 Merge "Manually unmount /data_mirror mounts in the right order" 2020-04-07 17:34:52 +00:00
Nikita Ioffe
bf66f433d6 Manually unmount /data_mirror mounts in the right order
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 152823078
Change-Id: I57ff9182807630d8cbcf3ca6374fdd6dc6379da5
2020-04-07 15:43:10 +00:00
Nikita Ioffe
74429fc121 Merge "get_mounted_entry_for_userdata: Realpath block devices from fstabs" 2020-04-07 12:01:29 +00:00
Josh Gao
20f079ec66 Merge "Revert "Reland "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor""" 2020-04-07 11:08:00 +00:00
Treehugger Robot
edf8335c72 Merge "Rename vts-core to vts" 2020-04-07 05:11:55 +00:00
Paul Crowley
1b1ec8f36a Merge "Abolish DmTargetDefaultKey::IsLegacy" 2020-04-07 03:23:57 +00:00
Dan Shi
ab8acaedae Rename vts-core to vts
Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL moves all tests in vts-core to vts.
It won't change test logic or behavior.

Change-Id: I24779951257ce37fc18929f214d3cf5f76c23a19
Merged-In: I24779951257ce37fc18929f214d3cf5f76c23a19
2020-04-07 02:48:48 +00:00
Josh Gao
9026a44bb3 Revert "Reland "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor""
This reverts commit bfe3dac36d.

This seems to be correlated with an increase in the rate of devices
going offline. Revert it to see if failure rates improve.

Bug: http://b/150863651
Test: treehugger
Change-Id: Ia6163fd9e31d2bf812628e028249662594ac2024
2020-04-06 16:49:01 -07:00
Nikita Ioffe
7aa37f1f21 get_mounted_entry_for_userdata: Realpath block devices from fstabs
Use realpath as a canonical representation of block devices. This makes
it easier to reason about block devices. This also fixes a bug, in which
fs_mgr_get_mounted_entry_for_userdata didn't properly work on devices
that don't support metadata encryption.

Test: atest CtsFsMgrTestCases
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 153363818
Change-Id: I139c2be46336a632bbaee86667019c075d7de814
2020-04-07 00:39:19 +01:00
Josh Gao
ba6d1da8ea adb: add option to disable kill-server.
In the post-apocalypse, it's increasingly common for people to use ssh
port forwarding to use an adb client with a remote adb server. This
results in `adb kill-server` being catastrophic, because the client has
no way of restarting the server on the other end. Android Studio in
particular has an unforunate habit of trying to manage adb's life cycle
such that starting or exiting Studio will result in a kill-server.

Add the ADB_REJECT_KILL_SERVER environment variable which ignores
kill-server, to make this scenario a bit better.

Bug: http://b/152251952
Test: ADB_REJECT_KILL_SERVER=1 adb start-server; adb kill-server
Change-Id: I5533a6dcbdb9220526a6fcf9ca31d9fcef1cec17
2020-04-06 14:33:14 -07:00
Dan Shi
45efd5a27b Merge "Remove vts10 tests from vts suite" 2020-04-06 21:24:46 +00:00
Steve Muckle
4c59323dc6 first_stage_init: load modules in modules.load.recovery in recovery
In recovery mode, load modules from modules.load.recovery if it
exists. Otherwise load from modules.load as usual.

Change-Id: I7636bb5958ed10ae9a66015f04f168129618272f
2020-04-06 12:24:16 -07:00
Elliott Hughes
681338dfb6 Add missing static for macOS inline.
Also switch to #pragma once and s/__inline__/inline/g for consistency.

There are a handful of inlines that are missing static, which seems like
a bug, but I've left those for now.

Bug: http://b/153328340
Test: treehugger
Change-Id: I2353215c0a8a6154ce8b39ecde022b282f5c0cb9
2020-04-06 09:17:08 -07:00
Paul Crowley
539b98fb58 Abolish DmTargetDefaultKey::IsLegacy
To make it easier to support disk formats created using old versions
of dm-default-key with new kernels, stop checking the kernel module
version; instead, the caller decides whether to use the old or new
options format.

Bug: 150761030
Test: crosshatch and cuttlefish boot normally; cuttlefish
    fails with "default-key: Not enough arguments" as expected when
    option is set to 1
Change-Id: I810bb7e085b9b8648858de1a02165162d1fd163e
2020-04-05 19:51:14 -07:00
Tianjie Xu
148f7af18a Merge "Allow parsing zip entries larger than 4GiB" 2020-04-04 20:00:20 +00:00
Tom Cherry
3fc16fed7e Merge "liblog: include all structures in README.protocol.md" 2020-04-03 23:52:26 +00:00
Yifan Hong
0dba184ac0 Merge "libsnapshot: Add VTS10 VtsLibsnapshotTest" 2020-04-03 23:37:05 +00:00
Tom Cherry
97deb299df liblog: include all structures in README.protocol.md
We are stating that these structures will be stable, so include them
in the documentation directly.

Bug: 152466437
Test: n/a
Change-Id: I52a05f61163aa35b99869d722284ff3f98d7f010
2020-04-03 14:34:58 -07:00