Commit graph

3547 commits

Author SHA1 Message Date
Inseob Kim
94c2593ea0 Remove RECOVERY_AS_BOOT check for init_first_stage
This has kept adb_debug.prop from being installed.

Ignore-AOSP-First: fixes sc-release test breakage

Bug: 192432810
Test: build ramdisk-debug.img and see contents
Change-Id: I254579d2c6427213f40e9ae8e50d046e19390ba5
2021-06-30 11:35:21 +00:00
Inseob Kim
86454f80ef Merge "Completely migrate init first stage to Soong" into sc-dev 2021-06-24 23:21:04 +00:00
Devin Moore
2d93a2a100 reboot_utils: Check bootconfig for reboot parameters
Androidboot parameters have moved from /proc/cmdline to /proc/bootconfig
so we need to check both places in reboot_utils.
"ro.boot.*" properties can not be used because this is initialized
before the properties are set.

Test: boot Cuttlefish with init_fatal_panic and
init_fatal_reboot_target in bootconfig and in cmdline
Bug: 191494101

Merged-In: I6c230496ec1c3632470d20ff4a31f28db96ea71b
Change-Id: I6c230496ec1c3632470d20ff4a31f28db96ea71b
2021-06-23 11:27:52 +00:00
Inseob Kim
7418252a4e Completely migrate init first stage to Soong
adb_debug.prop is migrated too. And ramdisk_available is added to all
dependencies.

Bug: 187196593
Test: boot
Change-Id: I59cd149e0021211b8fd59c44b93bbf18dc8637bf
Merged-In: I59cd149e0021211b8fd59c44b93bbf18dc8637bf
2021-06-23 04:26:12 +00:00
David Anderson
1de7384c10 Use std::shared_ptr in Epoll's callback list.
Ignore-AOSP-First: Awaiting security triage
Bug: 187862380
Bug: 190126442
Test: CtsInitTestCases
Change-Id: Ibb34a6b8a5675dbc515b7f8a43d7eecf2084510c
(cherry picked from commit aea9781530)
2021-06-09 19:59:20 +00:00
Yi-Yo Chiang
84fe96bfbc first_stage_mount: mount point must be canonical path
Ban weird paths such as /../system or //vendor in first stage mount.
Add utility function fs_mgr_create_canonical_mount_point() that:

* mkdir(mount_point) to ensure mount_point's existence
* Test that realpath(mount_point) =?= mount_point

Bug: 188898525
Test: Presubmit
Test: Boot CF
Change-Id: Iaf2ec52701277f26cc81f3e15a47b6083a788334
Merged-In: Iaf2ec52701277f26cc81f3e15a47b6083a788334
(cherry picked from commit 3431d52675)
2021-06-03 15:53:12 +08:00
Yi-Yo Chiang
18a6cc2bac Make fs_mgr_overlayfs_mount_fstab_entry() available for user builds
Rename fs_mgr_overlayfs_mount_fstab_entry() to
fs_mgr_mount_overlayfs_fstab_entry() and move it out of
fs_mgr_overlayfs.cpp to make it available for user builds.

Add checks to unsure overlayfs mount point doesn't contain symbolic
link or /../.

Check the mount point with an allowlist if user build. The mount point
should either be /vendor, /product ... or their submounts, or strict
submounts of /mnt/vendor and /mnt/product.

Bug: 188862155
Test: Boot test with overlayfs mount entries on user build
Change-Id: I3b60dfa4b63cf2ae0754f53d1d08365aa7be1ee0
Merged-In: I3b60dfa4b63cf2ae0754f53d1d08365aa7be1ee0
(cherry picked from commit 23816e84ca)
2021-05-27 16:55:28 +08:00
Yi-Yo Chiang
94d1f3b4fa fs_mgr_overlayfs: Polish fs_mgr_overlayfs_mount_fstab_entry()
* Add logs.
* Append "override_creds=off" overlayfs mount flag only if
  fs_mgr_overlayfs_valid() returns kOverrideCredsRequired.
  Pre-4.6 kernels or kernels without the override_creds patch don't
  need or don't recognize the override_creds mount flag.
  (Background: I832c8ca3fce0269bdef4ce988541adb7ba9662ed)
* mkdir(mount_point) before mount() to ensure the mount point exists.
  This could happen if the mount point is in a tmpfs, such as /mnt.

Bug: 188862155
Test: Boot to normal with overlayfs mount entries in first stage fstab
Change-Id: I1a05696346610d7fd61de6d25c379520fd58ca9b
Merged-In: I1a05696346610d7fd61de6d25c379520fd58ca9b
(cherry picked from commit dcf1c1f462)
2021-05-26 07:31:19 +00:00
Yi-Yo Chiang
aa061738bc first_stage_mount: Remove "overlay" hack from InitRequiredDevices()
GetDmVerityDevices() should filter out overlayfs fstab entries in the
first place, so InitRequiredDevices() don't need to filter out overlayfs
pseudo device names.

Bug: 188862155
Test: Boot to normal with overlayfs mount entries in first stage fstab
Change-Id: I0ac8b7ac0f21daa0c191580d9349adf217854864
Merged-In: I0ac8b7ac0f21daa0c191580d9349adf217854864
(cherry picked from commit 87290f8e9b)
2021-05-26 07:31:12 +00:00
Tianjie Xu
0a2bb08371 Merge "Add a unittest for fingerprint calculation" am: 023ac49db2 am: b026f15df0 am: 8408b03092
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1698093

Change-Id: Ic7cca5299f5a9f06cfc701990bcf781e3103f82f
2021-05-11 07:00:04 +00:00
Tianjie
69e880e257 Add a unittest for fingerprint calculation
Add a test to check the build fingerprint when the dynamic build
id is in use.

Bug: 186786987
Test: th
Change-Id: I44d6be0c18552f319bcb8d19cca5659ce580d26c
2021-05-10 12:11:28 -07:00
Tianjie Xu
87eeec4d40 Merge "Support appending vbmeta digest to id/fingerprint" am: 57b9a5370e am: 8b6d881071 am: 4e83aa5beb
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1695266

Change-Id: I3be9c44e07194c9c317677fe33e9dc1568548783
2021-05-09 00:10:02 +00:00
Tianjie Xu
57b9a5370e Merge "Support appending vbmeta digest to id/fingerprint" 2021-05-08 22:56:56 +00:00
Roman Kiryanov
bc7acaadda Merge "Remove the tech debt from the property_service" am: 8371ec25ab am: 9beeed390c am: 8456b731d8
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1698925

Change-Id: I1cdeeeed17212edcdd120cdddfd79e2ed7106231
2021-05-06 23:58:51 +00:00
Tianjie
becfa77e5d Support appending vbmeta digest to id/fingerprint
Background in http://go/compatible-build-fingerprint. To uniquely
identify the mixed build, we plan to append the unique vbmeta digest
to ro.build.id.

If BOARD_USE_VBMETA_DIGTEST_IN_FINGERPRINT is true, the build system
will not set ro.build.id. Instead, init will set it at runtime, by
appending the digest to the legacy build id.

Bug: 186786987
Test: build and boot a device with new build id
Change-Id: Idea57df599bfd6eede760671e2555541f7dc3f21
2021-05-06 22:31:54 +00:00
Roman Kiryanov
2d1a401b6e Remove the tech debt from the property_service
emulator migrated to bootconfig, we don't use
the kernel command line to pass userspace properties.

Bug: 182291166
Test: boot
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: Iff2f627aec64b7ba2240444639acedc76a1aa806
2021-05-06 11:55:29 -07:00
Treehugger Robot
641371794c Merge "Revert "init: adding fallback paths for debug ramdisk"" am: 0d712ad3a2 am: e21050474a am: 05c21f24f7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1697285

Change-Id: Ic0b4d1855fe4deeee22e0390e7c59062f8f04f70
2021-05-06 08:18:26 +00:00
Treehugger Robot
0d712ad3a2 Merge "Revert "init: adding fallback paths for debug ramdisk"" 2021-05-06 07:05:41 +00:00
David Anderson
6870933e8e Merge "OverlayFS support for fstab" am: 7cdbd8e64d am: 1e5400b429 am: 2f8663919e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1691625

Change-Id: I5b951b3340d095a2afddb7dbf7bf71a53a6db0d9
2021-05-06 02:51:15 +00:00
David Ng
d926aded73 OverlayFS support for fstab
Add overlayfs (lowerdir) mount entry support to fstab.

  overlay  <final dir>  overlay lowerdir=/1:/2

E.g.
  overlay /vendor overlay lowerdir=/odm/vnd_ovl1/1:/odm/vnd_ovl2

Test: Ensure mounting with fstab overlayfs entry
Change-Id: Ib025e203f8ac1836ab62dfa96fb14e8e108f82fb
2021-05-05 09:30:18 -07:00
Bowgo Tsai
26c1b74998 Revert "init: adding fallback paths for debug ramdisk"
This reverts commit 6cb4311f4d.

Reason for revert: no need to keep the compatibility now

Bug: 186485355
Change-Id: Iffdf3abebc17f32e36f3b3fe2b4f9c2592da9653
Test: TreeHugger
2021-05-05 10:31:29 +00:00
David Anderson
b4d299618f Merge "init: Add tests and document the new fnmatch behavior in ExternalFirmwareHandler." am: 6939583deb am: b383eb7f99 am: eb50ea4ea3
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1677040

Change-Id: Ia7b82f126dd25b7caa2b66ff8b5381026a816d19
2021-05-05 01:34:39 +00:00
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
6ba6672ce7 Merge "init: make reboot_on_failure not apply to manually stopped services" am: 890fd0c239 am: 7a07e8c1ad am: 506762b310
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1684056

Change-Id: Ia6a0f3b488a278c062b5cb6a01bc95300bbf788a
2021-05-04 21:53:53 +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
43f3a6b92c Merge "Fix precompiled sepolicy logic" am: 4664bbc6c7 am: ff9de56e37 am: 257a50e59d
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1690527

Change-Id: I359d9a1ea580a79d10f06825ee0a9c554f996c7b
2021-04-30 03:06:34 +00: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
277178c2c5 Merge "Allow a kernel bootconfig to set the qemu key" am: 6cbc7e01b2 am: 0d13e9370c am: 57f01c51e5
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1690216

Change-Id: Ia251f2c3fc296783b001d1584f34370e4b73aea6
2021-04-29 04:23:34 +00: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
5f7573c9c4 Merge changes from topic "debug_ramdisk_path" am: c4a1a32e91 am: d6fbaa0945 am: ee2cb68b2d
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1687907

Change-Id: If65a7996a499b7a312b0ab0b2a43554c0d807859
2021-04-28 18:59:08 +00:00
Bowgo Tsai
e62fdae795 init: loading debug resources before chroot into first_stage_ramdisk am: 64e92f946f am: 20a73996fa am: ba04147ae5
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1684655

Change-Id: I68ff80a39cf6df93486c3b30fa285ab11836b271
2021-04-28 18:59:06 +00:00
Bowgo Tsai
20a73996fa init: loading debug resources before chroot into first_stage_ramdisk am: 64e92f946f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1684655

Change-Id: Idedf53ec0e74a1fd12f4b883a7605200561d5ff3
2021-04-28 18:19:47 +00: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
a4c2d51c27 Merge "[Bugfix]Fix userspace-reboot failure when backing_dev exists but zram not swapped on" am: 23a50b3860 am: bce0c15f3f am: 11f3ed6133
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1674154

Change-Id: I1574031bb51c6a0c668be14654ee0ced824ae5ee
2021-04-23 01:09:45 +00: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
Treehugger Robot
73f0dfd416 Merge "init: apexd is started in the current mount namespace" am: 778f2b6837 am: fe5f60d051 am: d61e073a6a
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1680266

Change-Id: I6150bf4b982075fc578eec644bd5c0214d0209f1
2021-04-21 06:45:25 +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
5b7d0be4c3 Merge "ueventd: Allow pattern matching to find external firmware handler" am: 4a3ab034c6 am: dd7da900a0 am: 1875508cdf
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1664121

Change-Id: I25b4c6abe1a3197264b271f01c8ecda14e795e6a
2021-04-16 21:41:00 +00: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
Treehugger Robot
7f647a232a Merge "Do not populate ro.kernel. properties in init" am: 5e89a35ae3 am: f7c4f3b94b am: ff435d8995
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1676728

Change-Id: I136d3529e90f8f2ba869ac79da5d1cf54409f9de
2021-04-15 20:09:41 +00: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
ad5c80fda5 Merge "Load *_compat_cil_file from system_ext as well" am: 3841fdfa3c am: 6e944a9484 am: 832c06c27c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1650271

Change-Id: I62e8157a2a320ee0d8e46aca126ca03d433859d7
2021-04-13 07:40:22 +00:00
Yo Chiang
3841fdfa3c Merge "Load *_compat_cil_file from system_ext as well" 2021-04-13 05:48:04 +00:00
Hridya Valsaraju
1e0028a917 Merge "Use property ro.product.enforce_debugfs_restrictions to enable debugfs restrictions" am: 2a8b028c04 am: bdc512a21b am: 230df281ab
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1663702

Change-Id: Ie415770c7639361c9148db761cadf1b26a9c4513
2021-04-12 18:27:55 +00:00