Commit graph

1237 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Treehugger Robot
4a8d436ad1 Merge "init: Create /data/apex/hashtree folder at boot" 2019-06-19 04:37:56 +00:00
Daniel Rosenberg
c6e8972588 Start Vold on early-fs
We need vold on early-fs so we can handle userdata checkpointing.
Without this, devices will take an extra minute or two as checkpointing
related vdc calls attempt to reach vold before it is available.

Bug: 134114000
Test: Boot, see vold has started before vdc checkpointing tries to call
      out to vold.
Merged-In: Idfdb304503a163fbb91f9317949eb98c06fecce1
Change-Id: Idfdb304503a163fbb91f9317949eb98c06fecce1
2019-06-18 19:25:56 +00:00
Jooyung Han
baa7c13c31 init: Create /data/apex/hashtree folder at boot
/data/apex/hashtree is internal to apexd, hence 0700

Bug: 120058143
Test: m && boot device
Change-Id: I3637a3cbedf871e982e02d50c21e0fe53e6b4824
2019-06-14 15:35:49 +09:00
Neil Fuller
e59703319f Merge "Switch tzdatacheck to comparing tzdata module file" 2019-06-10 17:40:51 +00:00
Neil Fuller
09bdb325a7 Switch tzdatacheck to comparing tzdata module file
The old "time zone updates via APK" feature installs time zone data
files in /data. tzdatacheck is run during boot to guard against an
OTA leaving the data in /data older, or in a different format, than the
files that exist elsewhere on device. If such files existed the system
could use old versions of tzdb (and related) data or even end up
unstable.

Soon, the time zone data mainline module will be made "functionally
mandatory" by the removal of most time zone data files from the
runtime module APEX, i.e. the time zone data module cannot be absent,
and the runtime module won't have files to compare against.

This change modifies the command line args for tzdatacheck to reference
the contents of time zone data module instead of the runtime module.

Bug: 132168458
Test: Build / boot / inspect logcat
Change-Id: Iac8023b7cbb72213df344d603c121caa867a196f
2019-06-10 11:02:44 +00:00
Tom Cherry
fdeca99c4b init.rc: move rlimit setting earlier
There is no reason that rlimits cannot be set earlier than they are,
and apexd-bootstrap may want to set the priority service option, which
would require that these rlimits have been set, so we move these to
the beginning of early-init.

Bug: 134668377
Test: apexd-bootstrap can set the priorty service option
Change-Id: I8040190cd4dc5e141784496ae65cfab80d9cad53
2019-06-06 18:18:14 +00:00
Tao Bao
c61ef45379 DO NOT MERGE Start update_verifier early in late-fs.
We used to start update_verifier after mounting userdata (post-fs-data),
as part of zygote-start. This leads to issues in practice for security
updates, where an A/B device falls back into the old slot (for any
reason, which unrelates to this change) but failing to boot due to
upgraded key blob. It essentially breaks the fallback capability offered
by A/B OTA.

This CL mitigates the issue by starting update_verifier early, before
mounting userdata. This avoids the device from falling back to the old
slot with an already-upgraded key blob. update_verifier loses the
opportunity of verifying _all_ the updated blocks based on the info
that's stored in userdata.  Instead it will only trigger the minimal
read to finish the work of marking a successful boot. This is a
trade-off in P to avoid putting the device in a bad state after
fallback, which will be improved in Q by better handling the fallback
path in vold.

Bug: 131176531
Test: Flash and boot crosshatch. Check the start of update_verifier and
      it marks a successful boot.
Change-Id: I3f4c4333ff38772a9a93c9d027d497db11de1d63
(cherry picked from commit 79cfc7d5a8)
2019-05-10 21:52:50 +00:00
Treehugger Robot
9243da9008 Merge "Apply initial settings for blkio cgroup" 2019-05-07 08:15:35 +00:00
Rick Yiu
a8aaf198d5 Apply initial settings for blkio cgroup
Bug: 111422845
Test: values are applied
Change-Id: Id28d9619fc2fd2287fe656b8032025184ae7f631
2019-05-03 11:58:13 +08:00
Martijn Coenen
70788f93ba Support for stopping/starting post-data-mount class subsets.
On devices that use FDE and APEX at the same time, we need to bring up a
minimal framework to be able to mount the /data partition. During this
period, a tmpfs /data filesystem is created, which doesn't contain any
of the updated APEXEs. As a consequence, all those processes will be
using the APEXes from the /system partition.

This is obviously not desired, as APEXes in /system may be old and/or
contain security issues. Additionally, it would create a difference
between FBE and FDE devices at runtime.

Ideally, we restart all processes that have started after we created the
tmpfs /data. We can't (re)start based on class names alone, because some
classes (eg 'hal') contain services that are required to start apexd
itself and that shouldn't be killed (eg the graphics HAL).

To address this, keep track of which processes are started after /data
is mounted, with a new 'mark_post_data' keyword. Additionally, create
'class_reset_post_data', which resets all services in the class that
were created after the initial /data mount, and 'class_start_post_data',
which starts all services in the class that were started after /data was
mounted.

On a device with FBE, these keywords wouldn't be used; on a device with
FDE, we'd use them to bring down the right processes after the user has
entered the correct secret, and restart them.

Bug: 118485723
Test: manually verified process list
Change-Id: I16adb776dacf1dd1feeaff9e60639b99899905eb
2019-04-26 14:04:59 +02:00
Wei Wang
a91c5f700e init.rc: set fsck log permission on post-fs-data
Fixes: 130829745
Test: build and trigger fsck
      crosshatch:/ # ls -l /dev/fscklogs/log
      -rwxrwx--- 1 root system 1584 1970-04-08 14:48 /dev/fscklogs/log
Change-Id: Ifd0734e121d07b941a73d7cabde04928ce5e5c59
2019-04-19 11:46:21 -07:00
Treehugger Robot
a7c103eb8e Merge "init: set oom_adj early before fork vendor_init" 2019-04-19 02:17:50 +00:00
Wei Wang
45d8174fe7 init: set oom_adj early before fork vendor_init
right now vendor_init is forked before we set oom_adj for init which
leaves a chance vendor_init could be killed in heavy memory pressure.

this CL set the oom_adj before forking everything to ensure all native
have correct oom_adj settings.

Fixes: 130824864
Test: procrank -o
Change-Id: I8af129076c3efa29f7b781459449f8f2dc853c98
2019-04-18 16:14:08 -07:00
Yifan Hong
122e78248e charger: Allow to rw /sys/power/[state,wakeup_count]
charger needs to suspend the device when the power goes away
when it doesn't have root. These two files are marked with
group system, user system, mode 0600 in 'on boot', but
it is not executed in charger. Hence, move these actions
to 'on init'.

Test: no failure in libsuspend in charger

Bug: 129138950

Change-Id: I787b935b4ff6177601329aeedccdac361b119ca3
Merged-In: I787b935b4ff6177601329aeedccdac361b119ca3
2019-04-09 13:35:07 -07:00
Treehugger Robot
99ba4b36e8 Merge "init.rc: tune F2FS to be aligned to system settings" 2019-04-01 16:10:28 +00:00
Jaegeuk Kim
f65df964c0 init.rc: tune F2FS to be aligned to system settings
Android sets /proc/sys/vm/dirty_expire_centisecs to 200, so f2fs
doesn't need to do checkpoint in 60 seconds.

Bug: 127511432
Change-Id: I2ba0623053d4480b82003eb1cca85ff03c61fc0f
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-03-29 22:43:29 +00:00
Tim Murray
1504cb5b6e Set /proc/pressure/memory file permissions
Change access mode and ownership for /proc/pressure/memory file
to allow system components access memory pressure information.

Bug: 129476847
Change-Id: I25b6bc9d47aee857936f050b66e7bee6363b53be
Signed-off-by: Tim Murray <timmurray@google.com>
2019-03-28 22:12:06 +00:00
Victor Hsieh
59183120c2 Initialize fs-verity keys in shell script
This gives us two benefits:
  - Better compatibility to keyctl(1), which doesn't have "dadd"
  - Pave the way to specify key's security labels, since keyctl(1)
    doesn't support, and we want to avoid adding incompatible option.

Test: See keys loaded in /proc/keys
Bug: 128607724
Change-Id: Ia45f6e9dea80d037c0820cf1fd2bc9d7c8bb6302
2019-03-22 09:18:00 -07:00
Xiaoyong Zhou
66fc7eb195 Enable fsverity signature checking
This CL enable fsverity signature checking.

Bug: 112038861
Test: cat /proc/sys/fs/verity/require_signatures -> 1
Change-Id: I57aaf6094aa503bdcac93306cafd7f71f202e711
2019-03-18 14:28:18 -07:00
Andreas Gampe
e8565ac94a Init: Load fsverity keys earlier
Keys may be required for apex updates (post-installs), so load them
before starting apexd.

Bug: 125474642
Test: m
Test: manual
Change-Id: I32ddb6ae6854334e8ee7e195173ecfaed565d783
2019-03-15 15:14:35 -07:00
Treehugger Robot
4cd0914048 Merge changes from topic "apex_earlymount_no_bionic_bindmount"
* changes:
  /bionic path is gone
  Revert "Handle adb sync with Bionic under /bionic"
  Don't bind-mount bionic files
2019-03-15 09:02:18 +00:00
Gavin Corkery
ff3c13f52f Merge "Rename data/pkg_staging to data/app-staging." 2019-03-14 14:14:38 +00:00
Jiyong Park
7b4801a921 Don't bind-mount bionic files
Bind-mounting of the bionic files on /bionic/* paths no longer required
as there are direct symlinks from bionic files in /system partition to
the corresponding bionic files in the runtime APEX. e.g.,

/system/lib/libc.so -> /apex/com.android.runtime/lib/bionic/libc.so

Bug: 125549215
Test: m; devices boots
Change-Id: I4a43101c3e3e2e14a81001d6d65a8a4b727df385
2019-03-14 07:35:54 +09:00
Martijn Coenen
13b5c3bee7 Merge "Create /metadata/apex/[sessions]." 2019-03-13 07:46:32 +00:00
Martijn Coenen
4517e57ff5 Create /metadata/apex/[sessions].
For storing persistent apex session state.

Bug: 126740531
Test: builds
Change-Id: Ibf280764977768956b5512b2252d22ceaba31c1e
2019-03-12 22:05:20 +01:00
Gavin Corkery
8df32193f3 Rename data/pkg_staging to data/app-staging.
Test: atest apex_e2e_tests
Bug: 126330086

Change-Id: Ic5729d60046e8825a2a94e3c3483ea8232a69ed2
Merged-In: Ic5729d60046e8825a2a94e3c3483ea8232a69ed2
2019-03-12 15:38:44 +00:00
Xiaoyong Zhou
b29b27ec7f Change mini-keyctl command format.
This CL change the mini-keyctl tool to make it compitable with libkeyctl
tool to make it more useful.

Bug: 112038861
Test: mini-keyctl padd asymmetric 'desc' .fs-verity < /path/to/cert.der
Test: mini-keyctl unlink <key_id> <keyring_id>
Test: mini-keyctl restrict_keyring <keyring_id>

Change-Id: I950f07c7718f173823ce5a5cd08e0d1a0e23a007
2019-03-08 09:59:42 -08:00
David Anderson
1c1850fad2 Merge "Create /metadata/password_slots during boot." 2019-03-07 16:20:01 +00:00
David Anderson
0664f31dd0 Create /metadata/password_slots during boot.
This directory is used to store the Weaver/GateKeeper slot map so GSIs
do not overwrite host keys in secure storage.

Bug: 123716647
Test: /metadata/password_slots exists after boot
Change-Id: Ib0ca13edec38e68cba1fc2124465571feedc4be7
2019-03-05 22:18:14 -08:00
Jiyong Park
dcbaf9f41b Activate system APEXes early
Summary: Boot sequence around apexd is changed to make it possible for
pre-apexd processes to use libraries from APEXes. They no longer need to
wait for the apexd to finish activating APEXes, which again can be
done only after /data/ is mounted. This improves overall boot
performance.

Detail: This change fixes the problem that processes that are started
before apexd (so called pre-apexd processes) can't access libraries
that are provided only by the APEXes but are not found in the system
partition (e.g. libdexfile_external.so, etc.). Main idea is to activate
system APEXes (/system/apex/*.apex) before /data is mounted and then
activate the updated APEXes (/data/apex/*.apex) after the /data mount.

Detailed boot sequence is as follows.

1) init prepares the bootstrap and default mount namespaces. A tmpfs is
mounted on /apex and the propagation type of the mountpoint is set to
private.

2) before any other process is started, apexd is started in bootstrap
mode. When executed in the mode, apexd only activates APEXes under
/system/apex. Note that APEXes activated in this phase are mounted in
the bootstrap mount namespace only.

3) other pre-apexd processes are started. They are in the bootstrap
mount namespace and thus are provided with the libraries from the system
APEXes.

4) /data is mounted. init switches into the default mount namespace and
starts apexd as a daemon as usual.

5) apexd scans both /data/apex and /system/apex, and activate latest
APEXes from the directories. Note that APEXes activated in this phase
are mounted in the default namespaces only and thus are not visible to
the pre-apexd processes.

Bug: 125549215
Test: m; device boots
Change-Id: I21c60d0ebe188fa4f24d6e6861f85ca204843069
2019-03-05 09:47:49 +09:00
Jiyong Park
4ba548d845 mount /apex during first_stage init
/apex is not mounted via init.rc but directly by the first_stage init
before the mount namespaces are configured.

This allows us to change the propagation type for /apex mount point to
private to isolate APEX activatesions across post- and pre-apexd
processes.

Bug: 125549215
Test: m; device boots to the UI

Change-Id: I10e056cd30d64cb702b6c237acd8dab326162884
2019-03-04 16:22:41 +09:00
Rick Yiu
2b3bf84373 Add blkio cgroup to libprocessgroup
To differentiate IO priority for different groups.

Bug: 111422845
Bug: 117857342
Test: tasks are assigned to the group as expected
Change-Id: Ibb108d1b8e0f720f7ac4cab248b3c33d35e5483d
2019-02-27 11:23:14 +08:00
Treehugger Robot
61b2016881 Merge "Move tzdatacheck execution after apex is mounted" 2019-02-25 13:30:36 +00:00
Neil Fuller
ada7e4928a Move tzdatacheck execution after apex is mounted
tzdatacheck references files in the runtime apex so should
not be executed before the apex mounts are ready.

Test: Manual tests (see b/123270813); observed tzdatacheck running after
      apex files are mounted
Bug: 123270813
Bug: 116191025
Bug: 119293618
Bug: 113373927
Change-Id: I249d127c1d568bc5025d81b0bb4187c81363d897
2019-02-22 16:07:22 +00:00
Gavin Corkery
124a4bc791 Rename data/staging to data/pkg_staging.
Test: Build and flash, atest apex_e2e_tests
Fixes: 122999313
Change-Id: I878ee41f804956ee7533d64e844ce98e5a8afacc
Merged-In: I878ee41f804956ee7533d64e844ce98e5a8afacc
2019-02-19 15:46:22 +00:00
Jiyong Park
407b000fe4 apexd is started much earlier to create loopback devices
This change fixes the problem that apexd is delaying the entire boot
sequence while waiting for the loopback devices to be created. The delay
was as big as 50 ms per a loopback device.

With this change, apexd is started much earlier: from "on post-fs-data"
to "on init". When it is first started, it scans /system/apex to
determine the number of APEXes and creates that number of loopback
devices priori. Since then it enters into the binder loop.

When the data partition is mounted, init lets apexd to initiate the
apexd boot sequence where APEXes in /data is scanned, verified, and
activated. Since the creation of the loopback devices were requested far
before, it is very likely that dev nodes for the devices are ready at
this moment (even if not, this isn't a lose).

Bug: 123404717
Bug: 123772265
Test: compare boot times.
init_zygote_START_TIME_avg is improved from 2831ms to 2622ms on blueline
Change-Id: I12450cee44aa4d17a11def62261c2f82d3f2c718
2019-02-09 14:42:38 +09:00
Joel Fernandes
ae7f052328 init: set the sys.use_memfd property to false
The sys.use_memfd property is set by default to false in Android
to temporarily disable memfd, till vendor and apps are ready for it.
The main issue: either apps or vendor processes can directly make ashmem
IOCTLs on FDs they receive by assuming they are ashmem, without going
through libcutils. Such fds could have very well be originally created with
libcutils hence they could be memfd. Thus the IOCTLs will break.

Set default value of sys.use_memfd property to true once the issue is
resolved, so that the code can then self-detect if kernel support is present
on the device. The property can also set to true from adb shell, for
debugging.

Bug: 113362644

Change-Id: I0f572ef36cac2a58fe308ddb90bbeffbecdaed3b
Signed-off-by: Joel Fernandes <joelaf@google.com>
2019-02-07 00:40:22 +00:00
Treehugger Robot
4fdc2ce2bb Merge "apexd: Create top-level /data/apex folders at boot" 2019-02-06 16:58:23 +00:00
Nikita Ioffe
bc744dc98f apexd: Create top-level /data/apex folders at boot
- package manager needs to read from /data/apex/active, hence 0750
- both /data/apex/backups and /data/apex/sessions are internal to apexd,
  hence 0700

Bug: 123927167
Fixes: 123927167
Test: apex_e2e_tests, flashall -w & checked folders were created
Change-Id: I06c28328afe4945d082acd890401651bd37fcb20
2019-02-06 11:49:46 +00:00