Commit graph

64860 commits

Author SHA1 Message Date
Yo Chiang
b445a01263 Use default dsu slot name when host is Android Q
DSU slotting support is added in Android R, so
android::gsi::GetActiveDsu() is guaranteed to fail if DSU guest system
is S and host is Q.
In that case, just assume the the DSU slot to be "dsu".

Bug: 172541102
Bug: 168571434
Test: Boot GSI S on Q pixel with DSU
Change-Id: I96e191907ce2fedf8c22b7887e930a7c455eb593
2020-11-06 09:00:41 +00:00
David Anderson
56850e12e3 Merge "libsnapshot: Add an open /dev/null mode for CowWriter." 2020-11-05 07:37:43 +00:00
David Anderson
1b9ab3f544 libsnapshot: Add an open /dev/null mode for CowWriter.
This will be used by payload_generator to estimate the COW size without
using extra storage space.

Bug: 168554689
Test: cow_api_test, ota_from_target_files
Change-Id: I095c809e7d81eff5321b86f4c6bdfb6e9467e84e
2020-11-04 20:38:50 -08:00
Treehugger Robot
f2609b2b0f Merge "libsnapshot: Only sync after labels" 2020-11-05 03:52:04 +00:00
David Anderson
c497a1c63c Merge "libsnapshot: Use the COW size from the update manifest." 2020-11-04 20:20:14 +00:00
Treehugger Robot
fded8e696c Merge "Fix unused function error for user build" 2020-11-04 10:47:35 +00:00
Yo Chiang
cc86e967c7 Fix unused function error for user build
```
system/core/fs_mgr/fs_mgr_overlayfs.cpp:83:6: error: unused function
'fs_mgr_is_dsu_running' [-Werror,-Wunused-function]
```

Bug: 172405271
Bug: 165925766
Test: build aosp_bonito-user, no warning/error
Change-Id: I3206e5bd13658ab0b7f5826e8e1c206c8df65684
2020-11-04 07:02:47 +00:00
Rick Yiu
b4a3f080e6 Merge "libprocessgroup: Support write to file feature" 2020-11-04 04:54:42 +00:00
Treehugger Robot
f6d42d45c5 Merge changes I669a03a6,Ibb774d6d
* changes:
  libsnapshot: Fix footer values and verification
  libsnapshot: Fix some minor formatting bugs
2020-11-04 04:50:42 +00:00
Yo Chiang
65f4f4359d Merge changes from topic "dsu-overlayfs"
* changes:
  Refactor fs_mgr_overlayfs_teardown()
  Enable overlayFS on DSU system
2020-11-04 03:30:31 +00:00
Yo Chiang
497bca09c7 Merge "adb-remount-test.sh: Make devt errors warnings instead" 2020-11-04 03:30:31 +00:00
Yo Chiang
5ab4400db1 Merge "TransformFstabForDsu() skips handling special devices" 2020-11-04 03:30:31 +00:00
David Anderson
dfaede06bc Merge changes from topic "init-snapuserd"
* changes:
  libsnapshot: Implement MapAllSnapshots and UnmapAllSnapshots.
  Start snapuserd if needed as soon as possible during second-stage init.
  libsnapshot: Add support for first-to-second-stage transitions of snapuserd.
2020-11-03 18:24:49 +00:00
Tom Cherry
22e036bd26 Merge "Move CtsLiblogTestCases and CtsLogdTestCases to system/logging/TEST_MAPPING" 2020-11-03 14:14:08 +00:00
Rick Yiu
bc1ad9671a libprocessgroup: Support write to file feature
There may be some use cases that it needs to write string to a
file. This patch support write "Value" to "FilePath", where
both parameters could use special string "<uid>" and "<pid>" to
represent actual uid and pid.

Bug: 170507963
Test: function works
Change-Id: I543846f523518a9bcb3dd1b3437163a1b3157d95
2020-11-03 20:56:48 +08:00
Daniel Rosenberg
d5bcbaa066 libsnapshot: Only sync after labels
This changes labels to belong at the end of the set of ops that they
refer to. We only sync after writing a label, or the footer, saving the
cost of syncing after ever op.

Change-Id: Iee9dd69132b8e3321eccfe1e43fa0c072a94d3bd
Bug: 172026020
Test: cow_api_test
2020-11-03 00:40:02 -08:00
Daniel Rosenberg
290b0ed4b3 libsnapshot: Fix footer values and verification
A few values in the footer were being set inconsistently. We weren't
verifying them, so it didn't matter. This adds verification and sets
them properly.

Change-Id: I669a03a6e1e87ace31775aba5b67dde9b6e5ecf5
Bug: 168829493
Test: cow_api_test
2020-11-03 00:40:02 -08:00
Daniel Rosenberg
46ef7595d0 libsnapshot: Fix some minor formatting bugs
A few minor issues snuck through code review.
Removed a debug line in cow_api_test to persist file.
Removed unused function declaration for cow writer
Switched PLOG to LOG where no errno exists.

Change-Id: Ibb774d6de518fc2a8746e4b9eefc3655c9973c30
Bug: 168554689
Test: cow_api_test
2020-11-03 00:39:45 -08:00
Treehugger Robot
485505c06d Merge "Fix the expected tagged_addr_ctrl in a test." 2020-11-03 03:12:02 +00:00
Treehugger Robot
8df6d9e0de Merge "Store result of mount_all for mounted userdata by metadata encryption" 2020-11-03 02:18:24 +00:00
Peter Collingbourne
2b6764a625 Fix the expected tagged_addr_ctrl in a test.
It turns out that I had originally written the test with a local
patch applied that forces TCF0 to SYNC, so it was testing for the
wrong tagged_addr_ctrl value. Fix it.

Bug: 135772972
Change-Id: Ibb9b25e5f5635372ad5de7825c31d7264ff02590
2020-11-02 16:00:08 -08:00
Treehugger Robot
9979a4f79d Merge "Remove symlink libprocinfo" 2020-11-02 23:29:24 +00:00
Tri Vo
0b0f7f31b9 Merge changes I7741c7e5,I30bb2844,If55b93b1,Ife058ca2
* changes:
  trusty: fuzz: dump trusty kernel logs on crash
  trusty: Add corpus for gatekeeper fuzzer
  trusty: Fuzzer for Gatekeeper TA
  trusty: fuzz: Helper library
2020-11-02 23:09:13 +00:00
Treehugger Robot
8b4a9a9a61 Merge "Move e2fsck into /first_stage_ramdisk." 2020-11-02 21:33:07 +00:00
David Anderson
eb7eb4bef6 libsnapshot: Use the COW size from the update manifest.
When Virtual A/B Compression is enabled, the manifest contains the
predicted COW size. Use this instead of the algorithm based on the
kernel COW format.

Bug: 168554689
Test: vts_libsnapshot_test
Change-Id: I545679b4834957ff80a930d91cb44afbadebb66c
2020-11-02 13:24:16 -08:00
David Anderson
2eb7b9221b libsnapshot: Implement MapAllSnapshots and UnmapAllSnapshots.
Bug: 168554689
Test: vts_libsnapshot_test
Change-Id: I6809e226741dabcf337c3a5cfaba56afdb9edd64
2020-11-02 13:24:15 -08:00
David Anderson
b031def229 Start snapuserd if needed as soon as possible during second-stage init.
snapuserd is used as a user-space block device implementation during
Virtual A/B Compression-enabled updates. It has to be started in
first-stage init, so that updated partitions can be mounted.

Once init reaches second-stage, and sepolicy is loaded, we want to
re-launch snapuserd at the correct privilege level. We accomplish this
by rebuilding the device-mapper tables of each block device, which
allows us to re-bind the kernel driver to a new instance of snapuserd.
After this, the old daemon can be shut down.

Ideally this transition happens as soon as possible, before any .rc
scripts are run. This minimizes the amount of time the original
snapuserd is running, as well as any ambiguity about which instance of
snapuserd is the correct one.

The original daemon is sent a SIGTERM signal once the transition is
complete. The pid is stored in an environment variable to make this
possible (these details are implemented in libsnapshot).

Bug: 168259959
Test: manual test
Change-Id: Ife9518e502ce02f11ec54e7f3e6adc6f04d94133
2020-11-02 13:24:06 -08:00
David Anderson
f57fd97df3 libsnapshot: Add support for first-to-second-stage transitions of snapuserd.
This patch introduces the fundamentals needed to support booting off
dm-user. First, a method has been added to start snapuserd in
first-stage init. It simply forks and execs, creates a specially named
first-stage socket, then waits for requests.

Next, a new method has been added to SnapshotManager to perform a
second-stage handoff. This works by first launching a second copy of
snapuserd using init's normal service management functionality. The new
snapuserd runs alongside the original, but has correct privileges and a
correct selinux context. Next, we inspect each COW device, and if its
table uses dm-user, we replace the table with a renamed control
device. The new control device is bound to the new snapuserd.

device-mapper guarantees that such a table swap is safe. It flushes I/O
to the old table and then replaces it with the new table. Once the new
table is in place, the old dm-user control devices are automatically
destroyed. Thus, once all dm-user devices has been transitioned, the
first-stage daemon is idle and can gracefully exit.

This patch does not modify init. A few changes will be needed on top of
this patch:

(1) CreateLogicalAndSnapshotPartitions will need further changes to
start the first-stage daemon and track its pid. Additionally, it will
need to ensure the named socket file is deleted, so there is no further
IPC allowed after partitions are completed.
(2) init will need to propagate the pid to second-stage init so the
process can be killed (or signalled).
(3) first-stage snapuserd will need to gracefully exit once it has no
active handler threads.
(4) second-stage init will need to invoke the transition helper on
SnapshotMaanager, ideally as soon as feasible.

Bug: 168259959
Test: manual test
Change-Id: I54dec2edf85ed95f11ab4518eb3d7dbaf0bdcbfd
2020-11-02 13:24:05 -08:00
Tom Cherry
5c14450f4f Move CtsLiblogTestCases and CtsLogdTestCases to system/logging/TEST_MAPPING
Test: these tests run in presubmit
Change-Id: If7055853d3477ca3b40cc3b39c69f6077a42f990
2020-11-02 12:44:37 -08:00
Yifan Hong
92836b2e95 Merge changes from topic "toybox_vendor_ramdisk"
* changes:
  Add shell_and_utilities_vendor_ramdisk
  Make libraries {vendor_,}ramdisk_available.
2020-11-02 18:33:33 +00:00
Baligh Uddin
509eef3673 Remove symlink libprocinfo
BUG: 170465278
Test: TH
Change-Id: Ic195c735ab0f9aa232063194682ddcd73f84ab77
2020-11-02 18:16:57 +00:00
Stephen Crane
5e3a3ce011 trusty: fuzz: dump trusty kernel logs on crash
Adds an Abort() function to the fuzzer utils library that grabs and
prints the relevant trusty kernel logs before exiting the fuzzer.

Test: /data/fuzz/arm64/trusty_gatekeeper_fuzzer/trusty_gatekeeper_fuzzer
Change-Id: I7741c7e5e0ffdc402e3d3dd9a7e5856e2a640dd2
2020-11-02 10:16:44 -08:00
Stephen Crane
6c0fb906f6 trusty: Add corpus for gatekeeper fuzzer
Test: /data/fuzz/arm64/trusty_gatekeeper_fuzzer/trusty_gatekeeper_fuzzer
Change-Id: I30bb2844972df952d853f0809e2eb8d5b5a1dd9c
2020-11-02 09:58:54 -08:00
Qilin Tan
12d95df367 Store result of mount_all for mounted userdata by metadata encryption
When the userdata is mounted, its result will be stored and return.
But the result is not stored when the userdata is mounted with
metadata encryption. Store the result of metadata encryption mount.

Bug: 172180818
Test: run cts-on-gsi -m CtsUserspaceRebootHostSideTestCases
Change-Id: I88b1b4f6a2b1ed81773e18243cb6c46244dc1ba5
2020-11-02 05:27:11 +00:00
Treehugger Robot
c635d568ed Merge "Cleanup symlink for system/core/{libbacktrace, libunwindstack}" 2020-10-30 21:57:31 +00:00
Ryan Savitski
3b268df195 Merge "dev devices with permissive boot: disable perf_event_paranoid" 2020-10-30 17:48:04 +00:00
Rick Yiu
32809d8231 Merge changes from topic "aosp_use_uclamp"
* changes:
  init: Add cpu controller hierarchy to use utilclamp controller
  libprocessgroup: Replace stune with utilclamp profiles
2020-10-30 07:12:32 +00:00
Baligh Uddin
14aa6aa8c7 Cleanup symlink for system/core/{libbacktrace, libunwindstack}
BUG: 170465278
Test: TH
Change-Id: Ib906c46141886e691f4fc908d7b2f5dbe5eeda08
2020-10-30 01:44:43 +00:00
Baligh Uddin
61adc0d239 Merge "Cleanup references to system/core/liblog -> system/logging/liblog" 2020-10-30 01:30:18 +00:00
Tri Vo
10ffc3417d trusty: Fuzzer for Gatekeeper TA
Test: /data/fuzz/arm64/trusty_gatekeeper_fuzzer/trusty_gatekeeper_fuzzer
Change-Id: If55b93b1a15c5bd9a1148ff54a859635a6e7290c
2020-10-29 18:02:01 -07:00
Tri Vo
e8823ffcb4 trusty: fuzz: Helper library
Test: /data/fuzz/arm64/trusty_gatekeeper_fuzzer/trusty_gatekeeper_fuzzer
Change-Id: Ife058ca25417e6bee4bf593b10a4e7e4000f9f2f
2020-10-29 18:01:59 -07:00
Yifan Hong
3337e782e6 Move e2fsck into /first_stage_ramdisk.
On devices without a dedicated recovery partition, it is possible that
e2fsck exists in /system/bin, not /first_stage_ramdisk/system/bin, if
it is using generic ramdisk. When force_normal_boot, /system/bin/e2fsck
would not exist during first stage mount.

In this case, move /first_stage_ramdisk/system/bin/e2fsck to
/system/bin/e2fsck before switching root into /first_stage_ramdisk.
Abort if the operation fails.

On devices launching with R, e2fsck should already exist in the correct
place, so skip moving if force_normal_boot and
/first_stage_ramdisk/system/bin/e2fsck already exists.

On devices launching before R, it is possible that /system/bin/e2fsck
does not exist. Skip moving if force_normal_boot and /system/bin/e2fsck
does not exist.

Fixes: 171326057
Test: boot with GKI and move_recover_resources_to_vendor_boot, and
      check serial output

Change-Id: I8008a4cad54c7c74a84cbcabe56723bf0e193025
2020-10-29 12:59:36 -07:00
Ryan Savitski
ea93f110d2 dev devices with permissive boot: disable perf_event_paranoid
Some functionality based on eBPF attached to tracepoints (gpu memory
accounting and time-in-state) rely on newer devices running with
"disabled" perf_event_paranoid controls as a result of the kernel having
LSM hooks in the perf_event_open syscall instead. This is tested
for, and set up by init via the sys.init.perf_lsm_hooks sysprop.

Development devices that boot into permissive mode still want the
eBPF-based functionality to work, but end up with a paranoid value that
disallows the syscall, as the LSM hook test expects to observe a SELinux
denial (which doesn't happen due to permissiveness).

As a pragmatic way of achieving the paranoid value override, we pretend
that the hook test has succeeded if we detect permissive SELinux during
second-stage init. It'd be nicer if we had a sysprop to reflect the
device's on-boot status of SELinux, but it's not worth adding for this
case.

BYPASS_INCLUSIVE_LANGUAGE_REASON=technical term

Bug: 170674916
Tested: booted crosshatch-userdebug with permissive kernel cmdline,
        confirmed that the log message from the new codepath was present
        in logcat, sysprop is 1, and paranoid is -1.
Change-Id: I9df5da2076cdbd777d35e50e8cd7a483ec85e20a
2020-10-29 17:41:36 +00:00
Yifan Hong
0248561ae6 Merge changes from topic "vendor_ramdisk"
* changes:
  libprocessgroup_headers: make vendor_ramdisk_available.
  libdebuggerd_handler_fallback: make vendor_ramdisk_available.
  libcutils: make vendor_ramdisk_available.
  libpropertyinfoparser: make vendor_ramdisk_available.
2020-10-29 17:17:27 +00:00
Suren Baghdasaryan
c6baa19d6c init: Add cpu controller hierarchy to use utilclamp controller
For devices using utilclamp create cpu controller hierarchy. Do not
remove schedtune hierarchy yet because init.rc is generic and should
work with devices which still use schedtune.

Bug: 170507876
Test: cpuctl groups worked
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I8494b0b64336e0c882847d555c262814bef2ffa1
2020-10-29 16:52:18 +00:00
Suren Baghdasaryan
1b53c2496d libprocessgroup: Replace stune with utilclamp profiles
Replace schedtune out-of-tree controller's usage in the performance
profiles with utilclamp controller. Stop mounting schedtune controller.

Bug: 170507876
Test: cpuctl groups worked
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ib7fa6c902581398587c75414845c2ff6c8bdb005
2020-10-29 16:21:09 +00:00
David Anderson
4e4cff7e46 Merge "libsnapshot: Add a tool for inspecting COW files." 2020-10-29 00:27:28 +00:00
David Anderson
5fea7df825 Merge "libsnapshot: Add a skeleton API for mapping and unmapping all snapshots." 2020-10-29 00:27:19 +00:00
David Anderson
a1a5fdc6ee Merge "libsnapshot: Stop reading ops once we reach a footer." 2020-10-29 00:27:02 +00:00
Yifan Hong
7173ca82a4 Merge "Revert "Always create ramdisk/first_stage_ramdisk."" 2020-10-28 21:21:36 +00:00