Commit graph

3433 commits

Author SHA1 Message Date
David Anderson
6939583deb Merge "init: Add tests and document the new fnmatch behavior in ExternalFirmwareHandler." 2021-05-05 00:21:34 +00:00
Eric Biggers
1c51525f66 init: make reboot_on_failure not apply to manually stopped services
Add a new service flag SVC_STOPPING which tracks whether a service is
being manually stopped by init, and make the "reboot_on_failure" service
setting not apply when SVC_STOPPING is set.

This is needed for devices that use FDE, because otherwise the device
reboots during the following init script fragment:

    on property:vold.decrypt=trigger_shutdown_framework
        class_reset late_start
        class_reset main
        class_reset_post_data core
        class_reset_post_data hal

... because that stops all services, including apexd which has been
marked with reboot_on_failure since
https://android-review.googlesource.com/c/platform/system/apex/+/1325212.
So init was killing apexd, then rebooting the device because apexd
"failed" due to having been killed.  Making reboot_on_failure not apply
when init stops a service itself fixes the problem.

This is one of a set of changes that is needed to get FDE working again
so that devices that launched with FDE can be upgraded to Android 12.

Bug: 186165644
Test: Tested FDE on Cuttlefish
Change-Id: I599f7ba107e6c126e8f31d0ae659f0ae672a25e4
2021-05-03 21:38:50 -07:00
Inseob Kim
4664bbc6c7 Merge "Fix precompiled sepolicy logic" 2021-04-30 01:14:15 +00:00
Inseob Kim
28fdb6794c Fix precompiled sepolicy logic
If precompiled vendor policy has system_ext hash, system_ext also has to
have its hash, to use precompiled sepolicy.

Bug: 186727553
Test: remove system_ext's hash and see sepolicy compiled in runtime
Change-Id: I4af3418d614156b5e9cd0b0116c2814ba994ee81
2021-04-29 19:50:38 +09:00
Treehugger Robot
6cbc7e01b2 Merge "Allow a kernel bootconfig to set the qemu key" 2021-04-29 02:16:33 +00:00
Roman Kiryanov
6e20ff83ac Allow a kernel bootconfig to set the qemu key
The existing code has a lot of references to the
`ro.boot.qemu` and `ro.boot.qemu.something` properties
which is not supported by the bootconfig if we place
everything under `androidboot.qemu`.

Bug: 182291166
Test: getprop | grep qemu
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: Icb9d29c8dc39e1fa52a6f2ce43b4f42182b7995d
2021-04-28 15:31:52 -07:00
Treehugger Robot
c4a1a32e91 Merge changes from topic "debug_ramdisk_path"
* changes:
  init: adding fallback paths for debug ramdisk
  init: loading debug resources before chroot into first_stage_ramdisk
2021-04-28 16:27:34 +00:00
Bowgo Tsai
6cb4311f4d init: adding fallback paths for debug ramdisk
Currently the gki_4_19_pixel5 presubmit test uses an old
vendor_boot-debug.img from a release branch. Adding fallback
paths to load debug resources from /first_stage_ramdisk dir to
pass the presubmit.

This CL should be reverted later once the vendor_boot-debug.img
gets updated to store the debug resources on the root dir.

Bug: 186082603
Test: boot a device with boot-debug.img
Test: boot a device with vendor_boot-debug.img
Change-Id: I9fcd77fc5a60a15cff254e432e05f1c9122ad80d
2021-04-27 15:25:31 +08:00
Bowgo Tsai
64e92f946f init: loading debug resources before chroot into first_stage_ramdisk
Currently the debug resources might under /first_stage_ramdisk/*
of the ramdisk, if there is androidboot.force_normal_boot=1 in the
kernel cmdline to request init chroot into /first_stage_ramdisk dir.

To make a generic boot-debug.img works on devices with and without
this chroot, moving the debug resources to the root of the ramdisk.
And copy them for later use before the chroot.

Bug: 186082603
Test: boot a device with boot-debug.img
Test: boot a device with vendor_boot-debug.img
Change-Id: I052a92b2d26c7fdf749991fc55015ff68743efc2
2021-04-27 15:25:18 +08:00
Treehugger Robot
23a50b3860 Merge "[Bugfix]Fix userspace-reboot failure when backing_dev exists but zram not swapped on" 2021-04-23 00:28:49 +00:00
Jooyung Han
e5232a71b2 init: apexd is started in the current mount namespace
init starts services in "bootstrap" mount namespace until the "default"
mount namespace is ready even when init's current mount namespace is
"default".

apexd and linkerconfig are those processes to set up the mount
namespaces: apexd activates apexes and linkerconfig generates linker
configs.

Previously apexd is allowed to be started in the "current" namespace by
checking its "service name"(it should be "apexd"). But there can be a
certain environment apexd is started in a different way. For example, in
microdroid, apexd is started using "exec -- /system/bin/apexd --vm"
because it wants to run in a different execution mode.

So, instead of checking the service name, its executable's path is
checked against to allow apexd to be started in the current mount
namespace.

Bug: 179342589
Test: MicrodroidTestCase (microdroid boots)
Test: cuttlefish boots
Change-Id: I7c2490e15d481c28ddf382d2d3fdf58a78e467ec
2021-04-20 22:50:12 +09:00
David Anderson
19872d0156 init: Add tests and document the new fnmatch behavior in ExternalFirmwareHandler.
Bug: N/A
Test: atest CtsInitTestCases
Change-Id: I232db8416318ba31ea3f78cc07f235d9a47efac4
2021-04-16 13:35:11 -07:00
Suchang Woo
22fdd0ae13 ueventd: Allow pattern matching to find external firmware handler
Only the exact same devpath uevent can launch external handler specified
in ueventd.rc. So, you should specify all possible devpaths, even
firmware with different filenames on the same device. Pattern mactching
can be used to simplify this.

Test: atest CtsInitTestCases
Signed-off-by: Suchang Woo <suchang.woo@samsung.com>
Change-Id: If3b7a2cabb8055bf4b768d928f0fc0012da3c177
2021-04-16 13:35:10 -07:00
luwei9
8a3653cfe2 [Bugfix]Fix userspace-reboot failure when backing_dev exists but zram not swapped on
'/sys/block/zram0/backing_dev' will exist even if zram is not swapped on in some devices. And there is no reason to ensure that zram is swapped on if '/sys/block/zram0/backing_dev' exists. So, if we want to kill backing_dev during userspace reboot, we should check if zram is swapped on first.

TEST: as follow
 - adb root
 - adb shell swapoff /dev/block/zram0
 - adb shell echo 1 > /sys/block/zram0/reset
 - adb shell setprop test.userspace.reboot.flag 1
 - adb reboot userspace
 - (wait reboot ending) adb shell getprop test.userspace.reboot.flag (1 will be show if successful)

Signed-off-by: luwei9 <luwei9@xiaomi.com>
Change-Id: Icca569cf8d64bc024b867dae2ab789fc9e76445a
2021-04-15 08:08:20 +00:00
Roman Kiryanov
f4adb894cc Do not populate ro.kernel. properties in init
`ro.kernel.` is deprecated, emulator migrated to
`ro.boot.`.

Bug: 182291166
Test: presubmit
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: I074f9a63dc4e3edcc01930b2e8481efd1d85eb55
2021-04-14 20:45:55 -07:00
Yo Chiang
3841fdfa3c Merge "Load *_compat_cil_file from system_ext as well" 2021-04-13 05:48:04 +00:00
Hridya Valsaraju
2a8b028c04 Merge "Use property ro.product.enforce_debugfs_restrictions to enable debugfs restrictions" 2021-04-12 17:11:23 +00:00
Roman Kiryanov
0312c20a71 Populate ro.boot.dalvik.vm.checkjni from android.checkjni
emulator passes `android.checkjni` in the kernel
command which we want to use in
frameworks/base/core/jni/AndroidRuntime.cpp

Bug: 182291166
Test: getprop ro.boot.dalvik.vm.checkjni
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: If9473aa9492fa09d8de7cc8fb08614380e4e15f3
2021-04-07 15:55:21 -07:00
Roman Kiryanov
c755e5edf9 Populate ro.boot.debug.sf.nobootanimation from android.bootanim
emulator passes `android.bootanim=0` in the kernel
command line to disable boot animation.

Bug: 182336906
Test: boot emulator with -np-boot-anim
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: Id89a6c92dd4724cac414ffbf8ee731b2bfcc7195
2021-04-06 20:44:57 -07:00
Suchang Woo
8681f7e7a3 ueventd: Fix wrong argument index in devpath comparison
args[2](user name to run as) is used instead of args[1](devpath).

Test: atest CtsInitTestCases
Signed-off-by: Suchang Woo <suchang.woo@samsung.com>
Change-Id: Id271755993d55e332bad54d0414e2232071e5e8e
2021-04-06 11:15:28 +09:00
Hridya Valsaraju
6b7311fc99 Use property ro.product.enforce_debugfs_restrictions to enable debugfs
restrictions

Use the property ro.product.enforce_debugfs_restrictions to enable
debugfs restrictions instead of checking the launch API level. Vendors
can enable build-time as well as run-time debugfs restrictions by
setting the build flag PRODUCT_SET_DEBUGFS_RESTRICTIONS true which in
turn sets ro.product.enforce_debugfs_restrictions true as well enables
sepolicy neverallow restrictions that prevent debugfs access. The
intention of the build flag is to prevent debugfs dependencies from
creeping in during development on userdebug/eng builds.

Test: build and boot
Bug: 184381659
Change-Id: If555037f973e6e4f35eb7312637f58e8360c3013
2021-04-02 17:00:50 -07:00
Yi-Yo Chiang
20579011cf fs_mgr: Suppress SkipMountingPartitions log in ReadFstabFromFile
Minor refactoring and renaming, goal is to make the follow-up patch
easier to read.

Bug: 184132970
Test: Presubmit
Change-Id: I66416161b30ac310934d901cbaf11bc926e2cbf7
2021-04-02 05:23:02 +00:00
Roman Kiryanov
bcc7946ef0 Populate all other emulator properties as ro.boot.qemu.*
Bug: 182291166
Test: getprop | grep "ro\.boot\.qemu\."
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: I0d2a4a9edd87999b35fac8496e9cda93fc7d0cf1
2021-04-01 11:39:30 -07:00
Yi-Yo Chiang
731d2473da Load *_compat_cil_file from system_ext as well
So we can extend platform policies with target specific compat rules.
This use case surface in the context of system only upgrade, when the
vendor policy cannot be updated, then the system_ext partition can
contain target specific compat policies.

Bug: 183362912
Test: Presubmit
Change-Id: Ic6436eb8a269f07f932331dedf7dbaa629538ade
2021-03-30 13:05:50 +08:00
Roman Kiryanov
4ddfd023cc Populate more emulator properties to ro.boot.
ro.boot.config.low_ram
ro.boot.dalvik.vm.heapsize
ro.boot.debug.hwui.renderer
ro.boot.debug.stagefright.ccodec
ro.boot.opengles.version

Bug: 182291166
Test: presubmit
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: I4d7ee19feb13a418a95f31be7534df98dfaeb3e3
2021-03-22 14:34:36 -07:00
Roman Kiryanov
94ce40a527 Do not populate ro.kernel.qemu in ProcessKernelCmdline
The emulator migrated to `ro.boot.qemu`.

Bug: 182291166
Test: presubmit
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: Iaa3bdff5cc1efa79c21ae2dc2bdf7ec74731f66c
2021-03-22 14:18:44 -07:00
Will McVicker
8891c2002e init: fix debuggable paths for recovery mode
Since recovery mode doesn't switch root to /first_stage_ramdisk, we need
to update the debuggable file paths for recovery mode. Without this,
adb needs to be authorized in recovery mode even with a debug
vendor_ramdisk.

Bug: 182612208
Test: verify adb is authorized on pixel 5
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: I557429e1834efcdd92ba0e135377055ffa677137
2021-03-17 18:53:48 +00:00
Alistair Delva
fb1cffb46b Merge "init: check for verifiedbootstate in properties" 2021-03-15 04:03:17 +00:00
Inseob Kim
b56165cce3 Merge "Allow precompiled sepolicy w/o system_ext/product" 2021-03-14 15:28:42 +00:00
Roman Kiryanov
dce1f88bfb Merge "Populate ro.boot.qemu for the emulator device" 2021-03-12 06:06:03 +00:00
Roman Kiryanov
7787e70417 Merge "Populate only emulator specific properties into ro.kernel." 2021-03-12 06:05:35 +00:00
Roman Kiryanov
a3d37ac9b2 Merge "Move the androidboot. literal into its own variable" 2021-03-12 04:32:13 +00:00
Inseob Kim
d99d977f17 Allow precompiled sepolicy w/o system_ext/product
Some devices might not have system_ext or product partitions. But init
has been refusing to use precompiled sepolicy because init always checks
system / system_ext / product hashes, regardless of existence. This
makes system_ext and product optional, so hash check can be skipped for
non-existing partitions. Of course system is always checked.

Bug: 181640066
Test: boot microdroid and cuttlefish, see precompiled sepolicy works
Change-Id: I32c296fffd894c27097e8b4e10ade977a21d61ab
2021-03-12 11:40:15 +09:00
Roman Kiryanov
4a47c74b75 Populate ro.boot.qemu for the emulator device
Bug: 182291166
Test: presubmit
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: Ied78f42363c1f6580fe6e5660b14c257960aed98
2021-03-11 16:49:17 -08:00
Roman Kiryanov
1a705d4943 Populate only emulator specific properties into ro.kernel.
`ro.kernel.` is an emulator specific prefix.

Bug: 182291166
Test: presubmit
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: Ie4a19127f05f3074ccb02bd055711e9b70702ba6
2021-03-11 16:48:26 -08:00
Roman Kiryanov
ccc15c5dbd Move the androidboot. literal into its own variable
Bug: 182291166
Test: presubmit
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: I19f25671c82fff34dd52e3557361c4340706aab0
2021-03-11 16:46:00 -08:00
Alistair Delva
c19a7dd30e Merge changes from topic "bootconfig-selinux-property"
* changes:
  Allow selinux to be set by bootconfig
  Allow android_dt_dir to be set by bootconfig
2021-03-11 15:52:02 +00:00
Devin Moore
0a799bdfd6 Handle "hardware" bootconfig parameter as "androidboot.hardware"
The parameter "androidboot.hardware" has been removed from bootconfig
and replaced by "hardware" parameter.

Test: launch_cvd with 4.19 and 5.10 kernels
Test: atest CtsFsMgrTestCases
Bug: 173815685
Change-Id: I627426ae1bd0a165b70b8f2584ec184abfb4236f
2021-03-09 14:10:48 -08:00
Devin Moore
6c01baf075 init: check for verifiedbootstate in properties
This check in export_oem_lock_status happens after PropertyInit() so
all of the ro.boot.* properties will be set. There is no need to import
the kernel cmdline again.

Test: build and boot cuttlefish
Bug: 173815685
Change-Id: I5df7c0105566d4617442dbb8e77eb26e465775f1
2021-03-09 13:56:25 -08:00
Alistair Delva
63594a4dbc Allow selinux to be set by bootconfig
The androidboot.selinux property is loaded in a special way, because it
happens in the "selinux_setup" stage, and not the true second stage.
Allow it to be passed through bootconfig instead of only via the kernel
cmdline.

Bug: 173815685
Test: launch_cvd -extra_kernel_cmdline androidboot.selinux=permissive
Test: launch_cvd -guest_enforce_security=false [bootconfig method]
[..]
init: Permissive SELinux boot, forcing sys.init.perf_lsm_hooks to 1.
[..]
Change-Id: I92003c7a2dac5d6e7d0e0f4ee2757f86cc0087c7
2021-03-09 19:18:50 +00:00
Alistair Delva
3bb240bd4c Allow android_dt_dir to be set by bootconfig
The androidboot.android_dt_dir property is special, because it is loaded
to find out where to get the other DT properties from, and those DT
properties are supposed to override the cmdline/bootconfig ones. So, it
need special casing, and that special case lacked bootconfig support.

Bug: 173815685
Test: launch_cvd -extra_kernel_cmdline androidboot.android_dt_dir=/tmp
[..]
init: Using Android DT directory /tmp
[..]
Change-Id: Ie0958dd0a96394d65f6568653b754ea6f885212e
2021-03-09 19:14:17 +00:00
David Anderson
c90fce4387 Merge "init: only mlock() system pages when performing snapuserd transitions." 2021-03-08 19:32:34 +00:00
Devin Moore
7c98b89886 Merge changes from topic "bootconfig_args"
* changes:
  fs_mgr: handle more bootconfig parameters
  init: handle more bootconfig parameters
2021-03-08 18:27:50 +00:00
Kiyoung Kim
fcb28f5d30 Merge "Check if service is executed before APEX is ready" 2021-03-07 23:56:06 +00:00
David Anderson
9fd8862741 init: only mlock() system pages when performing snapuserd transitions.
Bug: 181032115
Test: manual test w/ VABC OTA
Change-Id: Ib4d2856b9b5eaf8688534f9d84edeb64d4b3244d
2021-03-05 15:44:25 -08:00
Devin Moore
79058486d2 init: handle more bootconfig parameters
As parameters are moved from kernel cmdline to bootconfig,
first_stage_init needs to be updated to handle the new
location.
/proc/bootconfig should be checked first, if not present, then check
/proc/cmdline.

Test: launch_cvd
Test: launch_cvd with 4.19 kernel artifacts that do not support
bootconfig
Test: Both of the above configurations with --num_instances 0 or 4
Test: Both configurations with androidboot.boot_devices or
androidboot.boot_device set
Bug: 173815685

Change-Id: I03743f922351d58375e8b9a903899b8bc54bd71e
2021-03-05 09:21:19 -08:00
Kiyoung Kim
0cbee0de2a Check if service is executed before APEX is ready
Any service which is executed when Runtime apex is mounted, but
linkerconfig is not updated can fail to be executed due to missing
information in ld.config.txt. This change updates init to have a status
variable which contains if current mount namespace is default
and APEX is not ready from ld.config.txt, and use bootstrap namespace if
it is not ready.

Bug: 181348374
Test: cuttlefish boot succeeded
Change-Id: Ia574b1fad2110d4e68586680dacbe6137186546e
2021-03-05 16:42:20 +09:00
Treehugger Robot
900c6010e0 Merge "Detect the absence of the default fstab" am: d9b7c9b4a7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1607906

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1f5b467eab74cc86c525a09210811e51459dab97
2021-03-02 21:50:30 +00:00
Jiyong Park
c6f19688f8 Detect the absence of the default fstab
This is a follow-up of I828ce999be6d786bf46dd5655dfda81d046906ab. The
change introduced a behavioral change that fstab is read twice: before
root is changed to /first_stage_ramdisk, and once again after that.
Previously, that happend only after the root is switched. That change
caused a problem when there is no fstab in DT and fstab is provided via
a file. The fstab file has been at
/first_stage_ramdisk/fstab.<hardware> because that file was supposed to
be read after the root switch.

With the change, init fails to read the fstab during the first attempt
because there is no /fstab.<hardware> at the moment. Here comes the
problem. Although it failed to read fstab, DoCreateService() is invoked
because ReadFirstStageFstab() doesn't report the failure; it returns an
empty fstab object. As a result, DoCreateDevices() is called but it
doesn't create the dm linear device because it couldn't find an fstab
entry having `logical` option.

Then after /first_stage_ramdisk becomes the root, the fstab file is
correctly read. But since the prior run of DoCreateDevices() is recorded
as 'done', init doesn't try to do that again; dm linear device is never
created. Then we fail to mount any of the logical partitions.

This change fixes the problem by modifying ReadFirstStageFstab()
function so that the failure is correctly reported back to the caller.
When it fails, DoCreateDevices() is not called.

Bug: N/A
Test: Watch TH
Change-Id: Idf2dbc6c0fb6c311ab3f5ff1f28315f7daa2b4ce
2021-02-26 17:58:34 +09:00
Treehugger Robot
c30a2b00ca Merge "first_stage_mount: Create snapshot devices before launching first_stage_console" am: 0c931aa993
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1565166

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6d92b22489e5bae7acbe7ae7e0ecbf3f738ba719
2021-02-25 21:49:12 +00:00