Commit graph

3447 commits

Author SHA1 Message Date
David Anderson
491e4da372 init: Add an selinux transition for snapuserd.
With compressed VAB updates, it is not possible to mount /system without
first running snapuserd, which is the userspace component to the dm-user
kernel module. This poses a problem because as soon as selinux
enforcement is enabled, snapuserd (running in a kernel context) does not
have access to read and decompress the underlying system partition.

To account for this, we split SelinuxInitialize into multiple steps:

First, sepolicy is read into an in-memory string.

Second, the device-mapper tables for all snapshots are rebuilt. This
flushes any pending reads and creates new dm-user devices. The original
kernel-privileged snapuserd is then killed.

Third, sepolicy is loaded from the in-memory string.

Fourth, we re-launch snapuserd and connect it to the newly created
dm-user devices. As part of this step we restorecon device-mapper
devices and /dev/block/by-name/super, since the new snapuserd is in a
limited context.

Finally, we set enforcing mode.

This sequence ensures that snapuserd has appropriate privileges with a
minimal number of permissive audits.

Bug: 173476209
Test: full OTA with VABC applies and boots
Change-Id: Ie4e0f5166b01c31a6f337afc26fc58b96217604e
2021-01-08 16:39:51 -08:00
SzuWei Lin
0061d4da01 Make ro.product.cpu.abilist* to be fetched dynamically
Basically, ro.product.cpu.abilist* are defined by
ro.vendor.cpu.abilist*. And they can be overried by
ro.odm.cpu.abilist* and ro.product.cpu.abilist*.
ro.system.cpu.abilist* are for fallback if others are no defined.

Bug: 176520383
Test: check the result by flashing aosp_arm64-userdebug on
Test: aosp_blueline-user and aosp_blueline-user hacked by
Test: 64-bits-only
Change-Id: I01ae01af099a4ec8fe3d4525edecc233a477ff60
2021-01-08 15:02:42 +08:00
Nicolas Geoffray
5266e041ef Merge "Add boot animation progress system property." 2021-01-07 09:23:35 +00:00
Jiyong Park
8b40485f58 Merge "init: Sort the list of flattened APEX folders to avoid variations" am: 0f2c5417c3 am: 570fe2083c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1538222

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I90ee4644f921d6bde03dbaef3f3e86fc080affaa
2020-12-31 04:34:56 +00:00
Adrian DC
9449583bc3 init: Sort the list of flattened APEX folders to avoid variations
* In 'ActivateFlattenedApexesFrom', the 'readdir' detects
   the APEX folders in a random way that depends on filesystems,
   built packages and order of the build chain

 * In normal cases, this is not an issue, however when building
   with Go configurations, we have a case where the package
   'com.android.tethering.inprocess' is built along the
   'com.android.tethering' overriden binary, and depending on
   the 'readdir' output, the mounts break the Tethering service

Change-Id: I8ac4a0284d8d885f732c71e846933869cf16a0bd
Signed-off-by: Adrian DC <radian.dc@gmail.com>
2020-12-30 22:41:33 +01:00
Bernie Innocenti
d2a4c1f841 Merge "Add explicit Result::ok() checks where needed" am: bc053268cf am: 0b0c5424a8
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1229625

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I66dafc280da0421afccadcd6c1c24e74dc306bf2
2020-12-21 19:20:02 +00:00
Bernie Innocenti
062ef5356d Add explicit Result::ok() checks where needed
Test: m checkbuild continuous_instrumentation_tests continuous_instrumentation_tests_api_coverage continuous_native_tests device-tests platform_tests
Exempt-From-Owner-Approval: mechanical mass refactoring
Change-Id: I8d40b1e3cb5d2f76baf77b8a190df4366909f7b6
2020-12-20 17:06:17 +00:00
Treehugger Robot
2d50616415 Merge "init: don't generate tombstones for expected test failures" am: 0b8d2fef69 am: 2a90da3ea8
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1529980

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I96debd5144ce163cdab07a7018208858e17658f4
2020-12-15 19:02:55 +00:00
Nicolas Geoffray
e106f0aaeb Add boot animation progress system property.
Test: m
Bug: 175686819
Change-Id: Ic2757054b908e2c7ff51e256e8683616df74fb33
2020-12-15 18:34:47 +00:00
Treehugger Robot
0b8d2fef69 Merge "init: don't generate tombstones for expected test failures" 2020-12-15 18:22:09 +00:00
Nikita Ioffe
3f473c9dfb Merge "Log start of the test to logcat" am: 356b184468 am: e7f989d826
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1526419

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If31b80253977f61e0cee5edf5ca9cdff4e73aa71
2020-12-15 16:15:59 +00:00
Tom Cherry
94b1c57d93 init: don't generate tombstones for expected test failures
The firmware_handler.HandleAbort and subcontext.RecoverAfterAbort
tests intentionally abort in the child process to ensure that
ueventd/init can recover if their child processes die.  This generates
a tombstone which causes confusion.  This change resets SIGABRT to
SIG_DFL right before the abort(), so that the child processes will
exit normally without generating a tombstone or writing a crash to
logcat.

Bug: 169771958
Bug: 175383788
Test: run the above tests and verify no stack traces are printed to
      logcat and no tombstones are generated.
Change-Id: Ica09548d1c7a766bf5d9ff2e26c9fd558e85c7c1
2020-12-15 06:38:55 -08:00
Nikita Ioffe
356b184468 Merge "Log start of the test to logcat" 2020-12-15 12:21:46 +00:00
Treehugger Robot
82f688e397 Merge "Add new owners to various sub-projects." am: e107d445f6 am: 25e7a66ad5
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1526395

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie4793f6147ac1930d379203e1ed23ce45d4bc624
2020-12-11 23:29:15 +00:00
Elliott Hughes
21de4e727e Add new owners to various sub-projects.
Test: treehugger
Change-Id: Ia2a99c0499633ccc5d23c37a1ec93867c876d637
2020-12-11 12:45:45 -08:00
Nikita Ioffe
9e4b111a33 Log start of the test to logcat
This makes it easier to associate logs written during the test with the
test case that was running.

Test: atest CtsInitTestCases
Change-Id: I832f1c9ba8358341c934fdd91a65f5739bc98e37
2020-12-11 18:00:45 +00:00
Tom Cherry
e2d6d3e8f2 Merge "init: remove DumpShutdownDebugInformation()" am: 6ece3c44fe am: afcc16e4e9
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1523598

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie865819e057b04761999a408bfb9e0a542f75384
2020-12-10 19:41:31 +00:00
Tom Cherry
6ece3c44fe Merge "init: remove DumpShutdownDebugInformation()" 2020-12-10 18:55:52 +00:00
Tom Cherry
959ea63b30 init: remove DumpShutdownDebugInformation()
This hasn't helped investigating the issue, and the issue itself isn't
a problem anymore, so we remove these logs.

Bug: 155203339
Test: reboot
Change-Id: I20e51d8fcad5572906a8d556bec8a8dee4522834
2020-12-10 07:34:29 -08:00
Yifan Hong
6c9f509cdb Merge changes from topic "readonly_generic_ramdisk" am: 696882455b am: 3401909e7c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1519823

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I696a169b18eb038958dafa45f63cd9a5528456c0
2020-12-09 20:42:04 +00:00
Elliott Hughes
93f97df267 Merge "Use freecon() with getcon()/getfilecon()." am: 2acdc9de33 am: ebcf0925fc
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1521162

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iaae3f3c53604eb9fc24a83b49516b75c29490372
2020-12-09 20:40:06 +00:00
Yifan Hong
696882455b Merge changes from topic "readonly_generic_ramdisk"
* changes:
  Add /metadata to ramdisk.
  Also create dirs under /first_stage_ramdisk for GKI.
  Refactor the list of empty dirs in ramdisk in its own list.
  Revert "Move e2fsck into /first_stage_ramdisk."
2020-12-09 19:46:17 +00:00
Elliott Hughes
2acdc9de33 Merge "Use freecon() with getcon()/getfilecon()." 2020-12-09 19:03:16 +00:00
Tom Cherry
26ff6deb67 Merge "ueventd: add no_fnm_pathname option" am: 6cf3695502 am: a95f900d69
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1518705

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7e6ecd974922ef6a5b26cd722860d59d8032b62f
2020-12-09 16:19:06 +00:00
Tom Cherry
1597ec0ac5 Merge "ueventd: add the import option from the init parser" am: 0608e36fb9 am: 877e2374a7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1520220

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I5983dc88d2dc8f4225b168969e25f9f969f71c55
2020-12-09 16:18:55 +00:00
Tom Cherry
6cf3695502 Merge "ueventd: add no_fnm_pathname option" 2020-12-09 15:50:16 +00:00
Tom Cherry
0608e36fb9 Merge "ueventd: add the import option from the init parser" 2020-12-09 15:47:25 +00:00
Elliott Hughes
d92c6a12da Use freecon() with getcon()/getfilecon().
Bug: https://issuetracker.google.com/175090444
Test: treehugger
Change-Id: Ia2b8102f1c9a4fd56ec1ff026ba5b4f375102b9b
2020-12-08 22:30:17 -08:00
Tom Cherry
5b271797de ueventd: add the import option from the init parser
Vendors have an interest in importing ueventd files based on certain
property values.  Instead of baking this logic in the ueventd binary,
add the import option from the init parser to the ueventd parser, to
allow vendors to expand as needed.

Test: imported files are parsed
Change-Id: I674987fd48f3218e4703528c6d905b1afb5fb366
2020-12-08 13:21:26 -08:00
Yifan Hong
a3f8373043 Add /metadata to ramdisk.
Now that GKI may not be writeable, also create /metadata at build time
to avoid error log at boot time.

Note that this also creates /first_stage_ramdisk/metadata in GKI.

[    1.891172] init: [libfs_mgr]check_fs():
mount(/dev/block/by-name/metadata,/metadata,ext4)=-1: No such
file or directory

Bug: 173425293
Test: boots

Change-Id: I62d23c382ed1ad165c1d6598b3df41bd92206733
2020-12-08 12:42:55 -08:00
Yifan Hong
55326187ab Also create dirs under /first_stage_ramdisk for GKI.
If the device uses GKI and generic ramdisk, also create
empty directories under /first_stage_ramdisk so that they
won't have to be created at runtime. This allows generic
ramdisk to be not writable.

Test: boots
Bug: 173425293
Change-Id: If987cb1d4af9f9ee94a43a4523f9e1465b01b16a
2020-12-08 12:42:55 -08:00
Yifan Hong
63be35649a Refactor the list of empty dirs in ramdisk in its own list.
Test: build and manual inspect
Bug: 173425293
Change-Id: I7805640af314b60801cc831f1d1f25820f0fb63b
2020-12-08 12:42:55 -08:00
Yifan Hong
addbafdb0b Revert "Move e2fsck into /first_stage_ramdisk."
This reverts commit 3337e782e6.

Reason for revert: e2fsck is moved into vendor ramdisk and installed
to / or /first_stage_ramdisk depending on the device, so there is no
need to move it.

Bug: 173425293
Change-Id: I1eb431e6b2a1e0ba7d0da0278d076b6682a0156d
Test: boots
2020-12-08 12:42:55 -08:00
Treehugger Robot
37476f59d2 Merge "ueventd: Add support for updating permissions on bind" am: bca7bfcc54 am: c6544c9246
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1511048

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7a3117112a572d6121a6630819518f3e3211676f
2020-12-08 19:59:10 +00:00
Treehugger Robot
bca7bfcc54 Merge "ueventd: Add support for updating permissions on bind" 2020-12-08 18:53:44 +00:00
Tom Cherry
47031c8c88 ueventd: add no_fnm_pathname option
If a `*` appears within (but not at the end) of a /dev or /sys path in
a ueventd.rc file, then that path is matched with fnmatch() using the
FNM_PATHNAME, which means `*` will not match `/`.  That is not always
the intended behavior and this change creates the no_fnm_pathname
option, which will not use the FNM_PATHNAME flag and will have `*`
match `/`.

Bug: 172880724
Test: these unit tests
Change-Id: I85b813d89237dbf3af47564e5cbf6806df5d412f
2020-12-07 14:58:19 -08:00
Kiyoung Kim
07c667a09b Merge "Use bootstrap linkerconfig from early init" am: 2f3e936f72 am: 7184a231cd
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1512740

Change-Id: I157dbbe47cda6f6ec69e3a4eb595553dbc639bb3
2020-12-04 02:04:47 +00:00
Nikita Ioffe
7ba5030dcc Fix potential use-after-free bug in reboot
Instead of operating on raw pointers, init now uses name of the
services as it's primary identifier. Only place that still uses
vector<Service*> is StopServices.

In addition, ServiceList::services() function is removed, which should
help avoiding similar bugs in the future.

Bug: 170315126
Bug: 174335499
Test: adb reboot
Test: atest CtsInitTestCases
Change-Id: I73ecd7a8c58c2ec3732934c595b7f7db814b7034
Merged-In: I73ecd7a8c58c2ec3732934c595b7f7db814b7034
Ignore-AOSP-First: fixing security vulnerability
(cherry picked from commit 8d6ae2dd8a)
2020-12-02 16:11:22 +00:00
Sriharsha Allenki
e6094789b4 ueventd: Add support for updating permissions on bind
Current implementation updates the permissions of sysfs
nodes of a device upon the following actions: "add",
"change" and "online".
But certain sysfs nodes (ex: wakeup capabilities under
power management) of devices are not present when the
device is added, but these are generally dependent on
the device driver and are added once the driver is bound.
This is particularly common in USB host stack.
If the bind action events are not parsed the ueventd
will not update the permissions of these nodes.

Hence, add the support for updating permissions on
bind action as well.

Bug: 174215510
Test: Verified permissions updated on bind action
Change-Id: Ic1a147e3993ef78dd6c539bbae652e8107207b87
2020-12-02 18:07:41 +05:30
Kiyoung Kim
03b9bcabff Use bootstrap linkerconfig from early init
Linkerconfig will be moved into Runtime APEX, so
/system/bin/linkerconfig would not be available before APEX is mounted.
Use bootstrap linkerconfig instead during early init.

Bug: 165769179
Test: Cuttlefish boot succeeded
Change-Id: Iae41f325bbd5f5194aaf4613141860f913dfbff1
2020-12-02 11:41:06 +09:00
Tom Cherry
456397830d Merge "Revert "Ramdisk: add metadata dir in ramdisk"" 2020-12-01 17:36:42 +00:00
jiazi li
18778cd5f9 Revert "Ramdisk: add metadata dir in ramdisk"
This reverts commit 9fa773746c.

Reason for revert: using aosp/1505939 instead

Change-Id: I4c654e5b77b0e5ffac036fe0674f201f2ae19fb6
2020-12-01 06:19:54 +00:00
Tom Cherry
c9bc6bb436 init: add some documentation in service_utils.h
Test: n/a
Change-Id: I2a2691a6d1f643e255550498d9871e38f1b51efa
2020-11-24 11:34:40 -08:00
David Anderson
1d57fb839d init: Fix ordering of second-stage snapuserd transition.
Running snapuserd before early-init means ueventd is missing, which
means we can't use WaitForFile() when dm-user misc devices are created.
Fix this by starting the transition after early-init.

Bug: 173476209
Test: full OTA with VABC applies and boots
Change-Id: Ice594cceb44981ae38deb82289d313c14726c36b
2020-11-22 13:51:15 -08:00
David Anderson
32f281d77a init: Pass a uevent regen callback to libsnapshot.
In first-stage init, libsnapshot needs to know how to wait for device
paths, since ueventd isn't running yet. We do this by passing a callback
wrapping BlockDevInitializer.

Bug: 173476209
Test: device boots into first-stage init after full VABC ota
Change-Id: I9a87f98824e65a9379cb0b99c001e28cccd9d205
2020-11-22 13:51:03 -08:00
Wei Wang
4544d991f7 Merge "init: add a copy_per_line built-in command" 2020-11-20 20:05:40 +00:00
Yifan Hong
15cd1cd8fd Merge changes from topic "e2fsprogs_vendor_ramdisk"
* changes:
  fs_config Add first_stage_ramdisk/system/bin/linker[64]
  libsparse: make vendor_ramdisk_available.
  init: don't abort if directory already exists
2020-11-20 19:50:44 +00:00
Wei Wang
49d2598166 init: add a copy_per_line built-in command
There are sysfs nodes that don't take multiple inputs, adding a new
copy_per_line built-in command to copy from source file to destination
line by line.

Bug: 171740453
Test: boot and check file and log
Change-Id: I41b7a565829299d56b81d4509525dfa6a0a52444
2020-11-20 10:54:14 -08:00
Yifan Hong
7e7f881508 init: don't abort if directory already exists
create_directories return false with ec == 0 if directory
already exists. Do not abort in this case.

Bug: 173425293
Test: boots with pre-existing /first_stage_ramdisk/system/bin
Change-Id: I351837f0a5a56361ebc385b9a9da9658882a131d
2020-11-19 17:35:21 -08:00
Daniel Norman
f597fa5d1d Returns a service parse error on overrides across the treble boundary.
Also includes new --out_<partition> flags for
  system,system_ext,product,vendor,odm
to allow host_init_verifier to work with a collection of init rc files.

Test: host_init_verifier --out_system=... --out_vendor=...
      where vendor contains an init rc file that overrides a service
      present in system. Observe parse failure and non-zero exit.
Bug: 163089173
Change-Id: I520fef613e0036df8a7d47a98d47405eaa969110
2020-11-19 10:02:56 -08:00