Commit graph

3738 commits

Author SHA1 Message Date
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
d438ea723b Merge "ueventd: suggest move location for ueventd config" 2022-04-22 21:38:48 +00: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
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
David Anderson
9f1c919115 Add jiyong@ to OWNERS.
Change-Id: Iada34671296ebb7c1dc372638c91320bad6e7166
2022-04-07 19:15:01 -07: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
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