Commit graph

1311 commits

Author SHA1 Message Date
Nikita Ioffe
12a36076a7 Userspace reboot: Support remounting userdata for f2fs
Test: adb reboot userspace
Test: adb shell /system/bin/vdc startCheckpoint 1;
      adb reboot userspace
Bug: 135984674
Change-Id: I227f2c1cc18495d893decb2df5173fc7a7919df6
2019-10-25 16:27:10 +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
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
Bill Peckham
dea8c9c1ac Moving recovery resources from /system to /vendor
This change is part of a topic that moves the recovery resources from the
system partition to the vendor partition, if it exists, or the vendor directory
on the system partition otherwise. The recovery resources are moving from the
system image to the vendor partition so that a single system image may be used
with either an A/B or a non-A/B vendor image. The topic removes a delta in the
system image that prevented such reuse in the past.

The recovery resources that are moving are involved with updating the recovery
partition after an update. In a non-A/B configuration, the system boots from
the recovery partition, updates the other partitions (system, vendor, etc.)
Then, the next time the system boots normally, a script updates the recovery
partition (if necessary). This script, the executables it invokes, and the data
files that it uses were previously on the system partition. The resources that
are moving include the following.

* install-recovery.sh
* applypatch
* recovery-resource.dat (if present)
* recovery-from-boot.p (if present)

This change moves the recovery resources to vendor in libcutils/fs_config.cpp
and removes the flash_recovery service from rootdir/init.rc. This service moved
to a vendor init.rc file in bootable/recovery/applypatch.

Bug: 68319577
Test: Ensure that recovery partition is updated correctly.
Change-Id: I492f7989ea8042912e9d0e0eadeaa351affbee13
2019-10-04 00:04:08 +00:00
Treehugger Robot
9a7e1eff5a Merge "Move fsverity_init to after class_start core" 2019-10-02 16:17:47 +00:00
Tom Cherry
6ddce6b015 Remove references to /sys/android_power/*
It looks like these were deprecated a very long time ago.

Bug: 141939924
Test: tree-hugger
Change-Id: I4fc098b2a45c81fe2af49c0ed4248dc14489f8b1
2019-10-01 13:30:41 -07:00
Tom Cherry
993d07fc53 Merge changes from topic "boringssl-kmsg"
* changes:
  Redirect boringssl_self_test stdio to kmsg
  init: add stdio_to_kmsg option
2019-09-25 19:56:03 +00:00
Tom Cherry
f5e872e9e9 Redirect boringssl_self_test stdio to kmsg
To aid in debugging if there are failures.

Bug: 137267623
Test: add prints to boringssl_self_test and see them
Test: add failure prints to the linker and see them before
      boringssl_self_test runs
Change-Id: I89d50c6a46df994d6ea1fadf00e3a8a796043234
2019-09-24 12:47:14 -07:00
Zim
fc64dad122 Prepare pass_through mounts
Execute mkdir -p /mnt/pass_through/0/emulated
and bootstrap the emulated volume for user 0.

The 'pass_through' paths allow us bind mount the lower
filesystem directly into /storage, bypassing any sdcardfs
of FUSE mounts.

This change is part of enabling upcoming platform changes that are
described in the bug linked below.

Bug: 135341433
Test: builds, boots and pass through directories are created
Change-Id: I46ce207d06a1ec550b8bacac259387371fc0b841
2019-09-23 14:21:27 +01:00
Tom Cherry
a76bfb2d97 Simply reboot if the boringssl self test fails
If this check fails and an OTA or mainline module update has recently
happened, we want to rollback the recent change.  The easiest way to
handle this is to reboot, which will trigger the fallback mechanisms
that are already in place.

Bug: 141082587
Test: device reboots if self test fails
Test: device rolls back a recently applied OTA with failing self test
Test: device rolls back a recently applied conscrypt apex update with
      failing self test
Change-Id: Iff879deff09d347262dc7a2acadb9164a5029d4a
2019-09-19 14:59:07 -07:00
Paul Crowley
21b00b31d4 Merge "Create /data/per_boot" 2019-09-17 05:40:05 +00:00
Paul Crowley
570d20d2ac Create /data/per_boot
Bug: 140882488
Test: Booted twice, checked logs to ensure encryption
    is different each time, adb created files in directory.
Change-Id: I44f746acd1040f7baa9123d4824ba39b194f287b
2019-09-13 15:50:23 -07:00
Tobias Thierer
f0f9438d5b boringssl_self_test: Enable optimization.
libcrypto performs a self test when it is loaded, unless
a marker file /dev/boringssl/selftest/[hash] exists which
indicates that the self test has already successfully
completed since the last time the device was booted.

Before this CL topic, libcrypto attempted to create the
marker file when the self test successfully completed.
On Android, dedicated boringssl_self_test{32,64} binaries
are run early during boot and are the only binaries
(apart from init and vendor_int) that have permission to
create these files.

Another CL in this topic stops the boringssl self test
creating a marker file unless the environment variable
BORINGSSL_SELF_TEST_CREATE_FLAG is set to a nonempty value.
This CL sets that value to "true" when running the dedicated
self test binaries, but not for other binaries. This has
the effect that other binaries that run the self test
early during boot (before the dedicated self test binaries
have created the marker files) and which run the self test
will no longer attempt to create the marker file, which
SELinux would have denied anyway.

Bug: 137267623
Test: Treehugger

Change-Id: I99317df1a8c3496d33ae83f9ec346782b2286ac9
2019-09-13 16:51:57 +01:00
Tom Cherry
60971e6ce2 init: add reboot_on_failure service option
This replaces the recently added `exec_reboot_on_failure` builtin, since
it'll be cleaner to extend service definitions than extending `exec`.
This is in line with what we decided when adding `exec_start` instead
of extending `exec` to add parameters for priority.

Test: `exec_start` a service with a reboot_on_failure option and watch
      the system reboot appropriately when the service is not found and when
      the service terminates with a non-zero exit code.

Change-Id: I332bf9839fa94840d159a810c4a6ba2522189d0b
2019-09-13 16:48:35 +01:00
Tobias Thierer
bda0554bb2 init.rc: Move /system/bin/boringssl_self_test{32,64} call to early-init.
This should ensure that the self tests run before any other binaries
that load libcrypto and which would otherwise run into SELinux denials
trying to create the marker file /dev/boringssl/selftest/[hash]

The invocation of the self test binaries from the Conscrypt apex
requires the apex to be mounted so it remains at a later point in
the boot process.

Bug: 137267623
Test: Treehugger
Change-Id: I34266d6e9d2f394fffa8a2c7725479b5770d119c
2019-09-13 03:31:42 +01:00
Tobias Thierer
9caa15b5c3 init.rc: drop spurious trailing ':'.
The accidental trailing ':' appears to stop the line
triggering.

Bug: 137267623
Test: Checked the /system/bin/boringssl_self_test32
      now runs on aosp_cf_x86_phone-userdebug

Change-Id: I7b4b1d6b838d8d1a7a0db7f104a94b34962df030
2019-09-10 13:38:55 +00:00
Nikita Ioffe
8bdbea8df5 Remove start vold action from post-fs-data
vold is already started during early-fs which happens before
post-fs-data.

Trying to start it again in post-fs-data is a little bit confusing.

Test: device boots
Change-Id: I5faefe6d1f1bb7472ea3d032b1f157c69da565f1
2019-09-09 14:50:33 +01:00
Tobias Thierer
983f76b3c6 Merge "Init: Run boringssl self test via separate binaries." 2019-09-07 23:46:00 +00:00
Victor Hsieh
8129f86141 Move fsverity_init to after class_start core
The script needs to run after keystore, which is now a core service.
Note the previous APEX requirement by ART is no longer needed.

Test: see keys loaded
Bug: 112038744
Change-Id: I02fb6ce193bb301488b259421f120e6aa6cd75b9
2019-09-06 15:49:58 -07:00
Tobias Thierer
1136f1592a Init: Run boringssl self test via separate binaries.
Instead of init.cpp knowning about the boringssl self
test, use init.rc to exec dedicated self test executables.

Advantages:
 - The self test is run not only both the copy of libcrypto
   in /system but also /apex/com.android.conscrypt.
 - The self test is run not only for the primary (e.g. 64bit)
   ABI but also for a secondarry (e.g. 32bit) ABI.
 - The dependency on libcrypto is kept to the self test binary.
 - The self test binary abstracts the exact native API for
   running the self test (this will change soon because the
   self test will be run when the library is loaded).

Bug: 137267623
Test: Check that logcat shows both binaries being started as root,
      and finishing with exit code 0.

Change-Id: I1e716749ee2133993f0f7b2836483391fd1a62f0
2019-09-05 01:41:08 +01:00
Tom Cherry
21fd368dc2 Merge "Start serial console at the 'init' trigger"
am: c70fc1cbfd

Change-Id: I18b1fc5fb667d4938e9d2a8fb9098444ef53259b
2019-08-29 09:07:37 -07:00
Tom Cherry
71c3ef135d Start serial console at the 'init' trigger
Start the serial console at the 'init' trigger instead of much later
when property triggers happen.  This will help debugging early boot
issues.

Test: serial console starts early for a userdebug build
Test: serial console still doesn't start on a user build
Change-Id: I7112a8e7171c9fa865c8787c9a3d14515bc59478
2019-08-28 14:43:07 -07:00
Paul Crowley
95e7252fd8 Merge "Move layout_version to /data/misc/installd"
am: 24f955155a

Change-Id: Icf3e304aff7e4e1e556c6372be932e3c357d1bbe
2019-08-28 13:35:54 -07:00
Paul Crowley
24f955155a Merge "Move layout_version to /data/misc/installd" 2019-08-28 19:56:15 +00:00
Paul Crowley
e7812e6787 Merge "Create the rollback directories in init"
am: 7a0948f6c4

Change-Id: Iee1c67c81b5809c645c35211431f5c003c07b167
2019-08-26 17:50:47 -07:00
Paul Crowley
8184d7c2a5 Create the rollback directories in init
Init sets the encryption policy on these directores when created.

Bug: b/139193659
Test: Boot device without this, then try to boot with it without wiping.
Cherrypicked-From: 7bf42f148a
Change-Id: I6b26710674b51d62fa4a07b06e06c539571fb7ac
Merged-In: I6b26710674b51d62fa4a07b06e06c539571fb7ac
2019-08-25 11:24:40 -07:00
Xin Li
d62c31d3ac DO NOT MERGE - Merge build QP1A.190711.019 into stage-aosp-master
Bug: 139893257
Change-Id: Ib69c986e30b903cc48ca835fb307acf569930806
2019-08-23 06:45:26 +00:00
Tobias Thierer
93c7c97047 Merge "Let init create /dev/boringssl/selftest/"
am: c3847f599c

Change-Id: I0eb2b4e57a7d5ba7e9bdcb7e3720d13d01c71a9e
2019-08-22 15:55:22 -07:00
Tobias Thierer
3536fdb927 Let init create /dev/boringssl/selftest/
This directory is intended to be used by boringssl
(through the bssl_self_test{,64} binaries) to create /
check for the existence of marker files indicating that
the self test has successfully run.

It appears that because this is an .rc script for init
rather than a shell,
  mkdir -p /dev/boringssl/selftest 0755 root root
wouldn't work.

Bug: 139348610
Bug: 136262690
Test: Checked that after booting, /dev/boringssl/selftest
  exists:
  $ su root ls -l /dev/boringssl
  total 0
  drwxr-xr-x 2 root root 40 1972-02-11 03:27 selftest
Test: Checked that if I instead try:
  mkdir -p /dev/boringssl/selftest 0755 root root
  in init.rc then the directory isn't created (there is
  no error message in logcat because logd is only
  started in line 311).

Change-Id: I12fdd08c8ead152ac4e62cbd0a2099a9d6170ddb
2019-08-22 21:51:09 +01:00
Paul Crowley
26aabfd1ed Move layout_version to /data/misc/installd
Bug: 139543295
Test: Boot, ensure file is properly created
Change-Id: I919b5599484b4c77f222e640a1f1b5d65198a0c7
2019-08-21 10:12:18 -07:00
Zimuzo Ezeozue
1562c6cd8c Merge "Allow switching between sdcardfs and FUSE mounts"
am: 6c62ae7adb

Change-Id: I707ad8146f4318fd3adf0e641aaac68e76d790b4
2019-08-13 02:35:36 -07:00
Zim
c9f8e5dfed Allow switching between sdcardfs and FUSE mounts
This change is part of enabling upcoming platform changes that are
described in the bug linked below.

Bug: 135341433
Test: builds, boots successfully and external storage remains
an sdcardfs mount by default and works correctly
Test: cat /proc/1/mountinfo is unchanged

Change-Id: Idf851b3a42910e0ce8fdd75daea1cce91dd1aa98
2019-08-12 21:37:12 +01:00
David Anderson
aa6b5176fb Merge "Implement basic libsnapshot functionality."
am: 23a87716b5

Change-Id: I2c29c0839d7cfefbc4791ab9a447c648e3ed73c0
2019-08-04 01:24:24 -07:00
David Anderson
456e50193b Implement basic libsnapshot functionality.
This CL implements some of the libsnapshot internals necessary to work
with update_engine. In particular it implements snapshot and update
state, as well as creating and mapping snapshot devices. It does not
implement anything related to merging, nor does it implement the full
update_engine flow.

Update state is stored in /metadata/ota/state. To synchronize callers of
libsnapshot, we always flock() this file at the top of public functions
in SnapshotManager. Internal functions are only called while the lock is
held, and a "LockedFile" guard object is always passed through to
indicate proof-of-lock.

Low-level functions, such as snapshot management, have been moved to
private methods. Higher-level methods designed for update_engine will
ultimately call into these.

This CL also adds some functional tests for SnapshotManager. Test state
is stored in /metadata/ota/test to avoid conflicts with the rest of the
system.

Bug: 136678799
Test: libsnapshot_test gtest
Change-Id: I78c769ed33b307d5214ee386bb13648e35db6cc6
2019-08-02 13:30:08 -07:00
David Anderson
f1ce0e51bb Merge "Add a metadata folder for libsnapshot."
am: 45a1c998d1

Change-Id: I450ae649c089b3c5108cc26a714d851e6615d298
2019-07-18 16:00:31 -07:00
David Anderson
45a1c998d1 Merge "Add a metadata folder for libsnapshot." 2019-07-18 22:42:13 +00:00
David Anderson
001747e890 Add a metadata folder for libsnapshot.
/metadata/ota will store the update state ("none", "applying",
"booting", "merging") for each dynamic partition. The data will be
managed by libsnapshot, whose primary consumer will be update_engine
but will also be available to recovery/fastbootd.

Bug: 136678799
Test: /metadata/ota exists
Change-Id: I3e06484cafeb363904914767abc8984adaa37021
2019-07-17 19:17:27 -07:00
Elliott Hughes
03cca21541 Merge "Remove perfprofd reference."
am: 97c06703f6

Change-Id: If6374e130ff430e7171ac71c7889844aab10775f
2019-07-17 11:47:44 -07:00
Treehugger Robot
97c06703f6 Merge "Remove perfprofd reference." 2019-07-17 18:30:37 +00:00
Elliott Hughes
ffaabf54ba Remove perfprofd reference.
Dead and gone.

Test: treehugger
Change-Id: I8c08cada5313ddede5ebb4973d61cef2bb8a0a7e
2019-07-17 08:17:44 -07:00
Tri Vo
b00894dc64 Merge "Set /sys/power/wake_lock permissions on init."
am: e75c6c841b

Change-Id: I300152717163bc5419015c03b5dc23a2beb62422
2019-07-16 18:55:40 -07:00
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
Daniel Rosenberg
d7d475d470 Reland "Revert "rootdir / sdcard : Stop creating /data/media/obb.""
This reverts commit 997a2d93d7.

Reason for revert: This revert is needed, just also need some selinux rules for changes to the script that runs if this folder is present.

Bug: 136199978
Change-Id: Ie0544954965e3c90abc2f833c41949976c3bea65
(cherry picked from commit 35708b9d7b)
2019-07-16 02:55:21 +00:00
Kiyoung Kim
7b64a9a73a Merge "Run linkerconfig from init process"
am: 2f174171d7

Change-Id: I1c228374303842ce7d02cb30ee23c83ef43808d9
2019-07-15 17:39:34 -07:00
Kiyoung Kim
2f174171d7 Merge "Run linkerconfig from init process" 2019-07-16 00:32:13 +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
Xin Li
3fd963ed5e DO NOT MERGE - Merge pie-platform-release (PPRL.190705.004) into master
Bug: 136196576
Change-Id: I127ae61add2e34184b3c65ca64693cccf62b8a6d
2019-07-09 17:00:47 -07:00
Jooyung Han
b7a8f6e0d8 Merge "init: Create /data/apex/hashtree folder at boot" am: 4a8d436ad1
am: 15e01c675c

Change-Id: I5d4d75df534681c39d2095e2c671f95a5897295a
2019-06-18 22:50:38 -07:00
Treehugger Robot
4a8d436ad1 Merge "init: Create /data/apex/hashtree folder at boot" 2019-06-19 04:37:56 +00:00
Daniel Rosenberg
ca8f5ade91 Merge "Start Vold on early-fs" into qt-dev
am: d6253fc917

Change-Id: Ifc23a45193c3b615f1e64d1ab5b48dfa86aa5df7
2019-06-18 12:55:55 -07:00