Commit graph

4028 commits

Author SHA1 Message Date
Sayanna Chandula
5754b5ab10 init: Support reboot reason with thermal warmreset
Thermal shutdown could be due to tskin temperature or
battery temperature. Pass reason while rebooting the
system to reflect properly in boot.reason

Bug: 238464124
Test: Build and boot on device. Check reboot reason
for thermal shutdown and battery thermal shutdown with
thermal warmreset enabled.

Change-Id: I192562fed48ae7da7843e383362cd22a76ce479f
2022-10-07 14:11:25 -07:00
Yi-Yo Chiang
ddc9763ee2 Remove deprecated BOARD_BUILD_SYSTEM_ROOT_IMAGE
This variable is always false or empty now, so clean up remaining
references of the variable.

Bug: 241346584
Test: Presubmit
Change-Id: Id5c37a1391239206477fd802d364a2678692f513
2022-10-07 21:17:40 +08:00
Bob Badour
03d5052754 Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  init/fuzzer/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I2db55c80799d0a8fc5935d9b07a2ddb17eb7235e
2022-10-06 19:59:07 +00:00
Treehugger Robot
71d9f3607b Merge changes I264d0891,I1af733e7,Iae344c1e
* changes:
  Added init_ueventHandler_fuzzer
  Added init_property_fuzzer
  Added init_parser_fuzzer
2022-10-06 13:59:37 +00:00
David Anderson
aaa16bbad4 Merge "init: Statically link libbootloader_message." 2022-10-04 16:32:50 +00:00
David Anderson
12e53bc350 init: Statically link libbootloader_message.
This is to resolve idiosyncracies with test packaging.

Bug: 244284630
Test: ldd -d -r CtsInitTestCases
Change-Id: Iec2c14c3ca5cd359b79d9e1f12e689c0eeffb122
2022-10-03 21:37:56 -07:00
Florian Mayer
84a30c8526 Merge "[MTE] Add device config to control upgrade time" 2022-10-03 17:47:12 +00:00
Cole Faust
7e279e97a3 Fix module-file name collisions
Bazel doesn't allow a module and file with the same name.

Bug: 198619163
Test: Presubmits
Change-Id: I345086764071ca649de1ac11804e21675cd5e59d
2022-09-20 12:33:47 -07:00
Florian Mayer
caa7a60e2d [MTE] Add device config to control upgrade time
Bug: 169277947
Change-Id: I67eb94a668e60a2970bb086f82cc69396275340a
2022-09-16 09:49:38 -07:00
Florian Mayer
565305b852 Merge "[MTE] only upgrade to SYNC mode for MTE crashes" 2022-09-14 01:22:45 +00:00
Florian Mayer
d705c2dbcd [MTE] only upgrade to SYNC mode for MTE crashes
Bug: 244471804
Test: atest mte_ugprade_test on emulator
Change-Id: Ie974cf2dec96267012f1b01b9a40dad86551b1be
2022-09-13 15:35:07 -07:00
Adam Langley
ecc14a5958 init: Add option to listen on sockets before starting service.
Review note: Original change was a p-o-c by agl in
https://r.android.com/2094350 which I think is actually
production quality.  I'm just taking it over so that he doesn't
get spammed by any review comments as that's not a good use
of his time.

Needed for the hardware entropy daemon (see bug).

Original commit message:
If one needs to create a service that synchronously starts listening on
a socket then there are currently no good options.

The traditional UNIX solution is to have the service create the socket
and then daemonise. In this situation, init could start the service with
`exec_start` and yet not block forever because the service forks and
exits. However, when the initial child process exits, init kills the
daemon process:

> init: Killed 1 additional processes from a oneshot process group for
> service 'foo'. This is new behavior, previously child processes
> would not be killed in this case.

Next, there is a `socket` option for services and (although the
documentation didn't nail this down), the socket is created
synchronously by `start`. However, init doesn't call `listen` on the
socket so, until the service starts listening on the socket itself,
clients will get ECONNREFUSED.

This this change adds a `+listen` option, similar to `+passcred` which
allows a socket service to reliably handle connections.

Bug: 243933553
Test: Started prng_seeder from init using the new listen flag
Change-Id: I91b3b2b1fd38cc3d96e19e92b76c8e95788191d5
2022-09-12 15:16:35 +01:00
Suren Baghdasaryan
633ce78b94 Merge "init: Change extra_free_kbytes.sh to add margin relative to the default watermark level" 2022-09-09 16:55:25 +00:00
Deyao Ren
2880afb77f Merge "Clean up services created after running test" 2022-09-09 16:20:31 +00:00
deyaoren@google.com
909bc47536 Clean up services created after running test
Services created during new tests weren't properly cleaned up after tests. It caused slowdown of subsequent tests as described in b/244486404.
This change kills/terminates services after test with apex services.

To provide some context, original change is at https://android-review.googlesource.com/q/topic:vapex_stop_service. The issue was discovered by android test monitor and filed as a P0 bug.

Bug: 244486404
Change-Id: Ie64e0eb1686e94ef543a457ea49d1d7aeab38c97
2022-09-09 04:15:26 +00:00
Suren Baghdasaryan
cfd8864f9a init: Change extra_free_kbytes.sh to add margin relative to the default watermark level
extra_free_kbytes.sh accepts a parameter representing the number of KB
to add to low and high watermarks. It adds this margin to the current
watermark levels, however this is not how /proc/sys/vm/extra_free_kbytes
knob that it replaces used to work. The old knob would add the margin
relative to the original and not the current level of the watermarks.
Change extra_free_kbytes.sh to add the specified margin to the original
watermark levels to act as correct replacement of the old knob.

Bug: 242837506
Fixes: 642048d969 ("init: Add extra_free_kbytes.sh script to adjust watermark_scale_factor")
Test: repeatedly run 'setprop sys.sysctl.extra_free_kbytes 30375'
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I8af603ba00bd4fb8182b80b3c0969fa96cdd7311
2022-09-08 19:34:43 +00:00
Bob Badour
9cf81ccfef [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  init/test_upgrade_mte/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I77b956ed672a2f171b78ab1e7bfddc09bd0dc158
2022-09-08 15:23:25 +00:00
Sandro
d01921034c Remove /dev/selinux directory creation from first_stage_init.cpp
Follow-up from aosp/2203897

Bug: 243923977
Test: m and manual verification
Change-Id: I9e41301d2fe4447906253a5c1249dc6c25cd5218
2022-09-07 15:04:59 +00:00
Sandro
1120f7f4a9 Create /dev/selinux folder if it was not created by first-stage-init
The /dev/selinux folder is normally created by first-stage-init
https://cs.android.com/android/platform/superproject/+/master:system/core/init/first_stage_init.cpp;l=299-300;drc=07c86bace1e7a7cc4dd975f10b077d21c3743749

However, in some cases the first-stage-init comes from a GKI prebuilt
boot.img and doess not create the required folder (see for example
b/217677967), resulting in bugs like b/244793900.

I modified the selinux.cpp code to create the /dev/selinux folder if it
does not exist already, as a safety measure.

To verify these changes for b/244793900, follow gpaste/4922166775644160

Bug: 243923977
Test: atest SeamendcHostTest, manual verification
Change-Id: I8fe798643b1aeab2b4caac837055348febf70b94
2022-09-07 11:31:47 +00:00
Treehugger Robot
c113dc3a95 Merge "Upgrade MTE to SYNC after ASYNC crash." 2022-09-06 21:29:14 +00:00
Florian Mayer
2ef47f8f6d Upgrade MTE to SYNC after ASYNC crash.
Bug: 169277947
Test: atest mte_ugprade_test on emulator.
Test: ASSUMPTION_FAILED on non-MTE
Test: ASSUMPTION_FAILED on HWASan
Change-Id: I5328d094ffb106abaa548feb76058c9ebd11d745
2022-09-06 20:10:57 +00:00
Jooyung Han
93c24d7e65 Only run Service::Start() under root
Tests using Service::Start() should run under root. Otherwise tests fail
to start services from the test binary due to lack of permission.

Bug: 244748231
Test: CtsInitTestCases
Change-Id: Ia4eb8457cfad7d44da6b171e44f64238e08af9f7
2022-09-06 10:03:47 +09:00
Jiyong Park
a5dfe700b8 Merge "init: remove unnecessary semicolon" 2022-09-02 11:39:05 +00:00
Jooyung Han
c69bcd4a6d Merge "Removed property init.apex.<apex-name>.load/unload." 2022-09-02 06:46:54 +00:00
Deyao Ren
259b63d71c Removed property init.apex.<apex-name>.load/unload.
Bug: 240533726
Test: atest CtsInitTestCases ApexTestCases
Change-Id: I7ed149f24dc4b116865320c85389ffe7bae6ae0d
2022-09-01 16:14:00 +00:00
Deyao Ren
e37c15e9b0 Merge changes from topic "vapex_stop_service"
* changes:
  Remove and add service and action during apex load and unload
  Stop services when unload an apex
2022-08-31 16:09:43 +00:00
Deyao Ren
238e909349 Remove and add service and action during apex load and unload
Bug: 232114573
Test: atest CtsInitTestCases ApexTestCases
Change-Id: I1f91ada1d44ac2380e2faf8fc25e0a521cc1a826
2022-08-30 17:31:00 +00:00
Treehugger Robot
85d69af38e Merge "Validate persistent properties file" 2022-08-30 08:42:09 +00:00
Bart Van Assche
fcf047113f init: Apply the NormalIoProfile when creating a service
Prepare for migration of the blkio controller to the v2 cgroup hierarchy
by applying the NormalIoProfile when starting a service. While the
NormalIoProfile is automatically applied when the blkio controller is
mounted in the v1 hierarchy, this is not the case for the v2 hierarchy.

Bug: 213617178
Change-Id: I3cad288a31aa2692e10c778ae1e5fdd04acd66d7
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-08-25 14:01:01 -07:00
Paul Crowley
f7c74694d7 Validate persistent properties file
Before loading persistent properties, init now checks if there are any
invalid properties (not starting with "persist.").

Bug: 243723877
Test: atest persistent_properties
Change-Id: Ieb4ddce05916f193388af6b658e1904004ffa473
2022-08-25 11:40:18 -07:00
Sandro
956ce287f3 Add SeamendcHostTest to selinux.cpp TEST_MAPPING
SeamendcHostTest should run when making changes to selinux.cpp, to
ensure the test logic is updated to match the logic selinux.cpp follows
when it decides to compile the SELinux policy in the OpenSplitPolicy
method.

Bug: 238394904
Test: atest --test-mapping system/core/init/TEST_MAPPING:presubmit
Change-Id: Iaf0ec2356a894b071e6875dd41bcf9e842126e42
2022-08-25 09:26:24 +00:00
Deyao Ren
07595e198c Stop services when unload an apex
Bug: 238854102
Test: atest CtsInitTestCases ApexTestCases
Change-Id: I3b9df9424f7841c42bd1bde27cd0e0750615bd6c
2022-08-24 06:22:57 +00:00
kunal rai
803b5f4230 Added init_ueventHandler_fuzzer
Test: ./init_ueventHandler_fuzzer
Bug: 218631398

Change-Id: I264d0891f14cc5836e45d08578347737c94a168f
2022-08-19 11:48:30 +05:30
Akshata Kadam
2ae767105d Added init_property_fuzzer
Test: ./init_property_fuzzer
Bug: 218631398

Change-Id: I1af733e7f82bef2979fc308b0109094b0ebe1e28
2022-08-19 11:48:19 +05:30
Devendra Singhi
d29be4aaa0 Added init_parser_fuzzer
Test: ./init_parser_fuzzer
Bug: 218631398

Change-Id: Iae344c1e174fb5e07a0fb6813744fa1ae78eff6a
2022-08-19 11:48:07 +05:30
Xin Li
4f74d4542d Merge "DO NOT MERGE - Merge Android 13" 2022-08-16 19:08:18 +00:00
Trevor Radcliffe
fcfd725a5c Point directly to generated c sysprop_library
Bug: 226199990
Test: m
Change-Id: I0ea65714f9a27093b37034abde7d59f1951a5cb6
2022-08-12 18:23:40 +00:00
Deyao Ren
aebf88191b Merge "Add apex name to service" am: ec73481e58
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2155014

Change-Id: I3c44c321568173fa11588c2d6c69a43ad48c63f9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-22 23:09:19 +00:00
Jooyung Han
07316159c3 Merge "Respect namespace mnt" am: ba1fbaf50c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2163903

Change-Id: I67d5c5d93109b97b376fb97b01618893aba8af13
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-22 23:08:56 +00:00
Deyao Ren
ec73481e58 Merge "Add apex name to service" 2022-07-22 23:03:45 +00:00
Jooyung Han
5eb441caca Respect namespace mnt
This fixes the regression of aosp/2153354.
SwitchToMountNamespaceIfNeeded() is supposed to switch between "default"
mount namespace and "bootstrap" mount namespace. But it shouldn't affect
services with its own mount namespace.

Bug: 239882455
Test: make a hal service start in a separate mount namespace
    using 'namespace mnt' in its definition.
    see the mount namespace of the service process
    $ cat /proc/$(pgrep -f myservice)/ns/mnt
Change-Id: I8c80eaec723241c405f48980b9e88640123c43ad
2022-07-23 01:41:18 +09:00
Deyao Ren
df40ed1be1 Add apex name to service
Passed apex file name to service. The file name will be parsed
to determine 1) whether the service is from an apex; 2) apex name

Bug: 236090201

Change-Id: I2c292c0c067f4bf44bb25b1f80e4f972b94f7258
2022-07-22 04:00:30 +00:00
Yi-yo Chiang
a367bdbc4c Merge "Revert "first_stage_mount: Bind mount /system after switch root"" am: e321b113d6
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2159462

Change-Id: Ie9afb0754d73a7bdcf735c8dc6d1c0fec4a514db
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 03:57:26 +00:00
Yi-yo Chiang
e321b113d6 Merge "Revert "first_stage_mount: Bind mount /system after switch root"" 2022-07-20 03:49:59 +00:00
Zhuoyao Zhang
54ec48fad7 Revert "first_stage_mount: Bind mount /system after switch root"
This reverts commit d7e6353a69.

Reason for revert: b/239574953 breaking emulator based test on g3

Change-Id: Ib7d17fe8383937c7764f6612cf89db4fb7e5a4d3
2022-07-19 18:09:42 +00:00
Jiyong Park
35ed22e7c0 Merge "Enhance documentation about SetMmapRndBitsAction" am: ccb1ce32cc
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2156356

Change-Id: I86fbac8de9872ef6733cbd05bb140e1c92820d43
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-19 05:06:30 +00:00
Jiyong Park
a9f856b13b Merge "init: don't touch mmap_rnd_compat_bits on 64-bit only builds" am: 2d79c6c096
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2154914

Change-Id: I1e3ef837b69b85c5a554a9d0f41d319dd986ecb4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-19 05:06:20 +00:00
Jiyong Park
ccb1ce32cc Merge "Enhance documentation about SetMmapRndBitsAction" 2022-07-19 04:41:32 +00:00
Jiyong Park
2d79c6c096 Merge "init: don't touch mmap_rnd_compat_bits on 64-bit only builds" 2022-07-19 04:40:39 +00:00
Jiyong Park
5b16ccb36e Enhance documentation about SetMmapRndBitsAction
Bug: N/A
Test: N/A
Change-Id: I0408158d181ef08831a55e1381477f5b128a5c52
2022-07-19 10:47:47 +09:00
Jooyung Han
6bfcefca0a Merge "Update linker configuration when loading apex" am: 11e757c9cc
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2155096

Change-Id: Ife9943c015595c8d1381716fede99ad0fce2fab1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-18 23:59:47 +00:00
Jooyung Han
11e757c9cc Merge "Update linker configuration when loading apex" 2022-07-18 23:39:56 +00:00
Yi-yo Chiang
c3e43e63fe Merge "first_stage_mount: Bind mount /system after switch root" am: 53f1fab6ac
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2146960

Change-Id: I6f8029284650238dcca3727cb9be81d486a9d314
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-18 10:08:01 +00:00
Yi-yo Chiang
53f1fab6ac Merge "first_stage_mount: Bind mount /system after switch root" 2022-07-18 09:47:56 +00:00
Jooyung Han
626be07153 Update linker configuration when loading apex
On ctl.apex_load <apex_name> control message, init invokes linkerconfig
to update linker configuration for the updated apex.

Bug: 232173613
Test: CtsInitTestCases
Test: VendorApexHostTestCases
Change-Id: I01d975849c3f4efe74205a7b04ebbd6864ba1121
2022-07-18 17:45:15 +09:00
Treehugger Robot
f8415fdc19 Merge "first_stage_mount: Fix log typo "check_at_most_once"" am: 4bc5277152
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2146961

Change-Id: Id41980ebd8e4ec7353def81828f0138374858a49
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-18 06:18:51 +00:00
Jiyong Park
11d7bc52df init: don't touch mmap_rnd_compat_bits on 64-bit only builds
mmap_rnd_compat_bits is for address space randomization of 32-bit
applications on 64-bit system. Configuring it is not only unnecessary
for 64-bit "only" builds, but also can cause a boot failure if the
kernel is built without CONFIG_COMPAT which is the case for Microdroid.

Use ro.product.abilist32 to determine whether 32-bit applications are
supported and if not, don't configure it, but mmap_rnd_bits.

Bug: 237950549
Test: run Microdroid with the kernel built with aosp/2153639

Change-Id: Ifca6fa02f14ad4c7d8f9b2ab8852494c12945c3a
2022-07-18 14:31:13 +09:00
Yi-Yo Chiang
a3832d496b first_stage_mount: Fix log typo "check_at_most_once"
Was "check_most_at_once", should be "check_at_most_once".
Also straighten the if-then-else logic from:
  if (cond) {
    // then
  } else {
    // error...
    return;
  }
to:
  if (!cond) {
    // error...
    return;
  }
  // fallthrough is "then"

Test: Presubmit
Change-Id: I85c1e94c47a727089374d5d05ecd40f4187b66a1
2022-07-18 04:38:02 +00:00
Jooyung Han
db126b9a4e Merge "Return Result<T> from Do(Un)LoadApex()" am: 46fa45d82c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2155095

Change-Id: Ib73a4ed9cfb73ebd26cd03d2c3119aab5f17c5e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-16 03:19:31 +00:00
Jooyung Han
a2fe3e577e Return Result<T> from Do(Un)LoadApex()
For consistent error message. This is a preparation step for the
follow-up change: to generate linker configuration in DoLoadApex()

Bug: 232173613
Test: CtsInitTestCases
Change-Id: I27954ae2429e82da1bde1925ef62b277c24129d3
2022-07-16 08:37:06 +09:00
Jooyung Han
000b85449c Merge "init starts servicemanagers in "default" mount ns" am: e89c457157
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2153354

Change-Id: I9fcb98938403626697ea5b515e1f5d2c82fbefd8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-15 00:34:25 +00:00
Jooyung Han
c5fa15e08c init starts servicemanagers in "default" mount ns
servicemanager/hwservicemanager are pre-apexd services but still wants
to see VINTF fragments from APEXes, especially from /data.

Like ueventd, these services need to be started in "default" mount
namespace.

Bug: 237672865
Test: m && boot
Change-Id: I0266c5be5530a1a07f8ffa23a26186d45a55613f
2022-07-14 18:31:21 +09:00
Treehugger Robot
e03286ac40 Merge "Add ctl.apex_(un)load properties to (un)load apex" am: e271146ec8
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2146970

Change-Id: I26a3865aaaae2ded31c84e701a0a6fe3592b65a1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-13 04:20:59 +00:00
Treehugger Robot
e271146ec8 Merge "Add ctl.apex_(un)load properties to (un)load apex" 2022-07-13 04:04:20 +00:00
Treehugger Robot
592de2a382 Merge "Don't kill subcontext if it's null" am: 932e069f0f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2146830

Change-Id: Ib839545df89ff9b6c6b554d7429c2f6e602a32f3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-11 07:17:30 +00:00
Inseob Kim
5caaa5575e Don't kill subcontext if it's null
We don't initialize subcontext in microdroid. subcontext->pid() will
crash in such case.

Test: atest MicrodroidTests
Change-Id: Ifca65acededbf7f113d8bf16afbb8e2c1aa91b41
2022-07-11 14:34:15 +09:00
Jooyung Han
678f0b4828 Add ctl.apex_(un)load properties to (un)load apex
These props are supposed to be used by apexd when installing an apex
without reboot. During the installation, apexd will unmount the current
one and mount the new one. Since the path and its contents will be
replaced, anything loaded from the apex should be unloaded before
unmounting. After apexd mounts the apex again, then init should re-read
.rc files from the apex.

This change only addes required properties:
- ctl.apex_load <apex_name>
- ctl.apex_unload <apex_name>
- init.apex.<apex_name> = loaded | unloaded

Bug: 232114573
Bug: 232173613
Test: atest CtsInitTestCases
Change-Id: I4a8942d67912e2f11acc51bec756c4e3c218179a
2022-07-07 15:58:33 +09:00
Yi-Yo Chiang
d7e6353a69 first_stage_mount: Bind mount /system after switch root
This ensures /system to be a mountpoint, which allows adb-remount to
change the subtree propagation type of /system and MS_MOVE submounts
under /system.

Test: Add submount under /system and adb remount
Change-Id: Ib281be41eaf86bc3e6b7dfac893e5e27b8374da8
2022-07-06 21:51:35 +08:00
Treehugger Robot
0aa01859e6 Merge "Add lz4 support for VABC" am: 3854a69d39
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2061511

Change-Id: I5e15a317788ea6eba843b2c3c6770d549ea7db48
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-30 00:42:20 +00:00
Kelvin Zhang
5cb1b0295e Add lz4 support for VABC
Add lz4 support in CowWriter/CowReader. Lz4 should offer faster
read/write performance but slightly larger COW sizes.

Download time: Reduced from 1264s to 825s (~35% faster)
Filesystem verification time: from 69s to 59s (~15% faster)
COW Size: 2.59GB to 3.21GB, (~25% regression)
Merge time: 37046ms to 27690ms (~25% faster)
Boot time: LZ4 is 2.7% faster

Overall, LZ4 offers faster read/write performance at the cost of 25%
space regression.

Test: th
Bug: 228478555
Change-Id: Ie521852fb3c9ff8a12e55b764c1eb1838f7b2181
2022-06-29 13:10:55 -07:00
Xin Li
ebe6598a1c Merge tm-dev-plus-aosp-without-vendor@8763363
Bug: 236760014
Merged-In: Ia927c19f544536f78c20ccef5830bd1be0cebf9b
Change-Id: I0267b9eaad470a56db68f3a0b99abfc41192c6d7
2022-06-28 21:23:43 +00:00
Yi-Yo Chiang
01a7dcb240 first_stage_init: Optimize redundant vector copy
```
std::vector<std::string> v2;
for (auto&& e : get_temporary_v1()) { v2.push_back(e); }
```
^^^ This is constructing v2 from a temporary object, which is an
unnecessary manual clone. We should just let copy-elision do its thing:

```
// Give compiler the chance to optimize this with copy-elision...
auto v2 = get_temporary_v1();
```

Also `lp_names` appends an extra ',' at its end. Just use
android::base::Join() here.

Bug: 235111004
Test: Presubmit GSI boot test
Change-Id: Ibe8ce7a29b8521e789aa0a99f7f6d31f3f9c70e9
2022-06-27 16:19:37 +00:00
Eric Biggers
1179b02637 Merge "Rename fscrypt_is_native() to IsFbeEnabled()" am: e5a9a70437 am: 3d3a52a7d4
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2127464

Change-Id: I192f917501e5c04aa9ea80168a20ed688edd2116
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-22 19:07:49 +00:00
Eric Biggers
e5a9a70437 Merge "Rename fscrypt_is_native() to IsFbeEnabled()" 2022-06-22 18:24:38 +00:00
Treehugger Robot
de80927e34 Merge "Promote HWASan tests to presubmit." am: 8874ad6378 am: 5efde0b299
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2130634

Change-Id: I4f6f55c73906c4a41a3fbca444674d169cdd1795
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-21 18:09:49 +00:00
Florian Mayer
4effd2f901 Promote HWASan tests to presubmit.
They have been passing and do not show significant slowdown.

Change-Id: I3eba6ecb746160d75e9a2c9561bceb71a09117d3
2022-06-17 22:29:09 +00:00
Eric Biggers
893b1ae313 Rename fscrypt_is_native() to IsFbeEnabled()
Now that emulated FBE is no longer supported, there is no longer any
distinction between native FBE and emulated FBE.  There is just FBE.

Referring to FBE as "fscrypt" is also poor practice, as fscrypt (the
Linux kernel support for filesystem-level encryption) is just one part
of FBE, the Android feature.

Therefore, rename fscrypt_is_native() to IsFbeEnabled().

Bug: 232458753
Change-Id: Ib4dcdf799833b91d326b4b6f7120b0a3d4f4fc31
2022-06-15 18:52:39 +00:00
Suchang Woo
7d8c25b0c9 ueventd: Wait for runtime apex before running external firmware handler
External firmware handlers cannot run until com.android.runtime.apex is
activated. However, it may be possible to request firmware from the
kernel before apex activation. Waiting for runtime apex is required
before running an external firmware handler.

Test: atest CtsInitTestCases
Change-Id: Id63b7f29084d3cecb901049162d3e5cd0055566f
Signed-off-by: Suchang Woo <suchang.woo@samsung.com>
2022-06-15 17:11:24 +09:00
Treehugger Robot
42ffffd8a1 Merge "Chmod for existing nodes which mode not the same as ueventd.rc" am: a50d431830 am: 79c6750b85
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2063313

Change-Id: Ie057274f2586cb6d2dcbe0a7e5a04d70764c0c70
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-14 17:06:39 +00:00
Treehugger Robot
a50d431830 Merge "Chmod for existing nodes which mode not the same as ueventd.rc" 2022-06-14 14:14:15 +00:00
Yi-yo Chiang
df05b6d488 Merge "Auto enable usb adb if booting with debug ramdisk" am: 155bba8b0c am: 0d9240f898
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2119852

Change-Id: I4bf912c06184106b9effda1e9259ab26362a93c5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-10 13:05:27 +00:00
Yi-Yo Chiang
70c53f5d52 Auto enable usb adb if booting with debug ramdisk
If booting with debug ramdisk (ro.force.debuggable is true), override
the persistent property "persist.sys.usb.config" to always enable adb.
This ensures a consistent debug experience. The developer can expect
that after debug ramdisk (debug boot image) is flashed,
1. Device is rootable with (adb root)
2. adb is enabled automatically
3. no-auth (if $ADB_VENDOR_KEYS is used)

Bug: 223517900
Test: 1. Flash & boot user build, verify device doesn't have usb
  debugging enabled.
  2. Reboot to bootloader and flash vendor_boot-debug.img.
  3. Boot and verify usb debugging is automatically enabled.
  4. Enter Developer Options and manually turn off usb debugging.
  5. Reboot and verify that usb debugging is automatically enabled.
Change-Id: I729e961d645f2dd521ead8ca30b5cb8eb1d9f909
2022-06-08 23:07:13 +08:00
Kean Mariotti
7772fc84f5 Merge "Revert "Set the log callback earlier for showing system property set denials"" am: 526fbe2a37 am: c0e0892a5a
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2118487

Change-Id: I351a3a385c5d1be27258343db342910c5ec0291f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-08 09:50:51 +00:00
Kean Mariotti
526fbe2a37 Merge "Revert "Set the log callback earlier for showing system property set denials"" 2022-06-08 09:07:42 +00:00
Kean Mariotti
3a6040eb71 Revert "Set the log callback earlier for showing system property set denials"
This reverts commit 8c224faa24.

Reason for revert: 235312897

Change-Id: I80684c80bb6f97853449d429bbf948c07d4cb651
2022-06-08 07:57:53 +00:00
Alex Hong
c0b9b5f2d3 Merge "Set the log callback earlier for showing system property set denials" am: af74368a36 am: 219306f683
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1684665

Change-Id: Ic880afd4b9393b6d5e0516c914d00c5ec27de55c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-08 06:11:38 +00:00
Alex Hong
af74368a36 Merge "Set the log callback earlier for showing system property set denials" 2022-06-08 05:37:22 +00:00
Treehugger Robot
c6e1bb2b8c Merge "Added libinit_headers to Android.bp" am: ac9b59ed5a am: e8ee78b0db
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1985237

Change-Id: I3d4364cb1f4ac8a3186ea862cb8a0f317f569059
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 09:42:33 +00:00
Treehugger Robot
ac9b59ed5a Merge "Added libinit_headers to Android.bp" 2022-06-03 08:57:08 +00:00
Akilesh Kailash
6e01fe9537 Merge "init: Set oom_score_adj to snapuserd process" am: cb3ef68f22 am: 1aae2b57f6
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2114498

Change-Id: I4b2186888dff2daef99b9fa356802b60906c13fc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-02 21:59:38 +00:00
Akilesh Kailash
4ffe8a3109 init: Set oom_score_adj to snapuserd process
When a process is started as a native service,
oom_score_adj is set to -1000 so that processes
are unkillable by lmkd.

During boot, snapuserd process is not started as a service;
hence, we need to set the oom_score_adj explicitly else in
the event of low memory situation, lmkd can kill the
process thereby device can never boot.

Bug: 234691483
Test: th and OTA on Pixel
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ic2c85aa470522b4bc847a16b4f5cebfc528ed3cf
2022-06-02 20:49:03 +00:00
Thiébaud Weksteen
ddbc4fdad1 Merge "Add documentation on mkdir about seclabel" am: 715ecbfb23 am: 46e8d29a4f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2110586

Change-Id: I2ff96f2a0dece853749315e1b3dcceadc5d34f75
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 00:02:16 +00:00
Thiébaud Weksteen
715ecbfb23 Merge "Add documentation on mkdir about seclabel" 2022-05-31 23:27:22 +00:00
Thiébaud Weksteen
cc2fb50f52 Add documentation on mkdir about seclabel
Test: n/a
Change-Id: Iab672b4755a259caacf495a6692afcb268b4205f
2022-05-31 14:47:13 +10:00
Kelvin Zhang
151ca69317 Merge changes from topic "snapuserd_ramdisk" am: 321d47639e am: 8e9150e9ba
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2095787

Change-Id: I7204ab5c5d801ca7f4e593203d61458660a091f7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 16:27:07 +00:00
Kelvin Zhang
321d47639e Merge changes from topic "snapuserd_ramdisk"
* changes:
  Prefer generic ramdisk copy of snapuserd
  Install snapuserd.ramdisk with a separate path
2022-05-25 15:39:17 +00:00
Treehugger Robot
0055dab511 Merge "Suppress most load_property_from_file logs" am: 216b8b67fb am: 9c52f509d7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2101492

Change-Id: Id82e6a0d400957023bc335d7826da1565d578a25
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 04:44:48 +00:00
Treehugger Robot
216b8b67fb Merge "Suppress most load_property_from_file logs" 2022-05-25 03:56:24 +00:00
Inseob Kim
946c972162 Suppress most load_property_from_file logs
Some partitions may not have build.prop files (and it's totally fine).
Rather than logging such failures as WARNING, load_property_from_file
now returns a Result<void> object so callers can manually log for
themselves.

Bug: 228389036
Test: boot and logcat
Change-Id: Ia4ad7eef34d572182a3f6e86547664ae31dfd29f
2022-05-25 09:47:08 +09:00
Treehugger Robot
4bdbd24b22 Merge "init: Disable 'on' for non-Vendor APEXes" am: 8b3dff3e82 am: bff647cabd
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2101572

Change-Id: I766637091cfbf9b74905f99653d39b9d5c1c201a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-24 14:11:59 +00:00
Jooyung Han
99fa346c35 init: Disable 'on' for non-Vendor APEXes
Mainline modules are not supposed to rely on 'on' action triggers in
their init scripts because events/properties are not guranteed to be
stable across many devices.

To reduce the potential risk of enabling 'on' for APEXes, for now, we
enable it for only Vendor APEXes.

When an init script in a non-Vendor APEX contains 'on' section, init
emits an error on parsing the script and skip the section.

For example, when init.rc in the ADBD APEX has 'on' section,
the following error is emitted on parsing the script.

  init: Parsing file /apex/com.android.adbd/etc/init.rc...
  init: /apex/com.android.adbd/etc/init.rc: 8: ParseSection() failed:
    'on' is supported for only Vendor APEXes.

Bug: 232543017
Test: see above
Change-Id: I6509c8d2c6b632369d215128f740f9ed78858605
2022-05-20 09:31:08 +00:00
Treehugger Robot
af4e6561d7 Merge "init: log services requested restart" am: 0ddcf6d2f1 am: 4d3bf512b0
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2099238

Change-Id: I8ef99df0a8ecb38f14d5fdf12374f240f0439f37
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-18 06:38:58 +00:00
Treehugger Robot
0ddcf6d2f1 Merge "init: log services requested restart" 2022-05-18 05:31:04 +00:00
Steven Moreland
61169c76dd init: log services requested restart
We have a case where a service is requested to be started and does
not appear to be running, but we see no indication that it is
actually starting. This log should be enough information to see
if init is in a bad state.

Bug: 232297944
Test: doesn't add too much spam
    ~/android/aosp/system/core/init :) adb logcat -d | grep "requested start" | wc -l
    42
Change-Id: Ic07f250c98b200b9e5b4432200c3668c6ca0ff35
2022-05-17 22:54:55 +00:00
Eric Biggers
2f7a362c42 Merge changes If6611d64,Ie55c3ac1 am: 9fcf000264 am: 1e67c2529f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2098430

Change-Id: Icb7c4a40e6f7c0ffaccc5f1b456965fe111dd074
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-17 02:19:05 +00:00
Eric Biggers
48c05a6d03 init: remove unneeded special cases from FscryptInferAction
All the individual directories being treated specially by
FscryptInferAction() already have an explicit encryption action in the
corresponding mkdir commands.  The explicit action is the source of
truth, so the special cases in FscryptInferAction() are unnecessary.

Also, some of these cases were outdated.  For example, /data/app-staging
was changed from encryption=None to encryption=DeleteIfNecessary at some
point, but FscryptInferAction() was not updated.  This is causing the
warning "Inferred action different from explicit one" to be logged.

Additional "Inferred action different from explicit one" warnings are
logged due to subdirectories of /data/apex being explicitly encrypted.

Change FscryptInferAction() to only do what it needs to do: check
whether the directory is a top-level directory of /data or not.  Remove
the above-mentioned warning which is not useful.

Bug: 232554803
Change-Id: If6611d64107a19d242892c92dfea095577e193e5
2022-05-16 19:06:22 +00:00
Eric Biggers
6cb5a36f4c init: fix mkdir to reliably detect top-level /data directories
To determine the default encryption action, the mkdir command checks
whether the given path is a top-level directory of /data.  However, it
assumed a path without any duplicate slashes or trailing slash(es).

While everyone *should* be providing paths without unnecessary slashes,
it is not guaranteed, as paths with unnecessary slashes still work
correctly for all other parts of the mkdir command, including the
SELinux label lookup and the actual directory creation.  In particular,
the /data/fonts directory is being created using 'mkdir /data/fonts/'.

The effect is that the mkdir command thinks that /data/fonts/ is *not* a
top-level directory of /data, so it defaults to no encryption action.
Fortunately, the full command happens to use "encryption=Require", so we
dodged a bullet there, though the warning "Inferred action different
from explicit one" is still triggered.

There are a few approaches we could take here, including even just
fixing the /data/fonts/ command specifically, but I think the best
solution is to have mkdir clean its path at the very beginning.  This
retains the Linux path semantics that people expect, while avoiding
surprises in path processing afterwards.  This CL implements that.

Note, this CL intentionally changes the behavior of, and thus would
break, any existing cases where mkdir is used to create a top-level
/data directory using a path with unnecessary slashes and without using
an explicit encryption action.  There are no known cases where this
already occurs, however.  No cases exist in platform code, and vendor
init scripts shouldn't be creating top-level /data directories anyway.

Test: atest CtsInitTestCases
Test: Booted and verified that a trailing slash is no longer present in
      the log message "Verified that /data/fonts/ has the encryption
      policy ...".  Also verified that the message "Inferred action
      different ..." is no longer present just above it.
Bug: 232554803
Change-Id: Ie55c3ac1a2b1cf50632d54a1e565cb98c17b2a6a
2022-05-13 19:29:00 +00:00
Jooyung Han
4a8d564a5e Merge changes from topics "action-in-apex-config", "apex-ready-event", "subcontext-for-vendor-apex" am: ec76b5cb4e am: 364bc73186
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2093006

Change-Id: I3f9f6446af71094526e3c5a2ff2034ba25495c7a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-13 03:55:45 +00:00
Jooyung Han
03baf470dc APEX configs support 'on' as well am: badb7de1a2 am: bc3ec37dad
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2093004

Change-Id: I6b656e0e9de265f1532406236d38578e2a99cf7f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-13 03:55:36 +00:00
Jooyung Han
bc3ec37dad APEX configs support 'on' as well am: badb7de1a2
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2093004

Change-Id: Iab5bc7325e65c464d42e775d724e7e834671081a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-13 03:13:09 +00:00
Jooyung Han
ec76b5cb4e Merge changes from topics "action-in-apex-config", "apex-ready-event", "subcontext-for-vendor-apex"
* changes:
  Use subcontext for APEX configs from /{vendor, odm}
  add apex-ready event after post-fs-data
  APEX configs support 'on' as well
2022-05-13 01:47:40 +00:00
Eric Biggers
0368bbdf6b Merge "Move creation of /data/user/0 and /data/media/obb to vold" am: 93a8fc215e am: 1cbab9e135
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2095463

Change-Id: I6d28654336561d4b2ff0e114c3100a654124ad6a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 19:57:48 +00:00
Eric Biggers
93a8fc215e Merge "Move creation of /data/user/0 and /data/media/obb to vold" 2022-05-12 18:41:21 +00:00
Christopher Ferris
3863195506 Merge "Use new AndroidUnwinder object." am: dbe14f2f73 am: 32cfdb4be7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2095788

Change-Id: I18b4dfda04db0fadf49fa9ce9112e1205c3c21ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 05:08:43 +00:00
Jooyung Han
38e8e74550 Use subcontext for APEX configs from /{vendor, odm}
Instead of using config file path, use APEX's preinstalled path to
determine whether to use subcontext or not for APEX configs.

Bug: 232021354
Test: CtsInitTestCases, CtsBluetoothTestCases
Change-Id: Iba603f09602f0bec3113e2be3d15c62055c09e72
2022-05-12 13:37:19 +09:00
Jooyung Han
badb7de1a2 APEX configs support 'on' as well
APEX configs have supported only 'service' definitions. For those
services relying on 'on' trigger actions, we had to have separate config
files installed in read-only partitions (e.g. /system/etc/init).

This was suboptimal because even though APEXes are updatable, read-only
partitions are not.

Now, 'on' is supported in APEX configs. Putting 'on' trigger actions
near to service definitions makes APEX more self-contained.

'on' trigger actions loaded from APEX configs are not sticky. So, events
happens before loading APEX configs can't trigger actions. For example,
'post-fs-data' is where APEX configs are loaded for now, so 'on
post-fs-data' in APEX configs can't be triggerd.

Bug: 202731768
Test: atest CtsInitTestCases
Change-Id: I5a01d9c7c57b07955b829d6cc157e7f0c91166f9
2022-05-12 13:37:13 +09:00
Christopher Ferris
dbe14f2f73 Merge "Use new AndroidUnwinder object." 2022-05-12 03:35:34 +00:00
Treehugger Robot
70b6eac6cf Merge "Make sure all expected actions get run." am: a14a44ca66 am: cd53587016
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2095343

Change-Id: I0fe7ebccd2da40439c68c74344303f86f67bc390
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 01:22:41 +00:00
Christopher Ferris
d2bd6c5f13 Use new AndroidUnwinder object.
Replace libbacktrace with the new AndroidUnwinder object.

Bug: 120606663

Test: Ran unit tests.
Test: Added call of UnwindMainThreadStack() in DebugRebootLogging()
Test: and verified unwind data is logged properly.
Change-Id: Ia724f9485377d6d2c894283242a3c5653bf82768
2022-05-11 15:39:20 -07:00
Eric Biggers
ef9275223c Move creation of /data/user/0 and /data/media/obb to vold
To prevent bugs, directory creation and encryption should happen
together.  /data/user/0 (and its "alias" /data/data) is a per-user
encrypted directory; such directories can only be encrypted by vold.
Therefore, move its creation to vold as well.

Besides closing the uncomfortably-large gap between the creation and
encryption of /data/user/0, this allows removing init's write access to
/data/user and similar directories (SELinux type system_userdir_file) to
prevent any such issues from being reintroduced in the future.

To also allow removing init's write access to /data/media (SELinux type
media_userdir_file), which also contains per-user encrypted directories,
also move the creation and encryption of /data/media/obb to vold.

Bug: 156305599
BYPASS_INCLUSIVE_LANGUAGE_REASON=Linux API ("slave" mount flag)
Change-Id: I7245251eeb56b345b6c7711482c0aa5848648edb
2022-05-11 21:50:35 +00:00
Kelvin Zhang
07c86bace1 Prefer generic ramdisk copy of snapuserd
Test: th
Bug: 219841787
Change-Id: I1319ff968dfa94fec2925b7d5febae32d824fe3a
2022-05-11 13:57:06 -07:00
Florian Mayer
6268f6ab7a Make sure all expected actions get run.
Change-Id: I2b390ffa394ccd6a50a4a5d8805ce5a580c369b9
2022-05-11 01:02:03 +00:00
Suren Baghdasaryan
d53a8ed83d Merge changes from topic "228160715_fix" am: 25f0c1c457 am: 42bab74623
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2080619

Change-Id: Ifcb16ff2c2cf9889e6765c4a3abbf68354fe1e2b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-03 20:32:46 +00:00
Suren Baghdasaryan
af64077f83 init: Purge empty process groups on zygote restart
When system_server crashes or gets killed, it causes zygote to kill
itself, which in turn leads to killing all processes in the same
process group (all apps). This leaves empty process groups because
system_server is not there to remove them.
Purge empty process groups when init detects zygote death.

Bug: 228160715
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I0ce27eea28f8713e52033bbec2d5363a7b8ff5db
2022-04-29 17:17:51 +00:00
Devendra Singhi
1df957b9be Added libinit_headers to Android.bp
Test: Builds libint_headers
Bug: 218631398

Change-Id: Ia47d3c23cd4d4be7abc618ac1d2bf698f7761446
2022-04-26 09:51:59 +05:30
Jaegeuk Kim
288ce44aa4 Merge "Shutdown f2fs to avoid fsck" am: 4669f919a6 am: 988c764993
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2072812

Change-Id: I780b31d9ca1de1887a53c8f8ca66a4953863f3bd
Ignore-AOSP-First: this is an automerge
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-25 17:50:13 +00:00
Jaegeuk Kim
4669f919a6 Merge "Shutdown f2fs to avoid fsck" 2022-04-25 16:42:48 +00:00
Jooyung Han
689efa8380 Merge changes I72a3720c,Idac0d0ef am: 0f3f4f402e am: 222a765961
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2074258

Change-Id: Ic27ce9c20d86894ba37a6f9053281b4758e12f25
Ignore-AOSP-First: this is an automerge
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-25 07:08:54 +00:00
Jooyung Han
cee25aa926 Migrate compare-bootcharts.py to python3
Bug: 229983560
Test: system/core/init/compare-bootcharts.py \
          base-bootchart-dir exp-bootchart-dir
Change-Id: I72a3720cb3a80ef8d4fcb06fba8c8893ac08c930
2022-04-25 10:26:08 +09:00
Jooyung Han
7f8721b992 Unshare mount namespace in bootchart's thread
When bootchart is enabled its thread shares the mount namespace context
with the main thread. This prevents the main thread to switch the mount
namespace later with setns().

So, unshare() the mount namespace of the bootchart thread.

Bug: 229983560
Test: rebooted with bootcharting on/off
    enter_default_mount_ns should succeeded.
Change-Id: Idac0d0efcb4f7f7d8a7cbcebf8fa2fa29f104c35
2022-04-25 10:26:07 +09:00
Steven Moreland
7d4f1a6ebc Merge "ueventd: suggest move location for ueventd config" am: d438ea723b am: 49ec1df66c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2070481

Change-Id: I6d7e9994f3678ceb862d34422a7383107835186a
Ignore-AOSP-First: this is an automerge
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-22 22:31:37 +00:00
Steven Moreland
d438ea723b Merge "ueventd: suggest move location for ueventd config" 2022-04-22 21:38:48 +00:00
Jaegeuk Kim
3e595d5e67 Shutdown f2fs to avoid fsck
Bug: 229406072
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Id3b27219ab2a4655f1740829b0f03f027e66349d
2022-04-22 12:48:09 -07:00
Steven Moreland
2098314842 ueventd: suggest move location for ueventd config
Bug: 229650435
Test: N/A
Change-Id: I4645fd5a95b46ff40a0e8ee25130788ebfd01d72
2022-04-21 20:13:40 +00:00
zexin.hou
76cba8a16a Chmod for existing nodes which mode not the same as ueventd.rc
Change-Id: I5b0a918d4085b55daff5be1f4fc4496fabfb4cce
2022-04-19 14:40:56 +08:00
Akilesh Kailash
071d75052b Merge "libsnapshot: Remove invalid snapshot metadata" am: e3cca4a0d1 am: d2611d1c1c am: 0d701c13b6
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2061835

Change-Id: Ica6ad814de0853722fd2e5d4ab41670a29f3f36e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-17 00:25:11 +00:00
Akilesh Kailash
f86fca236f libsnapshot: Remove invalid snapshot metadata
If there are snapshot metadata persisting in /metadata/ota/snapshots,
remove them before applying a new update. Make sure that
the snapshots are indeed invalid before removing them.

On a sidenote, add a comment in init.cpp related to
b/223076262.

Bug: 228250473
Test: 1: Apply OTA in recovery through adb sideload
2: Reboot
3: Apply OTA OTA again through update_device.py
4: Re-run Full OTA updates just from update_device.py

Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I116bbafae09042b9c391ccd58c102704571c214e
2022-04-16 16:43:35 +00:00
David Anderson
6776e645f1 Merge changes I16bd2d5e,I04e9bf73
* changes:
  DO NOT MERGE: Revert "init: Add more diagnostics for signalfd hangs."
  DO NOT MERGE: Revert "init: Add diagnostics for signalfd epoll failures."
2022-04-16 05:32:58 +00:00
David Anderson
fc90774ef2 DO NOT MERGE: Revert "init: Add diagnostics for signalfd epoll failures."
This reverts commit 0fa7c40c4c.

Reason for revert: Diagnostics no longer needed

Change-Id: I04e9bf73b89411f7092348f57bfe6eb7dfaa9fcb
2022-04-15 01:00:27 +00:00
JeongHyeon Lee
170855dd2c init: remove unnecessary semicolon
Test: N/A
Change-Id: Ifae3188cabd523d67a5a934e8406eb9984c2cbbd
Signed-off-by: JeongHyeon Lee <jhs2.lee@samsung.com>
2022-04-14 18:08:17 +09:00
Treehugger Robot
69c56d27f3 Merge "Add jiyong@ to OWNERS." am: b5a5095bf0 am: 93e5c072fd am: 4107315eff
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2059069

Change-Id: Ib8bae963132f39361cde1a5096713b2d2eed9267
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-08 05:31:00 +00:00
David Anderson
9f1c919115 Add jiyong@ to OWNERS.
Change-Id: Iada34671296ebb7c1dc372638c91320bad6e7166
2022-04-07 19:15:01 -07:00
Treehugger Robot
72d9303464 Merge "Clean up comments/logs" am: 02360a55b7 am: 8f9a356bd1 am: 3197c33f5b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2057947

Change-Id: I0d70a28d446d61cc156b8f9a579aed5935eeb6e6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-07 04:22:06 +00:00
Treehugger Robot
02360a55b7 Merge "Clean up comments/logs" 2022-04-07 03:17:38 +00:00
Kelvin Zhang
f887e74588 Clean up comments/logs
Test: th
Change-Id: Ie63cfab7bf8d5d8e3e91695259cf62ab3ac17ee9
2022-04-06 14:02:13 -07:00
Suren Baghdasaryan
b1ab56b30e Merge "init: try converting writepid used with cgroups into task_profiles command" am: 8330095807 am: 34cc1ffb19 am: c47ece62d4
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1740144

Change-Id: I833e1c01d189bd755be4f9f079c34302db337802
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-05 20:01:20 +00:00
David Anderson
61b06cc84f Merge "init: Add more diagnostics for b/223076262." into tm-dev 2022-04-05 18:13:09 +00:00
David Anderson
d7f2bfba54 init: Add more diagnostics for b/223076262.
This adds three more diagnostics to stuck exec services:

1. /proc/pid/fds is dumped
2. /proc/pid/status is dumped
3. HandleSignalFd is called to see if a SIGCHLD got stuck somewhere

Bug: 223076262
Test: while (1) in linkerconfig
Ignore-AOSP-First: diagnostics
Change-Id: Ida601d86e18be9d49b143fb88b418cbc171ecac6
2022-04-05 07:16:27 +00:00
Suren Baghdasaryan
746ede9629 init: try converting writepid used with cgroups into task_profiles command
writepid usage to add a task to a cgroup was deprecated in favor of the
task_profile command. The reason is that writepid hardcodes cgroup path
and makes it hard to change it in the future, whereas task profiles
configure cgroup paths in one centralized place and are easy to change.
Log a warning when writepid is used with cgroups and try converting it
into a task_profiles command for well-known cgroups. If conversion is
not possible the writepid operation will still be attempted to avoid
breaking existing use cases and an error will be logged.

Bug: 191283136
Test: build and boot
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ie58393468ef7d92ab0ffb41e6f339e36d21f7478
2022-04-05 01:25:46 +00:00
Suren Baghdasaryan
1bd1746447 init: Treat failure to create a process group as fatal
During process startup, system creates a process group and places the
new process in it. If process group creation fails for some reason, the
new child process will stay in its parent's group. This poses danger
when the child is being frozen because the whole group is affected and
its parent is being frozen as well.
Fix this by treating group creation failure as a fatal error which would
prevent the app from starting.

Bug: 227395690
Test: fake group creation failure and confirm service failure to start
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I83261bef803751759c7fd709bf1ccd33ccad3a0b
2022-04-01 23:32:47 +00:00
David Anderson
ed1bca4b52 ueventd: Allow legacy paths in API version 32.
Bug: 226699360
Test: manual test
Change-Id: I2602eaa217a2b6cba8a5fb8acd6d5a8a9e3d405e
2022-03-29 17:50:01 -07:00
Daniel Norman
c015f7f96d Merge "Adds an init host lib for use in host_apex_verifier." 2022-03-29 23:56:15 +00:00
Treehugger Robot
a41f3812fd Merge "Load kernel modules in parallel" 2022-03-23 07:40:18 +00:00
Treehugger Robot
99c892e579 Merge "restorecon /dev/console at the second stage boot" 2022-03-23 04:29:53 +00:00
Inseob Kim
89d6913cf2 restorecon /dev/console at the second stage boot
It could be the case that /dev/console is created at the first stage
boot. ueventd doesn't have a permission to relabel from tmpfs to
console_device, so we should try restorecon /dev/console, together with
/dev.

Bug: 193118220
Test: atest MicrodroidHostTestCases
Change-Id: Ic538bc9214d3996fe7b37fa2224c1f0c6eb373d1
2022-03-22 21:51:07 +09:00
Daniel Norman
f1200fb117 Adds an init host lib for use in host_apex_verifier.
Includes extracting the APEX-specific SDK version naming scheme filter
logic so it can be reused when host_apex_verifier looks at rc files
inside the APEX.

Bug: 222121216
Test: Use in host_apex_verifier
Change-Id: I0396a455f30d2de71525ccd3fa69c75576054048
2022-03-21 15:45:44 -07:00
Treehugger Robot
4767dccadf Merge "Copy snapuserd to first_stage_ramdisk" 2022-03-21 15:47:25 +00:00
Kelvin Zhang
22929da287 Copy snapuserd to first_stage_ramdisk
Certain binaries, such as snapuserd, are only available under
/system/bin. To make them accessible by first stage init, we copy
/system/bin/snapuserd to /first_stage_ramdisk/system/bin/snapuserd .

Test: th
Bug: 219841787
Change-Id: I913425a82905c745a05ac32d488f08506dc264ff
2022-03-19 00:56:25 -07:00
Chungkai
c60300a2cc Load kernel modules in parallel
First, we load independent module in parallel, then we singly load
modules which have soft-dependencies. then remove them from dependency
list of other modules. Repeat these steps until all modules are loaded.

Bug: 180676019
Test: boot successfully, and save more than 400 ms on Pixel 6 Pro.
Signed-off-by: chungkai <chungkai@google.com>
Change-Id: Ib844cfee72d4049bd951528692c818b4fa6c8e8f
2022-03-18 08:06:07 +00:00
Florian Mayer
6c27e866f7 Add core to hwasan-postsubmit
Test: Run tests under HWASan.
Bug: 193568145
Change-Id: I4328299776e7e658d0f02f7b71b150c1f4815d3e
2022-03-17 14:02:43 -07:00
David Anderson
fe62ca7165 Merge "init: Add more diagnostics for signalfd hangs." 2022-03-16 23:11:12 +00:00
Treehugger Robot
4c7dc7bd1d Merge changes from topic "sys_rootdisk"
* changes:
  Init: add dev.mnt.blk.bootdevice to access device sysfs
  init: mount_handler: detect main block device more reliably
  init.rc: use /sys/class/block instead of /sys/devices/virtual/block
2022-03-16 22:44:01 +00:00
David Anderson
14f9c15e05 init: Add more diagnostics for signalfd hangs.
This adds two new diagnostics. First, signalfd reads are now non-blocking. If the read takes more than 10 seconds, we log an error.

Second, init now wakes up from epoll() every 10 seconds. If it waits on an "exec" command for more than 10 seconds, it logs an error.

This change will be reverted as soon as we get feedback.

Bug: 223076262
Test: device boots
Change-Id: I7ee98d159599217a641b3de2564a92c2435f57ef
2022-03-16 05:06:17 +00:00
Jaegeuk Kim
120f6b260c Init: add dev.mnt.blk.bootdevice to access device sysfs
This patch adds a new property, 'dev.mnt.root.<mount_point>', which provides,
for example of /data,

1. dm-N
  dev.mnt.dev.data = dm-N
  dev.mnt.blk.data = sdaN or mmcblk0pN
  dev.mnt.rootdisk.data = sda or mmcblk0

2. sdaN or mmcblk0pN
  dev.mnt.dev.data = sdaN or mmcblk0pN
  dev.mnt.blk.data = sdaN or mmcblk0pN
  dev.mnt.rootdisk.data = sda or mmcblk0

Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I0a58a62d416f966f26b5de04112c2f9a7eceb22c
2022-03-14 16:59:52 -07:00
Juhyung Park
491004bbfb init: mount_handler: detect main block device more reliably
Current code is not portable beyond SCSI devices (e.g., UFS).
For example, eMMC and NVMe devices fail due to their extra postfix.

Change its logic to rewind each character until "queue" directory appears.

Test: Confirm md0p1, sda20, nvme0n1p3, mmcblk0p3 are all handled well.
Change-Id: I585ccf2d4a72f6ef8ecb203acdd72a1e32d3e749
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
2022-03-14 16:59:52 -07:00
Akilesh Kailash
6e43216340 Revert "init: Add diagnostics for snapuserd hangs"
This reverts commit 471643a909.

Reason for revert: Given https://r.android.com/1960063, it is safe to revert this diagnostics patch

Change-Id: Ib3600c1982ee10a0204ac0fdbc3e160c2833ed07
2022-03-14 20:49:53 +00:00
David Anderson
5c007a51dd Merge "init: Add diagnostics for signalfd epoll failures." 2022-03-08 08:02:39 +00:00
David Anderson
0fa7c40c4c init: Add diagnostics for signalfd epoll failures.
Bug: 222441619
Test: inject failure with close, check for log messages
Change-Id: Ia18b88841779e230d00a6c47aaed4952b1444f85
2022-03-07 21:10:40 -08:00
Alexander Koskovich
e5f05202c7
init: Skip interface duplicates if service is an override
These aren't actually duplicate interfaces because we
are overriding the service so interfaces in the original
definition will never be used.

Test: Verify 'm dist' works without complaining about
      duplicate interfaces.

Change-Id: Iab5e1d8bb4cb7d5b2608028c3cee73af94c47424
2022-03-07 17:07:05 -07:00
Thiébaud Weksteen
87050874bd Document firmware_class.path
This kernel command-line parameter may be used to alter the loading of
firmware.

Bug: 222166126
Test: n/a
Change-Id: I6dc1ae92694cf08b11ab6c3c41aa3d62c992a72a
2022-03-03 13:00:20 +11:00
Bart Van Assche
bd73665e68 Introduce the RunService() method
The Service::Start() method is so long that its length negatively
affects readability of the code. Hence this patch that splits
Service::Start().

Test: Booted Android in Cuttlefish.
Change-Id: I5a6f587ecc5e6470137de6cceda7e685bce28ced
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-01 15:17:33 +00:00
Bart Van Assche
f2222aab6a Introduce the ConfigureMemcg() method
The Service::Start() method is so long that its length negatively
affects readability of the code. Hence this patch that splits
Service::Start().

Test: Booted Android in Cuttlefish.
Change-Id: I972f4e60844bb0d133b1cca1fd4e06bb89fc5f37
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-01 15:17:33 +00:00
Bart Van Assche
847b80a112 Introduce the Service::CheckConsole() method
The Service::Start() method is so long that its length negatively
affects readability of the code. Hence this patch that splits
Service::Start().

Test: Booted Android in Cuttlefish.
Change-Id: Ib8e1e87fbd335520cbe3aac2a88d250fcf3b4ff0
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-01 15:17:33 +00:00
Devin Moore
07ec259a54 Update init/README.md to mention bootconfig for androidboot argument
In Android S and later, androidboot.* kernel cmdline parameters are
moved to bootconfig instead the kernel cmdline. This includes the
androidboot.force_normal_boot.

Bug: 219951268
Test: N/A
Change-Id: Id0328ad09a34d654de9936e37a576a8a9f44de6c
2022-02-25 17:04:45 +00:00
Bart Van Assche
ee36ba39f9 Fix a race condition in Service::Start()
The SetTaskProfiles() call modifies cgroup attributes. Modifying cgroup
attributes can only succeed after the cgroups and cgroup attributes have
been created. Hence this patch that makes the child process wait until
the parent has finished creating cgroups and activating cgroup
controllers.

Bug: 213617178
Test: Without this patch the migration to the v2 hierarchy does not work reliably. With this patch applied, the migration to the v2 hierarchy works reliably.
Change-Id: I80a7c0a35453d8fd89ed798d077086aa8ba9ea17
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-15 22:31:09 +00:00
Justin Yun
d1e4f7d157 Update ro.vendor.api_level for non-GRF devices
Non-GRF devices must read only the `ro.product.first_api_level` but
not the vendor build version because `ro.product.first_api_level` is
always less than or equal to `ro.vendor.build.version.sdk` for
non-GRF devices.

Bug: 218610653
Test: getprop ro.vendor.api_level
Change-Id: Ib98c33ae052daa949208c43bd441f98cf442da49
2022-02-11 09:44:31 +09:00
Treehugger Robot
eb710bfa72 Merge "Revert "Revert "Use Apex sepolicy if it's available""" 2022-02-08 14:47:43 +00:00
Jeffrey Vander Stoep
baeece6d0c Revert "Revert "Use Apex sepolicy if it's available""
This reverts commit 5638fcc22b.

Reason for revert: Root cause of b/217252559 fixed.

Change-Id: I8d2fbf0cab23a56dbea1f422608097c48d9288c0
2022-02-08 12:42:33 +00:00
Treehugger Robot
c75044d639 Merge changes from topic "system_dlkm_dynamic"
* changes:
  system_dlkm: Fix flag for mount point guard
  system_dlkm: load property for dynamic partition
2022-02-02 06:04:07 +00:00
Ramji Jiyani
8431328d96 system_dlkm: load property for dynamic partition
Load from: /system_dlkm/etc/build.prop

Bug: 200082547
Test: TH
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
Change-Id: I9c34c44fc969107b215c05ed9b0ed779683a30b6
2022-02-02 02:34:46 +00:00
Jeffrey Vander Stoep
2e7bc19fc2 Merge "Revert "Use Apex sepolicy if it's available"" 2022-02-01 12:42:11 +00:00
Jeffrey Vander Stoep
5638fcc22b Revert "Use Apex sepolicy if it's available"
Revert "Build precompiled_sepolicy.apex_sepolicy.sha256"

Revert submission 1965099-precompiled-apex-sepolicy

Reason for revert: Boot regression b/217252559
Reverted Changes:
I2dbe43e32:Use Apex sepolicy if it's available
Bug: 217252559

Change-Id: I1cca3a1ae833c21619de26b2610736170ec5463c
2022-02-01 11:21:38 +00:00
Treehugger Robot
d15b09f187 Merge "init: remove debug logging." 2022-01-31 23:54:48 +00:00
Elliott Hughes
0305cf0f19 init: remove debug logging.
I think this was left in by accident?

Test: treehugger
Change-Id: Ie954efe33f1f811f58c9df4934d50caf0f79e0ea
2022-01-31 13:03:29 -08:00
Treehugger Robot
1412fee4a8 Merge "Use Apex sepolicy if it's available" 2022-01-31 09:11:05 +00:00
Jeff Vander Stoep
2e4b3ffa75 Use Apex sepolicy if it's available
[reland aosp/1910032]

Updatable sepolicy is shipped within an zip within an APEX. Because
it needs to be available before Apexes are mounted, apexd copies
the zip from the APEX and stores it in /metadata/sepolicy. If there is
not updatable sepolicy in /metadata/sepolicy, then updatable policy is
loaded from /system/etc/selinux/apex. Init performs the following
steps on boot:

1. Validates the zip by checking its signature against a public key
that is stored in /system/etc/selinux.
2. Extracts files from zip and stores them in /dev/selinux.
3. Checks if the apex_sepolicy.sha256 matches the sha256 of
precompiled_sepolicy. if so, the precompiled sepolicy is used.
Otherwise, an on-device compile of the policy is used. This is the
same flow as on-device compilation of policy for Treble.
4. Cleans up files in /dev/selinux which are no longer needed.
5. Restorecons the remaining files in /dev/selinux.
6. Sets selinux into enforcing mode and continues normal booting.

Bug: 199914227
Test: adb root
adb shell cp /apex/com.android.sepolicy.apex/etc/SEPolicy-33.zip \
/metadata/sepolicy/SEPolicy.zip
adb shell cp /apex/com.android.sepolicy.apex/etc/SEPolicy-33.zip.sig \
/metadata/sepolicy/SEPolicy.apk.sig
adb shell cp /apex/com.android.sepolicy.apex/etc/SEPolicy-33.zip.fsv_sig \
/metadata/sepolicy/SEPolicy.zip.fsv_sig
adb reboot
ls -laZ /dev/selinux/
Verify that files exist and that the labels are expected.

Change-Id: I2dbe43e329e91f46abedc7e44f7d24b220e19173
2022-01-28 13:47:24 +01:00
Jeffrey Vander Stoep
acd4121dbc Merge "Revert "Use Apex sepolicy if it's available"" 2022-01-27 18:04:28 +00:00
Jeffrey Vander Stoep
9759e248d1 Revert "Use Apex sepolicy if it's available"
This reverts commit 97ff3ab852.

Reason for revert: b/216491364 boot time regression

Bug: 216491364
Change-Id: I6c9af0887affa130cc61edf70506e79453dbd228
2022-01-27 17:49:40 +00:00
Treehugger Robot
71f3bfab23 Merge "Use Apex sepolicy if it's available" 2022-01-26 08:53:08 +00:00
Jeff Vander Stoep
97ff3ab852 Use Apex sepolicy if it's available
Updatable sepolicy is shipped within an zip within an APEX. Because
it needs to be available before Apexes are mounted, apexd copies
the zip from the APEX and stores it in /metadata/sepolicy. If there is
not updatable sepolicy in /metadata/sepolicy, then updatable policy is
loaded from /system/etc/selinux/apex. Init performs the following
steps on boot:

1. Validates the zip by checking its signature against a public key
that is stored in /system/etc/selinux.
2. Extracts files from zip and stores them in /dev/selinux.
3. Checks if the apex_sepolicy.sha256 matches the sha256 of
precompiled_sepolicy. if so, the precompiled sepolicy is used.
Otherwise, an on-device compile of the policy is used. This is the
same flow as on-device compilation of policy for Treble.
4. Cleans up files in /dev/selinux which are no longer needed.
5. Restorecons the remaining files in /dev/selinux.
6. Sets selinux into enforcing mode and continues normal booting.

Bug: 199914227
Test: adb root
adb shell cp /apex/com.android.sepolicy.apex/etc/SEPolicy-33.zip \
/metadata/sepolicy/SEPolicy.zip
adb shell cp /apex/com.android.sepolicy.apex/etc/SEPolicy-33.zip.sig \
/metadata/sepolicy/SEPolicy.apk.sig
adb shell cp /apex/com.android.sepolicy.apex/etc/SEPolicy-33.zip.fsv_sig \
/metadata/sepolicy/SEPolicy.zip.fsv_sig
adb reboot
ls -laZ /dev/selinux/
Verify that files exist and that the labels are expected.

Change-Id: I614e8d84892693ecc663b17eebd204096367693d
2022-01-25 10:27:00 +01:00
Akilesh Kailash
fd5562b0a5 init: Wait for snapuserd before starting second stage
This is a race between init process and bionic libc initialization of
snapuserd.

init->fork() ----------------> SecondStageMain() -> PropertyInit()
       |
       |
       v
      execveat ---> __libc_init_common() -> __system_properties_init()
     (snapuserd)

When init process calls PropertyInit(), /dev/__properties__ directory
is created. When bionic libc of snapuserd daemon invokes __system_properties_init
_after_ init process PropertyInit() function is invoked, libc will
try to initialize the property by reading
/system/etc/selinux/plat_property_contexts. Since any reads on /system
has to be served by snapuserd, this specific read from libc cannot be
serviced leading to deadlock.

Reproduce the race by inducing a sleep of 1500ms just before execveat()
so that init process calls PropertyInit() before bionic libc
initialization. This leads to deadlock
immediately and with additional kernel instrumentation with debug
logs confirms the failure:

======================================================
init: Relaunched snapuserd with pid: 428
ext4_file_open: SNAPUSERD: path /system/etc/selinux/plat_property_contexts - Pid: 428 comm 8
ext4_file_read_iter: SNAPUSERD for path: /system/etc/selinux/plat_property_contexts pid: 428 comm 8

[   25.418043][  T428]  ext4_file_read_iter+0x3dc/0x3e0
[   25.423000][  T428]  vfs_read+0x2e0/0x354
[   25.426986][  T428]  ksys_read+0x7c/0xec
[   25.430894][  T428]  __arm64_sys_read+0x20/0x30
[   25.435419][  T428]  el0_svc_common.llvm.17612735770287389485+0xd0/0x1e0
[   25.442095][  T428]  do_el0_svc+0x28/0xa0
[   25.446100][  T428]  el0_svc+0x14/0x24
[   25.449825][  T428]  el0_sync_handler+0x88/0xec
[   25.454343][  T428]  el0_sync+0x1c0/0x200

=====================================================

Fix:

Before starting init second stage, we will wait
for snapuserd daemon to be up and running. We do a simple probe by
reading system partition. This read will eventually be serviced by
daemon confirming that daemon is up and running. Furthermore,
we are still in the kernel domain and sepolicy has not been enforced yet.
Thus, access to these device mapper block devices are ok even though
we may see audit logs.

Note that daemon will re-initialize the __system_property_init()
as part of WaitForSocket() call. This is subtle but important; since
bionic libc initialized had failed silently, it is important
that this re-initialization is done.

Bug: 207298357
Test: Induce the failure by explicitly delaying the call of execveat().
      With fix, no issues observed.
      Tested incremental OTA on pixel ~15 times.
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I86c2de977de052bfe9dcdc002dcbd9026601d0f3
2022-01-25 08:30:08 +00:00
Kelvin Zhang
a2544adbb4 Convert perfboot.py to python3
Change-Id: I29c06888b84c2b00455884bca8e5d4dd9209057c
2022-01-21 13:53:19 -08:00
David Anderson
471643a909 init: Add diagnostics for snapuserd hangs
This patch attempts to diagnose snapuserd hangs by performing reads
immediately after entering second-stage init. This is done by spawning
two threads: one to perform the reads, and another to wait for the read
thread to finish. If any aspect of the read fails, or the read thread
does not complete in 10 seconds, then a list of snapuserd's open file
descriptors are logged.

Bug: 207298357
Test: apply working OTA, check logcat for success
      apply broken OTA, check logcat for fd map
Change-Id: I549e07b7d576fcdaca9b2d6ff33e0924c3812c07
2022-01-21 17:35:33 +00:00
Jiyong Park
e060580c31 Merge changes from topic "or_return"
* changes:
  Sort exported headers of libutils
  OR_RETURN supports status_t
2022-01-12 07:27:41 +00:00
Jiyong Park
705abe2d30 OR_RETURN supports status_t
This change provide a specialization of android::base::OkOrFail for
status_t. As a result, a statement whose type is status_t can be used
with OR_RETURN.

The specialization also provides conversion operators to Result<T,
StatusT> where StatusT is a wrapper type for status_t. This allows
OR_RETURN macro to be used in newer functions that returns Result<T,
StatusT>.

Example usage:

\#include <utils/ErrorsMacros.h>

status_t legacy_inner();

status_t legacy_outer() {
  OR_RETURN(legacy_inner());
  return OK;
}

Result<T, StatusT> new_outer() {
  OR_RETURN(legacy_inner()); // the same macro
  return T{...};
}

Bug: 209929099
Test: atest libutils_test
Change-Id: I0def0e84ce3f0c4ff6d508c202bd51902dfc9618
2022-01-12 09:20:27 +09:00
David Anderson
58e554e7ed Merge "Remove support for AVB 1.0." 2022-01-05 03:57:20 +00:00
Jiyong Park
f5caf5b2e1 Merge "android::base::ResultError/Error are template classes" 2021-12-16 23:54:16 +00:00
Yi Kong
b4b20ae65d Fix missing comma
This is discovered by Clang's -Wstring-concatenation diagnostic.

Test: presubmit
Bug: 175068488
Change-Id: Ied97b32e6707236621387bb06993d52a662d9d83
2021-12-15 17:23:46 +08:00
Jiyong Park
d185d4a8b4 android::base::ResultError/Error are template classes
They are changed to template classes. s/Error/Error<>/g to reflect that.

In addition, the direct uses of ResultError for error reporting is
replaced with Error and Errorf.

Bug: 209929099
Test: m
Change-Id: I815526a8e6fa30e63fa3efcf5700b146bf70a507
2021-12-14 17:34:40 +09:00
David Anderson
6d7c7a2156 init: Add --only-if-running argument to restart command.
If surfaceflinger crashes before zygote starts, it will restart zygote
too early. Add this argument will allow it to only restart zygote if
it's already running.

Bug: 197224273
Test: manual test
Change-Id: I0ac8dbeaf0a002f8cfcfcc0f63d4b90d08393c5c
2021-12-03 15:49:39 -08:00