Commit graph

56836 commits

Author SHA1 Message Date
Yifan Hong
f9e1e16377 libsnapshot: Add allow-forward-merge indicator.
The indicator signals that on factory data reset, initiating
merge is allowed.

Test: vts_libsnapshot_test
Test: apply downgrade update
Test: apply update with FDR
Bug: 152094219
Change-Id: Ieecddd198136571dd652ca62c27fe65a12b7b15f
2020-03-26 14:56:11 -07:00
Yifan Hong
a4f9b07490 libsnapshot: Fix DataWipeAfterRollback test
Test: run it
Bug: 152094219
Change-Id: I06852d7a0514481cbeed3ef66192ba49a24cb54b
2020-03-26 14:56:11 -07:00
David Anderson
533b2b6296 libsnapshot: Fix intermittent test failure due to missing null check.
Bug: 152547190
Test: vts_snapshot_test
Change-Id: If7adc4fba61325e52d6268531ce0a15b00c0a380
2020-03-26 14:56:11 -07:00
Songchun Fan
89650f9692 Merge "[libziparchive] add an option to start iteration with functor" 2020-03-24 19:55:59 +00:00
David Anderson
b80b654b1b Merge "init: Factor out first-stage uevent handling into a separate class." 2020-03-24 18:19:15 +00:00
Songchun Fan
c33f5260ea [libziparchive] add an option to start iteration with functor
To reduce the seeks for local file headers in large APK files, we can
specify entry prefix/suffix when we call StartIteration(). However,
some use cases need additional name matches that is outside the
prefix/suffix matches.

Adding a new option to StartIteration, which allows additional functor
that restricts the iteration to customized name matching schemes.

Test: atest ziparchive-tests
BUG: 151676293
Change-Id: Iff45e083b334602f183c05cb39ba521e7070252c
2020-03-24 10:16:49 -07:00
David Anderson
4117559746 init: Factor out first-stage uevent handling into a separate class.
This will make it possible to re-use in second-stage init.

Bug: 150315914
Test: first-stage init boots
Change-Id: I6a0f13d5c71ab5529a76751f68ac0f15834323d1
2020-03-23 18:49:51 -07:00
Tianjie Xu
18c00858d2 Merge "Add definition for zip64 struct" 2020-03-24 01:21:09 +00:00
Tom Cherry
746012571b Merge "Skip pmsg related tests if /dev/pmsg0 is not found" 2020-03-23 21:58:07 +00:00
Martin Stjernholm
6d4e47a165 Merge "Remove use of static libdexfile to avoid linking in ART internal code." 2020-03-23 20:15:14 +00:00
Tom Cherry
986bd0c7c8 Skip pmsg related tests if /dev/pmsg0 is not found
These test use fopen() with append which includes O_CREAT.  If these
tests are run in the 'su' SELinux domain (aka through `adb root`) then
they'll create a blank text file when opening /dev/pmsg0 if it does
not exist.  Other tests and processes will attempt to write to this
file, either succeeding (for 'su' domain processes) and wasting memory,
or failing due to SELinux and generating audits (for typical
processes).

This isn't a problem for user builds, since without `adb root`, the
tests simply fail when pmsg0 does not exist.

Test: no excess denials or /dev/pmsg0 creation when running
      liblog-unit-tests as root
Change-Id: I06e0f308c72db5a53c5f9e4a29bd23f56352c7e2
2020-03-23 13:15:05 -07:00
Yifan Hong
548101de29 Merge "libsnapshot: Add RecoveryCreateSnapshotDevices(device)" 2020-03-23 19:49:58 +00:00
David Anderson
0053acd11c Merge "init: Remove special-case hacks for the super partition." 2020-03-23 19:19:22 +00:00
Christopher Ferris
a010ddbb88 Merge "Fix memory leak of DexFile handle after release" 2020-03-23 18:20:00 +00:00
Anna Trostanetski
447a1ead21 Merge "Revert "Set apex_available property"" 2020-03-23 14:14:32 +00:00
Anna Trostanetski
56a712f6c9 Revert "Set apex_available property"
This reverts commit d25bb60e05.

Reason for revert: Breaks build_test b/152190149
Bug: 152190149

Change-Id: I6b7cb4aa4fc07fae648bcf4d9e8f60ea1c62fd9e
2020-03-23 12:02:53 +00:00
Jiyong Park
fb0b0d24f2 Merge "Set apex_available property" 2020-03-23 10:51:28 +00:00
Jiyong Park
d25bb60e05 Set apex_available property
The marked library(ies) were available to the adbd APEX 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.

Exempt-From-Owner-Approval: already +2'ed by the owner (enh)

Bug: 150999716
Bug: 151398197
Test: m
Change-Id: I8b572e3c4e76bd10c0443a6c08b72e9519243ab5
2020-03-23 10:50:12 +00:00
Treehugger Robot
4abafe2230 Merge "adb: fix sync." 2020-03-23 06:06:25 +00:00
Treehugger Robot
c549b122f4 Merge "adb: extract syncmsg structs." 2020-03-23 06:01:26 +00:00
Josh Gao
672cdfeeff adb: fix sync.
adbd's file sync service doesn't handle a full socket gracefully,
immediately terminating the service as soon as it fails to write a
response. This would generally be fine if the socket's buffer were as
large as it claims (212992 by default with a 64-bit kernel), but this
buffer size is a giant lie, as each write has 576 bytes of overhead
that's used up in the send buffer. When setting the send buffer size,
the kernel helpfully doubles the value to attempt to account for the
overhead, but when writing 8 byte responses, only 2% of the buffer
actually gets used for responses, so we run out of buffer after 364
files instead of the 26624 that would be expected.

Fix this by processing the responses as they become available, and
calculate a maximum limit to how many sends we dispatch before we stop
and wait for responses to come in.

Test: manually modified adbd to respond with giant error messages, and
      modified adb to not read responses until we choose to block
Change-Id: Ieb8c935662864211e2fd16c337ffed0992990086
2020-03-21 20:06:39 -07:00
Tianjie Xu
69ee4b70c8 Add definition for zip64 struct
Add the definition of zip64 related structs. Also add place holders in
the zip parsing code. In addition, this cl changes the variable type of
num of entries to uint64_t. The number was capped at UINT16_MAX in zip32
format.

Bug: 150900468
Test: unit tests pass
Change-Id: I51a39e7b993fa376e0d050a04b8d39abae8a9e15
2020-03-20 22:23:57 -07:00
David Anderson
b78a632ab7 init: Remove special-case hacks for the super partition.
Rather than special-casing super in the uevent listener, call Realpath()
after we've generated its symlink. This allows us to generalize the
uevent listener code.

Also, rename "metadata partition" to "super partition" in a few places,
as this terminology is a bit dated.

Bug: 150315914
Test: first-stage init boots
Change-Id: I2bf3bebf3360f097582df7fba95f3c1753feb2e2
2020-03-20 19:48:46 -07:00
Peter Collingbourne
fffdd1ab1a Merge "Make GetPcAdjustment a free function." 2020-03-21 00:18:54 +00:00
Yong Li
489c3a8b35 Fix memory leak of DexFile handle after release
The DexFile handle is allocated from heap in OpenFromFd/OpenFromMemory.
After releasing the unique_ptr, the DexFile handle itself is no longer
managed by the smart pointer. However, the DexFile handle is not freed
in the constructor of DexFileFromFile/DexFileFromMemory.

This change uses get() method to get the DexFile pointer while allowing
it to be managed by smart pointer so that it can be freed after method
end.

Added new unit tests to detect leaks.

Bug: 151966190

Test: Unwinding can still retrieve dex frame information during crash.
Test: Ran new unit tests before change and verified they fail, ran them
Test: after the change and verified they don't fail.

Signed-off-by: Yong Li <yongl0722@gmail.com>
Change-Id: I0627e1e255eb6644aba51e940c1a79ff78d568d7
2020-03-20 16:46:11 -07:00
Yifan Hong
fc449eb1d5 libsnapshot: Add RecoveryCreateSnapshotDevices(device)
... that doesn't auto mount/umount /metadata.

Test: builds
Bug: 151983957
Change-Id: If525a82c1635ddef221e7be20763bc2f27d3c417
2020-03-20 15:10:45 -07:00
Tom Cherry
321151247c Merge "init: add ctl.oneshot_on/ctl.oneshot_off" 2020-03-20 20:57:18 +00:00
Josh Gao
448519736b Merge "adbd: add apex_available and visibility for internal libs." 2020-03-20 09:58:23 +00:00
Peter Collingbourne
5ac3927878 Make GetPcAdjustment a free function.
We're now using it in contexts that don't have all of the registers available,
such as GWP-ASan and soon MTE, so it doesn't make sense to have it be a
member function of Regs.

Bug: 135772972
Change-Id: I18b104ea0adb78588d7e475d0624cefc701ba52c
2020-03-19 17:51:20 -07:00
Josh Gao
eddae92928 adb: extract syncmsg structs.
Make it so that we can get the sizeof a member of syncmsg without having
an instance of syncmsg or doing something awful along the lines of
sizeof(reinterpret_cast<syncmsg*>(nullptr)->status).

Test: m adb adbd
Change-Id: I4830e7f90033c7706ff52cdd8d13e9cf40c73628
2020-03-19 17:24:15 -07:00
Martin Stjernholm
a2cc893044 Remove use of static libdexfile to avoid linking in ART internal code.
- Create a static library libunwindstack_no_dex without DEX support.
- Use it in libdebuggerd_handler_fallback, whose only use is in the
  linker, which shouldn't need that support.
- Use it in init_first_stage, which doesn't need DEX support either.
- Also need a libbacktrace_no_dex since it's in the dependency chain
  from init_first_stage to libunwindstack_no_dex.

Also restrict the *_no_dex libs and libdebuggerd_handler_fallback as
much as possible to avoid inadvertent use of these reduced
functionality libs.

Test: m init_first_stage on Cuttlefish
  where BOARD_BUILD_SYSTEM_ROOT_IMAGE=false
Test: m system_image com.android.runtime
Test: Build & boot
Test: atest linker-unit-tests libunwindstack_unit_test debuggerd_test
Bug: 142944931
Bug: 151466650
Change-Id: Iaacb29bfe602f3ca12a00a712e2a64c45ff0118b
2020-03-19 22:23:54 +00:00
Tom Cherry
bdbf5047c9 init: add ctl.oneshot_on/ctl.oneshot_off
Some services are lazy HALs on some platforms and not lazy HALs on
others; this is known at runtime by hwservicemanager, so this change
adds these properties to allow hwservicemanager to turn one oneshot
(for lazy HALs).  It may also be required to make a lazy HAL not lazy
anymore, and oneshot_off is provided for this.

Bug: 147841742
Test: new unit test that turn on and off oneshot on a service (bootanim)
      and observes that it follows the expected behavior
Change-Id: I79524e2c9a5008f90c8d3bc40920fde00602a439
2020-03-19 12:54:25 -07:00
Treehugger Robot
3ab681c9a8 Merge "fastboot: add support for v3 boot header format" 2020-03-19 05:47:48 +00:00
Kazuhiro Inaba
f98ee05a17 Merge "healthd: Don't take device-scoped battery as the main system battery." 2020-03-19 04:40:01 +00:00
Josh Gao
b567303330 adbd: add apex_available and visibility for internal libs.
abb links against libadbd_core for the shell protocol, and must be
on the system image because it links against cmd, so let's just
expose it to abb for now.

Bug: http://b/151398197
Test: treehugger
Change-Id: Id926bc4324d3259def21ea19d3bd72320311a6e3
2020-03-18 18:36:01 -07:00
Ryan Mitchell
ed22a0aa70 Merge "Allow loading zip at an offset in fd" 2020-03-18 23:00:52 +00:00
Steve Muckle
15303f2f67 fastboot: add support for v3 boot header format
Support v3 header format when changing the command line with
fastboot boot or using flash:raw.

Bug: 151750405
Test: fastboot boot and flash:raw with updated cmdline and v3 header
Change-Id: Ibf396e2d18d8b22cad50db290f3fd4e46ff85d9b
2020-03-18 15:00:47 -07:00
Ryan Mitchell
23150e4fe4 Allow loading zip at an offset in fd
To allow the ResourcesLoader API to load part of a file as an APK
that contains resources, an additional override of OpenArchiveFd
that contains read offset and length as parameters must be created.

This functionality allows for an APK stored in a zip file to be read
without having to write the APK to disk.

Bug: 142716192
Test: atest FrameworksResourceLoaderTests
Change-Id: I772fc8b462d71de0529717c420ced552103a6e3f
Merged-In: I772fc8b462d71de0529717c420ced552103a6e3f
2020-03-18 20:46:50 +00:00
Tom Cherry
b33afa9d8d Merge "storaged: ignore SIGPIPE" 2020-03-18 18:50:57 +00:00
Treehugger Robot
cdb6003784 Merge "base: dlopen/dlsym for liblog when SDK_VER <= 29" 2020-03-18 16:05:54 +00:00
Jooyung Han
2d954136fa base: dlopen/dlsym for liblog when SDK_VER <= 29
libbase doesn't have to rely on dlopen/dlsym to use liblog's new symbols
when it is built for __ANDROID_SDK_VERSION__ > 29.

Bug: 150860940
Test: TARGET_BUILD_APPS="com.android.adbd com.android.resolv" m
      objdump -T ...shared_com.android.resolv/libbase.so | grep LIBLOG_R
        => should be none because resolv apex is targeting 29
      objdump -T ...shared_com.android.adbd/libbase.so | grep LIBLOG_R
        => should list all new symbols because adbd apex is targeting R
      objdump -T ...shared/libbase.so | grep LIBLOG_R
        => should list all new symbols

Merged-In: I7f7f16510d7637cd380fe35ea9ff3e804f38851d
Change-Id: I7f7f16510d7637cd380fe35ea9ff3e804f38851d
(cherry picked from commit 22207e6590)
2020-03-18 17:42:41 +09:00
Treehugger Robot
b962d6bee5 Merge "libziparchive: move the array of error strings into the implementation." 2020-03-17 23:25:45 +00:00
Elliott Hughes
bda268636a libziparchive: move the array of error strings into the implementation.
Test: treehugger
Change-Id: Iaffc29f77912d268c3335b74eb712a58914ce945
2020-03-17 14:10:59 -07:00
Steven Moreland
df78c43412 Merge "init: init_kill_services_test" 2020-03-17 20:30:49 +00:00
Tianjie Xu
780528e86b Merge "Move the implementation of cd entry map to a separate file" 2020-03-17 19:00:36 +00:00
Tianjie Xu
f496d286c6 Merge "Add std::map implementation for cd entry map" 2020-03-17 19:00:23 +00:00
Steven Moreland
6cce3f7f90 init: init_kill_services_test
Kill processes and make sure the phone recovers. This adds a basic level
of testing, but it could be improved by:
- trying to kill all running processes on the device
- improving metrics for 'recovery'

Bug: 148236233
Test: init_kill_services_test
Change-Id: I8aaca7bf4bb0be588decf741d1f6e1c5787cea84
2020-03-17 10:58:02 -07:00
Tom Cherry
3f3b1708d9 storaged: ignore SIGPIPE
It is possible for storaged to terminate due to SIGPIPE if its clients
have terminated.  This is not a fatal condition from storaged's
perspective, so we ignore SIGPIPE instead.

Bug: 151581751
Test: build
Change-Id: I633780ed20908be02e5e1dea9504e140932afc8c
2020-03-17 09:31:01 -07:00
Tianjie Xu
323c09c3d0 Move the implementation of cd entry map to a separate file
Move the entry map classes to a separate file to make the hierarchy
clear.

Test: unittests pass
Change-Id: Ie01d7835359daa4f59af75a0eda204c696d5658e
2020-03-16 17:43:49 -07:00
David Anderson
8a178c184f Merge "init: Fix restorecon for /metadata." 2020-03-16 23:40:16 +00:00