Commit Graph

48035 Commits

Author SHA1 Message Date
Tri Vo c6a84e873b Set /sys/power/wake_lock permissions on init.
system_suspend need to be an early_hal as it's required before storage
encryption can get unlock on FDE devices.

/sys/power/wake_lock is a dependency of system_suspend (only in Q and
earlier). Permissions on this file need to be set early enough.

Bug: 136777986
Bug: 133175847
Test: boot blueline
Change-Id: I8a9d3374b327e451fb98d2279d1bac9477a9560d
2019-07-16 14:33:00 -07:00
Treehugger Robot 8987f061c4 Merge "Add nolint for implicit borrowed_fd constructors" 2019-07-16 04:11:20 +00:00
Treehugger Robot a19f51eccc Merge "Reserve 'init'." 2019-07-16 02:35:29 +00:00
Treehugger Robot 100e8ffbcd Merge "Remove obsolete subdirs entry." 2019-07-16 02:02:40 +00:00
Kiyoung Kim 2f174171d7 Merge "Run linkerconfig from init process" 2019-07-16 00:32:13 +00:00
Ryan Prichard c37f4a4199 Merge changes I5e33e5bf,I64237006
* changes:
  Make android_load_sphal_library thread-safe
  Switch libvndksupport's linker.c to C++
2019-07-16 00:06:21 +00:00
Christopher Ferris 1e7b753c36 Merge "Optimize code that only uses PageMap call." 2019-07-16 00:00:18 +00:00
David Anderson 4c3d9b2491 Merge "Revert "Remove libfiemap_writer from fs_mgr and move it to gsid."" 2019-07-15 23:55:25 +00:00
David Anderson 31656c2c53 Revert "Remove libfiemap_writer from fs_mgr and move it to gsid."
This reverts commit 20fbf0d672.

Reason for revert: broke build

Change-Id: I6914455ba1f0fd56fbf3572f349242d734281610
2019-07-15 23:52:49 +00:00
Tom Cherry c8620ddafe Merge "init: clean up file / socket descriptor creation" 2019-07-15 23:20:13 +00:00
Tom Cherry 2a0a0810a1 Merge "Add reserved AID ranges for all partitions" 2019-07-15 23:19:41 +00:00
David Anderson 3d5b8bc373 Merge "Remove libfiemap_writer from fs_mgr and move it to gsid." 2019-07-15 22:54:21 +00:00
David Anderson 20fbf0d672 Remove libfiemap_writer from fs_mgr and move it to gsid.
gsid is the only consumer for this library, and it's unlikely to grow
beyond gsid.

Bug: 134536978
Test: gsid builds
Change-Id: Ib632b1dd8de3e29c02d1fe443a1e409af5f1257d
2019-07-15 22:53:39 +00:00
Steven Moreland 4c79df91a9 Remove obsolete subdirs entry.
Change-Id: I3327df74179d2ba1ffd66da59e5196f34dfe3974
Bugs: me
Test: N/A
2019-07-15 15:14:34 -07:00
Steven Moreland ceb36d08f4 Reserve 'init'.
This makes `pathmod init` and `gomod init` work, and it also reserves
the 'init' for potential future usage.

Change-Id: I6990bf421211b93d58d978d84d46474ff243e808
Bugs: me
Test: pathmod init; gomod init
2019-07-15 15:12:56 -07:00
Tom Cherry aa55ee6044 Add nolint for implicit borrowed_fd constructors
bpfloader uses both clang-tidy and this header, so the below lint
warnings are generated:

/work/aosp/system/core/base/include/android-base/unique_fd.h:261:18:
  warning: single-argument constructors must be marked explicit to
  avoid unintentional implicit conversions
  [google-explicit-constructor]
  /* implicit */ borrowed_fd(int fd) : fd_(fd) {}
                 ^
                 explicit

/work/aosp/system/core/base/include/android-base/unique_fd.h:263:18:
  warning: single-argument constructors must be marked explicit to
  avoid unintentional implicit conversions
  [google-explicit-constructor]
  /* implicit */ borrowed_fd(const unique_fd_impl<T>& ufd) : fd_(ufd.get()) {}
                 ^
                 explicit

Add NOLINT to quiet them.

Test: build without this lint warning
Change-Id: I5241938c33070b0fa39888289b8ca67d6d94ac73
2019-07-15 15:00:23 -07:00
Ryan Prichard 8c733615aa Make android_load_sphal_library thread-safe
Also: remove an obsolete comment from linker_test.cpp. The test program is
at /data/nativetest[64]/libvndksupport-tests/libvndksupport-tests, which
may will be in the system or legacy configuration, and either the "sphal"
or "default" namespace will be visible.

Bug: none
Test: run libvndksupport-tests, device boots
Change-Id: I5e33e5bf1402a0368e046b03827c216789b02c96
2019-07-15 13:58:51 -07:00
Ryan Prichard 807d9d62d8 Switch libvndksupport's linker.c to C++
Bug: none
Test: device boots
Change-Id: I64237006a7f903647c8d8f7ca681b1da23ac53a9
2019-07-15 13:43:05 -07:00
Tom Cherry 2e4c85f157 init: clean up file / socket descriptor creation
clang-tidy hinted that some of this code wasn't right.  Looking
deeper, there is really not much related to file and socket
descriptors, except that they're published in similar ways to the
environment.  All of the abstraction into a 'Descriptor' class takes
us further away from specifying what we really mean.

This removes that abstraction, adds stricter checks and better errors
for parsing init scripts, reports sockets and files that are unable to
be acquired before exec, and updates the README.md for the passcred
option.

Test: build, logd (uses files and sockets) works
Change-Id: I59e611e95c85bdbefa779ef69b32b9dd4ee203e2
2019-07-15 12:17:30 -07:00
Mark Salyzyn 91338a6aa2 Merge "bootstat: power_on* handling" 2019-07-15 15:47:04 +00:00
Tom Cherry a8b0517108 Merge "Add noexcept to missing places in expected.h" 2019-07-15 15:12:46 +00:00
David Anderson cd22e3a6f6 Merge "fs_mgr: Remove the timeout parameter to DestroyLogicalPartition." 2019-07-13 18:02:05 +00:00
Christopher Ferris 504d2cce64 Optimize code that only uses PageMap call.
Some code only wants to use PageMap to determine whether pages are
mapped in to memory. Modify the code to optimize this path.

Changes:
- Add a function that doesn't read all of usage stats data for every
  map. This operation is extremely expensive, and some code doesn't
  care about it.
- Optimize the PageMap call to do a single read instead of a single
  read per page.
- Add unit tests for these changes.

Bug: 136245508

Test: Ran new unit tests.
Test: Ran procrank and verified data looks good.
Test: Ran DexDiag art tests.
Change-Id: I37d03f2584551d26cb20be3abacdb958111d4eca
2019-07-12 16:28:09 -07:00
David Anderson c9b797ac25 Merge "libdm: Improve the reliability of dm device paths." 2019-07-12 23:03:41 +00:00
Suren Baghdasaryan e0b729d214 Merge "lmkd: Prevent non-main threads being registered or killed by lmkd" 2019-07-12 20:13:35 +00:00
Tom Cherry 8a779ee959 Merge "init: fix clang-tidy performance issues" 2019-07-12 18:49:49 +00:00
Treehugger Robot bde9fc1787 Merge "fs_mgr: overlay: do not allow sub-mounts to be overridden" 2019-07-12 18:38:39 +00:00
Daniel Norman 4b505fe3a8 Merge "Checks the interface inheritance hierarchy in init_rc files." 2019-07-12 18:01:46 +00:00
Tom Cherry e7a010de01 Merge "init: Write the reason in BCB on "reboot recovery"" 2019-07-12 17:39:32 +00:00
Treehugger Robot 5c296a0003 Merge "init: powerctl support and propagate longer canonical reboot reasons." 2019-07-12 17:37:25 +00:00
Steven Moreland 67a0dd4e27 Merge "libutils: remove references to unimplemented func" 2019-07-12 16:48:04 +00:00
Steven Moreland a1821e13f3 Merge "libadbd_services: remove unused deps" 2019-07-12 16:36:16 +00:00
Suren Baghdasaryan 0082ef15cf lmkd: Prevent non-main threads being registered or killed by lmkd
Only thread group leaders should be registered with lmkd. Add a check to
ignore any non-leader TIDs and generate an error if such condition is
detected. Run the same check before killing a process to detect cases of
non-leader TIDs being used to kill a process. This might happen if PIDs
overflow and previously registered PID gets reused for a non-leader
thread in the following scenario:

1. pid X is a thread group leader and is registered with lmkd
2. pid X dies without lmkd knowing it and pid gets recycled
3. process Y creates a thread with tid X
4. lmkd kills pid X which results in process Y being killed

Bug: 136408020
Test: lmkd_unit_test
Change-Id: I46c5a0b273f2b72cefc20ec59b80b4393f2a1a37
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-07-12 15:11:54 +00:00
Kiyoung Kim 74c229232c Run linkerconfig from init process
Create linkerconfig tmpfs mount and create ld.config.txt using
linkerconfig during init

Bug: 135004088
Test: m -j & tested from device
Change-Id: Iea30259871ef26d6c04beebf42b17ba7b494db0d
2019-07-12 12:27:11 +09:00
Steven Moreland c0927e64b1 libutils: remove references to unimplemented func
printWeakPointer isn't implemented anywhere. This also allows us to
remove a forward declaration of TextOutput.

Bug: N/A
Test: N/A
Change-Id: Ie2debdfda17b7cc1d599c431eaf4c362a591e482
2019-07-11 17:50:52 -07:00
Steven Moreland e0d94b6493 libadbd_services: remove unused deps
Bug: 137311188
Test: library still builds
Change-Id: I52e110ddfda073c833e86194eaf7a9502b9181a6
2019-07-11 16:13:10 -07:00
David Anderson 470fe2b5f0 fs_mgr: Remove the timeout parameter to DestroyLogicalPartition.
This is no longer needed as CreateLogicalPartition() ensures the
obtained path will not race with device deletion.

Bug: 135771280
Test: device builds, flashes
Change-Id: I821290aa08fede99d5c51cd68681c351a1ea97bc
2019-07-11 15:39:53 -07:00
David Anderson 924858cd18 libdm: Improve the reliability of dm device paths.
This fixes a race condition where WaitForFile() after
GetDmDevicePathByName appears to succeed, but a subsequent operation on
the path fails. This can happen when CreateDevice() is called
immediately after a call to DeleteDevice (from any process), and the
path is re-used, enqueuing udev events to remove and re-add the block
device.

The fix for this is to introduce a new variant of CreateDevice() that
has a timeout parameter. When the timeout is positive, CreateDevice()
will wait for a /dev/block/mapper/by-uuid symlink to be created, which
signals that ueventd has finished processing the operation.

ueventd will now create these by-uuid symlinks for device-mapper nodes.
Unfortunately, the uuid is only available during "change" events, so we
have to special case device-mapper symlink creation. And since the uuid
is not available during "remove" events, we simply find matching links
to remove them.

This ensures that callers of CreateDevice() can use the device path
knowing that no asynchronous removals are pending. Code that uses the
old CreateDevice+WaitForFile pattern will be transitioned to the new
method.

Note that it is safe to ignore the timeout, or to use the "unsafe"
CreateDevice, if the caller ensures the path by other means. For example
first-stage init has no device removal, and regenerates uevents until
it has acquired all the paths it needs.

Finally, since libdm now inspects sysfs unconditionally, libdm consumers
need r_dir_file perms for sysfs_dm in their sepolicy. Additionally
linking to libdm now requires linking to libext2_uuid.

Bug: 135771280
Test: libdm_test
      device flashes, boots
Change-Id: If5a7383ea38f32a7fbbcf24842dce6a668050a70
2019-07-11 15:39:52 -07:00
Daniel Norman 3f42a767cd Checks the interface inheritance hierarchy in init_rc files.
Bug: 118016875
Test: Added 'interface' lines to an init_rc file and observed errors
when misspelled or missing entire inheritance hierarchy.
Change-Id: I681420f15539742d8415808b2a0dcbf0bf6faaf1
2019-07-11 14:43:11 -07:00
Steven Moreland 4280165ae0 Merge "Remove binder dependency in init." 2019-07-11 20:56:12 +00:00
Sam Protsenko 4d35f2e59c init: Write the reason in BCB on "reboot recovery"
Without this change "adb reboot recovery" leads to normal boot.

Change-Id: I361d0a1f6f6f2c57f3dc80102c21970b462c9b9c
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
2019-07-11 11:25:28 +00:00
Justin Yun 6da50e319c Merge "Rename product_services to system_ext" 2019-07-11 05:36:23 +00:00
Treehugger Robot 7c2e6f4e6f Merge "DO NOT MERGE - Merge pie-platform-release (PPRL.190705.004) into master" 2019-07-11 03:52:57 +00:00
Mark Salyzyn 8cf2103083 fs_mgr: overlay: do not allow sub-mounts to be overridden
Prevent sub-mounts from being candidates for overlayfs overrides.
We move them temporarily to hold the references, then move them back
after overlayfs mount.

There is a race condition that can not be solved where the content
of the sub-mount is temporarily unavailable.  This operation occurs
in first stage init (no problem) and during the first adb remount or
adb disable-verity that causes the backing storage to be setup.
Workaround will be to time the adb remount/disable-verity so that the
device-specific problems do not surface.

Test: adb-remount-test.sh and manual device configs
Bug: 130131892
Bug: 135647457
Change-Id: I8782d09b7b389d899aed07b3e6c528280af2d6c8
2019-07-10 14:32:05 -07:00
Tom Cherry 3ceea099f3 Add reserved AID ranges for all partitions
With Treble and Mainline, each partition needs to be able to
independently define its own set of AIDs and therefore needs its own
AID range to not conflict with updates made to other partitions.

This includes the system partition in the case of vendors making
additions to it.  Bionic will always have the hardcoded list of
platform AIDs in its own reserved list.

Bug: 73062966
Test: can load AIDs from partitions other than vendor
Test: bionic-unit-tests

Change-Id: I6509acc555cd28b421b9edaf3f8006bad6c56125
2019-07-10 13:45:53 -07:00
Mark Salyzyn d7931f1149 init: powerctl support and propagate longer canonical reboot reasons.
init: Received sys.powerctl='reboot,userrequested,recovery,ui' ... (/system/bin/recovery)
init: powerctl: unrecognized command 'reboot,userrequested,recovery,ui'

Test: manual & boot_reason_test.sh
Bug: 63736262
Bug: 135078366
Bug: 133326470
Change-Id: I931daf8dc4b74db5ee114c59ee215b1ba54bc31d
2019-07-10 13:06:57 -07:00
Tom Cherry 7c1d87e490 init: fix clang-tidy performance issues
Test: boot, init unit tests
Change-Id: Iccf34d2fedfa543dd9f29e010cbb6d8fe9cf5983
2019-07-10 12:59:02 -07:00
Steven Moreland 4ee27039e0 Remove binder dependency in init.
- unused
- using binder requires twoway calls (since getting a service from
    servicemanager requires two calls)

Bug: 135768100
Test: N/A
Change-Id: Idc41f487bad2d8343e99ded98812f3a84e2b8e37
2019-07-10 17:01:31 +00:00
Elliott Hughes d543c8ca11 Merge "grep is now toybox grep." 2019-07-10 15:19:58 +00:00
Tom Cherry 820333dce4 Add noexcept to missing places in expected.h
These move and assignment operations are conditionally noexcept, so
add that to their definitions.  This is a performance issue as well as
correctness, since std containers will copy instead of move during
resize if these operations are not noexcept.

Test: build
Change-Id: I148f7eb3489e7f1dd68cc0fb0e555b56470e42da
2019-07-09 17:06:08 -07:00