Commit graph

58451 commits

Author SHA1 Message Date
Yo Chiang
5b028bab2a Move SingletonTest back to libutils_test
Use the new "data_libs:" to specify test library dependency. This is
like "data:" and it treats compiled libraries as test data files.
The result is libutils_test_singleton{1,2} is picked up by libutils_test
and installed next to the test binary.

Mark the test libs libutils_test_singleton{1,2} as uninstallable. This
prevents installing libutils_test_singleton{1,2} directly and only
permits installing via "data_libs:".

```
$ m libutils_test
testcases
└── libutils_test
    ├── arm
    │   ├── libutils_test
    │   ├── libutils_test_singleton1.so
    │   └── libutils_test_singleton2.so
    ├── arm64
    │   ├── libutils_test
    │   ├── libutils_test_singleton1.so
    │   └── libutils_test_singleton2.so
    └── libutils_test.config
```

Bug: 124838889
Test: atest libutils_test
Change-Id: I432135e128fc9eedb1b8c18a331957e271d8b0f0
2020-07-10 19:34:53 +08:00
Tom Cherry
c8e4154d89 Merge "init: skip RejectsCriticalAndOneshotService for devices launched before R" 2020-07-09 19:35:34 +00:00
Tom Cherry
0e40ba3183 init: skip RejectsCriticalAndOneshotService for devices launched before R
This restriction is only added for devices launching with R or later.

Bug: 160663765
Test: this test runs when appropriate
Change-Id: I2353bfa7f598bd19ba57498cc5bbad7a3ed34707
2020-07-09 08:49:29 -07:00
Treehugger Robot
69b513ce09 Merge "Add a libipchecksum that contains the C IP checksum code." 2020-07-09 08:55:16 +00:00
Lorenzo Colitti
3b56a0226b Add a libipchecksum that contains the C IP checksum code.
This is useful for test code that wants to statically link the IP
checksum code. This is not currently possible because libnetutils
is vendor_available and making it available for static linking is
discouraged.

Test: m libnetutils libipchecksum
Change-Id: Ic7f1864902581b8a5e3626860565b78c168bdb7f
2020-07-09 16:35:47 +09:00
Tianjie Xu
d7b4fe95c7 Merge "Add function to compare the partitions' extents in metadata" 2020-07-09 02:46:47 +00:00
Treehugger Robot
e28cc8cf48 Merge "Added fuzzer for Unwinder" 2020-07-09 01:22:01 +00:00
Treehugger Robot
9e84b3166f Merge changes I51628abe,I412d62b7
* changes:
  Wrap flock with TEMP_FAILURE_RETRY.
  Try locking after mounting metadata
2020-07-08 21:23:01 +00:00
Treehugger Robot
3042f0ff9f Merge "Add libdm and dmctl support for dm-user targets" 2020-07-08 20:59:41 +00:00
Yifan Hong
c96ab99136 Wrap flock with TEMP_FAILURE_RETRY.
flock may return EINTR. There are code using LockShared() to test
existance of the directory. Don't fail spuriously.

Test: pass
Bug: 160457903
Change-Id: I51628abe05599422eb3f344781d8f3acd653c822
Merged-In: I51628abe05599422eb3f344781d8f3acd653c822
2020-07-08 13:46:23 -07:00
Yifan Hong
fc1e1aeef9 Try locking after mounting metadata
In rescue mode, if /metadata is mounted but /metadata/ota does
not exist, immeidately unmount /metadata and fallback to the code
path when /metadata is not mounted; that is, old partitions are
overwritten.

Test: in recovery, select wipe then immediately sideload
Bug: 160457903
Change-Id: I412d62b7005c81a7126106edc471622e6a7ef813
Merged-In: I412d62b7005c81a7126106edc471622e6a7ef813
2020-07-08 13:46:23 -07:00
Steven Moreland
1652ac276a Merge "libutils: integer sanitization" 2020-07-08 16:45:14 +00:00
Wei Wang
4203129353 Merge "Boost init priority before main loop" 2020-07-08 04:53:04 +00:00
Treehugger Robot
90fe62e76e Merge "Move build.prop to ./etc subdir for some partitions" 2020-07-08 00:03:30 +00:00
Wei Wang
30bbf7d0ad Boost init priority before main loop
Now we have more things e.g. loading kernel modules, initialize
selinux. And before all these, system cannot make further progress. It
should be beneficial to boost this critical peroid in init.

Benchmark on a Pixel device shows this saves 100+ms on early boot

ToT release + This CL (P15538587)
D/BaseBootTest: init_stage_second_START_TIME_avg : 1563.4
D/BaseBootTest: ueventd_Coldboot_avg : 219.0
D/BaseBootTest: action_init_/system/etc/init/hw/init.rc:114_START_TIME_avg : 2103.7

ToT release (6654154)
D/BaseBootTest: init_stage_second_START_TIME_avg : 1639.0
D/BaseBootTest: ueventd_Coldboot_avg : 238.2
D/BaseBootTest: action_init_/system/etc/init/hw/init.rc:114_START_TIME_avg : 2226.0

Bug: 143857500
Bug: 147997403
Bug: 160271169
Bug: 160696502
Test: Boottime
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I21c9e051f4ae3e953d991c031f151b2779702548
2020-07-07 15:50:58 -07:00
Steven Moreland
9c832028c1 libutils: integer sanitization
For sanity.

Fixes: 160342252
Test: manually introduce overflow for "ubsan: mul-overflow"
Change-Id: I292039eaef24582f05dd9f0fef011f0ece8364ed
2020-07-07 22:37:07 +00:00
Jiyong Park
8178c5f0c9 Move build.prop to ./etc subdir for some partitions
build.prop files under system_ext, product, and odm partitions are moved
to the ./etc subdirectory. This is to be in-line with the established
practice of having all configuration files under ./etc subdir.
build.prop doesn't need to be an exception.

However, system/build.prop and vendor/build.prop were not moved because
there are a lot of apps and tools that depend on the path.

Bug: 158735147
Test: device has build.prop under ./etc and is bootable
Change-Id: I26300574c23c78cc4e5bc20f98fc9702838465e1
2020-07-08 02:18:16 +09:00
Tom Cherry
b88a97b41e Merge "Add AMBA bus support to platform devices" 2020-07-07 15:14:14 +00:00
Tianjie
07c951fcf3 Add function to compare the partitions' extents in metadata
For partial updates, the metadata for untouched dynamic partitions
are just copied over to the target slot. So, verifying the extents
of these partitions in the target metadata should be sufficient for
correctness. And we don't need to read & hash the bytes on these
partitions.

Bug: 151088567
Test: unit tests pass
Change-Id: I95836ee6f76d884c7a1f5537154ac7230563493a
2020-07-06 17:40:01 -07:00
Treehugger Robot
3d882d0536 Merge "liblp: Force 10.0 metadata on downgrade to Q." 2020-07-06 22:19:55 +00:00
Jooyung Han
a657c799bf Merge "init: generate apex-info-list.xml" 2020-07-06 21:32:25 +00:00
Yifan Hong
a819a3cad2 liblp: Force 10.0 metadata on downgrade to Q.
Q liblp only supports 10.0 super partition metadata, so
forcefully downgrade the current metadata version too.

On retrofit Virtual A/B devices, the metadata version is
at most 10.1, because the new VIRTUAL_AB flag is not set
on retrofit devices.

In version 10.1, two per-partition flags: UPDATED and DISABLED
are introduced.
- The updated flag is set when the device undergoes a Virtual A/B
update before. Clear it.
- The disabled flag should only be set on metadata files used by
libfiemap ImageManager. It shouldn't be used on super partition metadata.

Hence, this CL should only clear UPDATED flag.

Test: R->R->Q OTA
Bug: 159590481
Change-Id: I8b548c8ce36a75197e7172a77f9207fd44fe4670
(cherry picked from commit ba5dfd76de)
Merged-In: I8b548c8ce36a75197e7172a77f9207fd44fe4670
2020-07-06 13:36:20 -07:00
Josh Gao
7229923bcd Merge "[adb] Fix crash in mdns service removal." 2020-07-06 20:14:27 +00:00
Jooyung Han
1d951b7700 init: generate apex-info-list.xml
If a device doesn't support unflattened APEXes, init activates flattened
APEXes instead of apexd.

Because apexd dumps apex-info-list.xml after it activates all APEXes,
init should do the same thing.

Bug: 159585065
Test: lunch aosp_cf_x86_phone_noapex & m & boot
      adb more /apex/apex-info-list.xml
      adb shell ls -lZ /apex/apex-info-list.xml
       -> -rw-rw-rw- 1 root root u:object_r:apex_info_file:s0 ..
Change-Id: I74a4d0ee363761564225097c5949e5ce335ac6dc
2020-07-05 00:12:04 +00:00
Jim Kaye
08097d4ba4 Merge "Add Silent Mode boot controls" 2020-07-03 18:12:18 +00:00
Treehugger Robot
437ded4dbd Merge "Remove SkipMountingPartitions from vendor libfstab" 2020-07-03 12:02:55 +00:00
Hung-ying Tyan
e7cb09d226 Remove SkipMountingPartitions from vendor libfstab
SkipMountingPartitions() should only be called from a system process
as the config file is in /system_ext.
Remove it from the vendor variant of libfstab.

Bug: 158301941
Test: build hardware/interfaces/boot/1.1/default/boot_control and check symbol
Change-Id: I834183a623c0711dd79b89486fc3fc80f9710801
2020-07-03 17:16:21 +08:00
Jim Kaye
b7386a6239 Add Silent Mode boot controls
Add "reboot,forcedsilent" and "reboot,forcednonsilent"

Bug: 134521909
Test: Manually with 'adb reboot forcedsilent'
Change-Id: Ib07d2b78e6263bc25b23e9973590e399eaf4d7ca
2020-07-01 16:57:01 -07:00
Dylan Katz
b62e324406 Added fuzzer for Unwinder
Adds a fuzzer for Unwinder. This will likely cover a large portion of the library, as it uses many of the library's features
in the process of setting up the Unwinder. Hopefully this, combined with the calls Unwinder makes internally, will provide
sufficient coverage.

Rough coverage estimate (this is drastically lower than the true number due to shared libraries): 6.6%

Test: Ran on device for a few hours
Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: I813e204df595ff38dccfb73be7fff5c080aaa043
2020-07-01 16:02:29 -07:00
Treehugger Robot
bf95cc25e3 Merge "libprocessgroup: Allow vendor profile attributes to override system ones" 2020-07-01 22:35:04 +00:00
Joshua Duong
1922ad0dd4 [adb] Fix crash in mdns service removal.
If std::remove_if is a no-op (no service name match), then
std::vector::erase would crash.

Bug: 160025305

Test: test_adb.py
Test: Manual.
1) Enable wireless debugging on multiple devices
2) Disable wireless debugging on all devices

Change-Id: If58b0dda0bb698fd3fd225d9b6a6726a88ae47e0
2020-07-01 15:06:33 -07:00
Suren Baghdasaryan
81b9f0b763 libprocessgroup: Allow vendor profile attributes to override system ones
In the current implementation vendor profile attributes do not override
system ones and instead generate a warning. Fix that by overriding existing
attribute if a new definition is found.

Bug: 160318642
Test: add vendor attributes and confirm no warnings
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I71a2ee4d4b3c585e7c9a01b791e973390d409cbc
2020-07-01 20:44:24 +00:00
Usama Arif
d86300cc7e
Add AMBA bus support to platform devices
AMBA specification from Arm is a freely available open
standard for the connection and management of functional
blocks in a system-on-chip.
AMBA devices create a device kernel object in /sys/devices/platform
and a kernel object of the bus for the respective device in
/sys/bus/amba. For e.g. for pl180 mmc:
device: /sys/devices/platform/1c050000.mmci
bus: /sys/bus/amba/devices/1c050000.mmci

In first stage init, android creates a symlink from /sys/devices/platform/...
to /dev/block/platform/... for all partitions and then to
/dev/block/by-name for the boot_device used. However this is only done
for devices that "attach" to bus/platform. This patch adds support for
platform devices that attach to bus/amba.

Signed-off-by: Usama Arif <usama.arif@arm.com>
Change-Id: I9da7456407c4f62335c959502d8b2d16026fddfc
2020-07-01 11:47:49 +01:00
Treehugger Robot
c3f17840ae Merge "libmodprobe: remove unused EnableVerbose() method" 2020-06-29 12:05:21 +00:00
Treehugger Robot
14260d2314 Merge "modprobe: add -s/--syslog flag" 2020-06-26 22:36:12 +00:00
Mark Salyzyn
ce30bb8e4b libmodprobe: remove unused EnableVerbose() method
modprobe command no longer uses EnableVerbose, opting to do the
associated operations directly.

Test: compile
Change-Id: Iffc8324f37f34de4eeb9a27e92fdf5524afa2220
2020-06-26 22:30:21 +00:00
Palmer Dabbelt
2def03a2b9 Add libdm and dmctl support for dm-user targets
dm-user is very much a WIP and while this may change (we need to figure out how
to get credentials to the dm-user daemon, for example) it seems like a somewhat
safe bet to assume that the behavior will at least include a start/end range.

Test: I just ran "dmctl create palmer user 0 1024", which created the device.
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Change-Id: Ic5f84de6a4f09bf906246035d450edd637cc38ed
2020-06-26 12:24:53 -07:00
Mark Salyzyn
63368beaba modprobe: add -s/--syslog flag
There is a desire to ensure that modprobe as a service can log to
kmesg to help triage issues, so add support for the -s or --syslog
flag to do so.

SideEffects:
- help goes to stdout instead of stderr.
- verbose flag once, sets DEBUG, twice, sets VERBOSE minimum.
- quiet flag sets WARNING minimum.

Bug: 159424228
Bug: 151950334
Test: use modprobe as a service to load modules, check logs
Change-Id: I884995f364b0fc604861797eb90d7225a372f864
2020-06-26 10:31:07 -07:00
Mark Salyzyn
3d246cced8 Merge "modprobe: add --all=modules.load flag" 2020-06-26 11:46:48 +00:00
Treehugger Robot
d894b463f1 Merge "modprobe: switch to getopt_long for argument parsing" 2020-06-25 16:52:51 +00:00
Tom Cherry
c58d1e4aec Merge changes I9638e90b,Ib2636dfc
* changes:
  logd: replace std::vector<uint8_t> in SerializedLogChunk
  logd: fix use after resize of contents_ vector
2020-06-25 14:48:39 +00:00
Mark Salyzyn
6c9a1e4d49 modprobe: add --all=modules.load flag
Add a means to specify the modules to load from a file, rather than
on the argument list by adding an optional argument to the --all flag.
This allows modprobe to be designated as a standalone service to load
a long series of modules in the background and be specified
separately.  The specified (module.load) file contains a newline
separate list of module names, and supports line comments using '#'
since this file may be maintained by a human or scripting that
requires tagging for regions of the file.

Bug: 159424228
Bug: 151950334
Test: use modprobe as a service to load modules
Change-Id: Id32641c7244e65848fca3a4a82c8d08b2042bf2f
2020-06-24 18:10:12 -07:00
Mark Salyzyn
3ad274be15 modprobe: switch to getopt_long for argument parsing
Add support for long options, and fit existing options to upstream
behaviors and extensions.  Fix some missing std::endl and
android::base::Join() usage.

Bug: 159424228
Bug: 151950334
Test: manually test long options work
Change-Id: Id792d87d4407628e706aeccecb6e2bce22bcad10
2020-06-24 18:10:12 -07:00
Tom Cherry
b6cb992cf3 logd: replace std::vector<uint8_t> in SerializedLogChunk
Turns out std::vector::resize() and std::vector::clear() don't
actually deallocate any memory.  std::vector::shrink_to_fit() can be
used for this but isn't a 'guarantee'.  Instead of trying to get
std::vector to play nice, this change replaces std::vector<uint8_t>
with std::unique_ptr<uint8_t[]>, which is more accurate to how I'm
using this memory anyway.

Test: logging unit tests
Change-Id: I9638e90bbf50bcf316c5aa172c8278ea945d27e7
2020-06-24 16:19:28 -07:00
Tom Cherry
b07e339b53 logd: fix use after resize of contents_ vector
SerializedFlushToState::PopNextUnreadLog() was calling
AddMinHeapEntry() to replenish the element that was just popped off of
the heap, however AddMinHeapEntry() also manages reference counts for
the buffers, and this resulting in the following scenario:

PopNextUnreadLog() returns a pointer referencing log buffer #1
AddMinHeapEntry() sees that all logs from buffer #1 has been read, so
it decrements the reference count
The caller of PopNextUnreadLog() uses the result which references
invalid memory.

This calls CheckForNewLogs() within HasUnreadLogs() instead of
requiring a separate call, which fixes an additional issue where
continuing from the loop in SerializedLogBuffer::FlushTo() may not
pick up subsequent logs in a given log buffer, since CheckForNewLogs()
wouldn't be called.  This was exacerbated by the above change.

This adds a test to check the reference counts for this case and fixes
an argument mismatch in SerializedFlushToStateTest.

This adds the corpus that surfaced the issue.

Bug: 159753229
Bug: 159783005
Test: these unit tests, run fuzzer without error
Change-Id: Ib2636dfc14293b7e2cd00876b9def6e9dbbff4ce
2020-06-24 15:31:46 -07:00
Nikita Ioffe
5b2457ed34 Merge "Explicitly call restorecon_recursive on /metadata/apex" 2020-06-24 16:40:52 +00:00
Nikita Ioffe
a462044ac8 Explicitly call restorecon_recursive on /metadata/apex
On some devices we see a weird in which /metadata/apex will have a wrong
selinux label. This will effectively prevent such devices from getting
any apex updates. Since we haven't figured out a root cause for this
bug, it's safer to explicitly call restorecon on /metadata/apex to make
sure it's correct.

This change shouldn't affect a normal boot flow, since /metadata/apex
will already have a correct label and restorecon_recursive will be a
no-op.

Test: rm -Rf /metadata/apex && \
    mkdir /metadata/apex &&
    mkdir /metadata/apex/sessions
Bug: 149317789
Merged-In: I971ffe35c93bb79d9e71106c24515ec0ee70333a
Change-Id: I971ffe35c93bb79d9e71106c24515ec0ee70333a
(cherry picked from commit cf7b6bad55)
2020-06-24 16:30:03 +01:00
Lorenzo Colitti
d9299c5119 Merge "add a new trigger for launching the bpfloader" 2020-06-24 02:50:28 +00:00
Tom Cherry
23ae9df08e Merge changes Id5f03945,I69c74471
* changes:
  logd: add fuzzer for SerializedLogBuffer and other improvements
  logd: join() the SerializedLogBuffer deleter thread
2020-06-23 22:06:36 +00:00
Tom Cherry
f2774a04ca logd: add fuzzer for SerializedLogBuffer and other improvements
1) Add fuzzer for SerializedLogBuffer
2) Enable fuzzing on host
3) Read logs after writing them
4) Silence log tags error on host

Test: run these fuzzers
Change-Id: Id5f0394546ecbccf5281e3d8855853be90dee3f0
2020-06-23 11:37:49 -07:00