Commit graph

1750 commits

Author SHA1 Message Date
Howard Chen
cd8b982e40 Merge "Add a switch to enforce avb for DSU in userdebug" 2020-02-11 06:21:38 +00:00
Howard Chen
f4d345c5ee Add a switch to enforce avb for DSU in userdebug
Bug: 148997664
Test: adb root && adb shell touch /metadata/gsi/dsu/avb_enforce
Change-Id: I5308fa1ae3ca32ee49575fdc52475ad67d51c176
2020-02-10 18:39:57 +00:00
Bernie Innocenti
ba9b73ef8f Convert system/core/fs_mgr to Result::ok()
No functionality changes.

Test: m checkbuild
Change-Id: I96b2adfe7aaea2b2e67307a3ce308455bc1d7a0a
2020-02-10 08:20:25 +09:00
Treehugger Robot
86e13d79cc Merge "rm libbinderthreadstate" 2020-02-07 11:18:51 +00:00
Steven Moreland
f5f9e3594c rm libbinderthreadstate
This library is empty, and its functionality has moved
into libbinder/libhwbinder.

Bug: 148692216
Test: N/A
Change-Id: I306a2c18ec7770cfb6c3939b5e3d42a55c3165fb
2020-02-06 13:25:34 -08:00
Bernie Innocenti
cecebbbacc Convert system/core to Result::ok()
No functionality changes, this is a mechanical cleanup.

Test: m
Test: cd system/core && atest
Change-Id: Ifdaa3ce1947ed578f656d5a446978726eb416c36
2020-02-06 17:04:27 +00:00
Treehugger Robot
a6bc86aae7 Merge "Add libsnapshot_test to presubmit" 2020-02-06 16:58:43 +00:00
David Anderson
24c70ea7ba Merge "libsnapshot: Restrict when snapshots can be deleted." 2020-02-06 16:46:58 +00:00
Alessio Balsini
9ab7fe2768 Add libsnapshot_test to presubmit
Add libsnapshot test to the TEST_MAPPING's presubmit of fs_mgr to run
the test on TH whenever changes are applied to the fs_mgr contents.
Some of the tests are temporarily disabled due to a WIP bug.

Test: TH
Bug: 142513589
Change-Id: I2a283645b433ed1fd2b08d1c4919cac26d19cf16
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-06 14:58:25 +00:00
David Anderson
367cca3937 libsnapshot: Restrict when snapshots can be deleted.
Do not delete snapshots for any reason other than merge-complete or a
cancel request from update_engine. Additionally, create a rollback
indicator file if booting into the source slot, so update_engine can
attempt to cancel the update.

Bug: 147819418
Bug: 147347110
Test: libsnapshot_test gtest
Change-Id: Id357a91cec467a60246c7c3d133f6c54ccb3fc93
2020-02-05 17:16:17 -08:00
Alessio Balsini
c352179e10 fiemap: add image_test and writer_test tests to presubmit
Add fiemap_image_test and fiemap_writer_test to TEST_MAPPING to be run
by TH as presubmits.
Because of a bug under investigation, the actual
fiemap_image_test_presubmit is used instead of the original, that has
one test case disabled.

Bug: none
Test: TH, fiemap_image_test, fiemap_writer_test
Change-Id: I63b5e69b5c245a18eceb1e5896df7bd0577f289b
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-05 22:08:29 +00:00
Alessio Balsini
f6034544c0 fiemap: fix fiemap size and log message when last extent
Fix the total fiemap struct plus extents size allocation.
Fix also the logging in IsLastExtent, that was printing error messages
every time.

Bug: none
Test: fiemap_*_test
Change-Id: I85c6af63ba3a75b993a5e8ad7d7170dc7af59582
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-05 18:27:40 +00:00
Bowgo Tsai
e0f5c10691 first_stage_mount: reading all avb_keys before chroot
Avb keys used to verify a partition are stored in the first-stage
ramdisk. However, after /system is mounted, init will chroot into it.
This makes those keys inaccessible for later mounts, e.g., /vendor or
/product.

This change retains avb keys by reading all of them before chroot
into /system.

Note that it is intentional to perform public matching for both
preload_avb_key_blobs and fstab_entry.avb_keys in libfs_avb.
As some keys might only be availble before init chroots into /system,
e.g., /avb/key1 in the first-stage ramdisk, while other keys might
only be available after the chroot, e.g., /system/etc/avb/key2.

Bug: 147585411
Test: specify avb_keys for a partition and checks the keys are preloaded
Test: atest libfs_avb_test
Test: atest libfs_avb_internal_test
Change-Id: I6bd490c4215480db2937cdfc3fea0d616e224a91
2020-02-05 15:51:41 +08:00
Treehugger Robot
3cbb753b0d Merge "liblp: add test to presubmit" 2020-02-05 01:20:36 +00:00
Yifan Hong
e8cd50a7a0 Merge "libsnapshot::RemoveAllUpdateState log stack" 2020-02-04 23:31:47 +00:00
Treehugger Robot
405d26dacb Merge "Set e2freefrag and e2fsdroid as required by libfs_mgr_defaults" 2020-02-04 22:57:36 +00:00
Yifan Hong
c19b08a66a Merge "Make snapshotctl logging better." 2020-02-04 22:18:33 +00:00
Treehugger Robot
b34a729469 Merge "snapshot/test: Add delay to all the CreateLogicalAndSnapshotPartitions" 2020-02-04 22:16:52 +00:00
Yifan Hong
e8148150c3 libsnapshot::RemoveAllUpdateState log stack
Bug: 148818798
Test: apply OTA but cancel it in the middle, then
      delete /data/misc/update_engine/prefs/*, then
      reapply it again (to trigger CancelUpdate()).
      Stack is dumped.

Change-Id: I2dfb6b7f15b9d5854d0b81ed8ad260538d21c922
2020-02-04 14:01:24 -08:00
Yifan Hong
12fe03d470 Make snapshotctl logging better.
snapshotctl merge --logcat --log-to-file
- If --logcat, log to logcat
- If --log-to-file, log to /data/misc/snapshotctl_log/
- If both, log to both
- If none, log to stdout

Test: manually test these 4 cases
Bug: 148818798
Change-Id: I44b52936c0d095867acc6ee781c6bec04f6ebd6b
2020-02-04 14:01:24 -08:00
Alessio Balsini
13d2d968d9 liblp: add test to presubmit
Add liblp_test to TEST_MAPPING to be triggered as TH presubmit test.

Bug: none
Test: liblp_test
Change-Id: If4d60e816e4e1b321603e1a5ed00e21297567d38
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-04 21:33:56 +00:00
Alessio Balsini
272ef868f1 Extra logging for metadata errors
Increase logging in metadata image management.

Bug: none
Test: m
Change-Id: Ie49ca9ac90cd593c95d31f4651ae724d617d5695
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-04 20:49:59 +00:00
Alessio Balsini
841bccc1eb snapshot/test: Add delay to all the CreateLogicalAndSnapshotPartitions
In tests CreateLogicalAndSnapshotPartitions may give flaky results
because not synchronous.
Add a bounded delay that prevents this behavior defined by a single
constexpr.

Bug: none
Test: libsnapshot_test
Change-Id: Iad3c24b1d3e82e3bd695d6dbbc8af8eab75bee32
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-04 19:33:35 +00:00
Mark Salyzyn
3576ed043c tests: handle legacy and new bootstat complete
Regression from commit cb1a8e7fdd
("Don't retrigger bootstat during userspace reboot.")

sys.boot_completed and either sys.logbootcomplete (legacy) or
sys.bootstat.first_boot_completed set to determine if the display
has gone active for bootstat.  For adb remount test we have no
desire or need to wait for bootstat complete, reduce script
complexity.

Also solve a possible problem with no content supplied to xargs.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Test: adb-remount-test.sh
Bug: 148804390
Bug: 135984674
Change-Id: Ieefddf583ff7422e8811d2e338a0f16c8943b0d7
2020-02-04 09:01:31 -08:00
Daniel Rosenberg
2e10d8f74f Merge "Add support for casefold and product ID to format" 2020-02-03 23:12:15 +00:00
Treehugger Robot
be074feb93 Merge "Add libdm_test to presubmit" 2020-02-03 21:55:39 +00:00
Treehugger Robot
962e3ddfd6 Merge "Missing UpdateState::Cancelled string conversions" 2020-02-03 20:03:56 +00:00
Alessio Balsini
d7cc465481 Add libdm_test to presubmit
Also add libdm_test to the TEST_MAPPING's presubmit of fs_mgr to run the
test on TH whenever changes are applied to the fs_mgr contents.

Test: TH
Bug: none
Change-Id: Icc6adeeacaefbcfeb494f37fc776eb5a886a5183
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-03 17:34:44 +00:00
Alessio Balsini
a60f6a35ec Missing UpdateState::Cancelled string conversions
Add the missing UpdateState::Cancelled conversions from/to string.

Bug: none
Test: build
Change-Id: I097d80e21521725fbb02f3ef37b22e95a5e83929
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-03 16:37:51 +00:00
Alessio Balsini
fb19ed9130 Update assertion on DmTargetDefaultKey param string
Due to some recent code updates that introduced some additional
extra_argv, the DmTargetDefaultKey::GetParameterString() test was
failing.
Update the string accordingly.

Bug: none
Test: libdm_test
Change-Id: I63fab27e32a08211a43d4804d90a6f19ea4edc06
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-03 10:37:36 +00:00
Treehugger Robot
cb1a8e7fdd Merge changes from topics "dm-default-key-v2", "metadata_cipher"
* changes:
  Set metadata cipher in fstab
  Add support for v2 of dm-default-key
2020-02-01 16:12:30 +00:00
Treehugger Robot
afb6b354a9 Merge "Propagate failure of MetadataBuilder creation in CreateUpdateSnapshots" 2020-02-01 12:22:38 +00:00
Daniel Rosenberg
29bc5d4924 Add support for casefold and product ID to format
Product ID Quotas require wider inodes. For Ext4, quotas and casefolding
are enabled later via tune2fs

Bug: 138322712
Bug: 138321217
Test: Build with and without casefolding and quotas. Verify fs features
Change-Id: I99819f6c38adabcf7a1f944085f9005134e6fc5f
2020-01-31 18:34:03 -08:00
Paul Crowley
3d8e105510 Set metadata cipher in fstab
Bug: 147814592
Test: Cuttlefish can use adiantum
Change-Id: I9207ffcdb74dcd36c8b2534b51233a3f8e80dc0b
2020-01-31 14:45:00 -08:00
Paul Crowley
f1b264f17c Add support for v2 of dm-default-key
Version 2 of dm-default-key has an extra parameter and always sets the
DUN.

Bug: 147814592
Test: Cuttlefish boots with keydirectory flag
Test: Crosshatch formatted before this change boots after it
Change-Id: I309bcc3f907a6df745f5c073b0017a7dd5b5354b
2020-01-31 14:45:00 -08:00
Paul Crowley
60a55d91dc Merge "Rename key_dir to metadata_key_dir and refactor" 2020-01-31 21:49:13 +00:00
Paul Crowley
7823e327c1 Rename key_dir to metadata_key_dir and refactor
Bug: 147814592
Test: Crosshatch boots
Change-Id: I18b03486d2e93c6103880d1af68d9f70147fde63
2020-01-30 16:03:45 -08:00
Alessio Balsini
fb5de5bc8f Propagate failure of MetadataBuilder creation in CreateUpdateSnapshots
In a device with malformed metadata, the MetadataBuilder returns a
nullptr that may cause segmentation faults when using the builder.
Fix by handling the nullptr exception in CreateUpdateSnapshot and
propagating the error to its caller.

Bug: n/a
Test: libsnapshot_test
Change-Id: Ie9148a552cf4bb223ab8d54b1d30d2b13d92bb22
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-01-30 22:42:54 +00:00
Alessio Balsini
fce02741d3 Skip snapshot tests for non-Virtual A/B devices
The libsnapshot features are currently not used anywhere else than the
update system with Virtual A/B.
Ignore libsnapshot tests for devices that are not implementing this
feature.

Test: m, snapshot_test, OTA
Bug: 142513589
Change-Id: I4580bae5ed315f21501556eea062e6af1f982ab3
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-01-30 16:23:27 +00:00
Treehugger Robot
274bd807a6 Merge "Creating logical and snapshot partitions uses timeout in tests" 2020-01-30 02:57:25 +00:00
David Anderson
838b1a1f94 Merge "fs_mgr: Fix MapScratchPartitionIfNeeded signature" 2020-01-29 22:48:08 +00:00
Treehugger Robot
68acec7723 Merge "Dependency cleanup for snapshot .bp" 2020-01-29 20:55:03 +00:00
Luca Stefani
32835b3967 fs_mgr: Fix MapScratchPartitionIfNeeded signature
Test: lunch aosp_x86_64-user; m

Change-Id: I0cd9be80baab664dd374593c1a4f45cea6a0cc78
2020-01-29 20:58:06 +01:00
Treehugger Robot
30abf7a9fc Merge "libsnapshot_test runs as root" 2020-01-29 18:43:53 +00:00
Alessio Balsini
153ccacfb6 Creating logical and snapshot partitions uses timeout in tests
CreateLogicalAndSnapshotPartition is used in first-stage init and by
default never blocks (thanks to a timeout set to 0).  This causes some
libsnapshot tests to fail, because snapshot devices may be accessed
before there actual creation is complete.
Fix by introducing a timeout_ms argument, set to 0 if unspecified.

Test: libsnapshot_test
Bug: 142513589
Change-Id: I5e23adaaf6df8603df501b9a25fdd1e9d8c15252
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-01-29 18:24:50 +00:00
Alessio Balsini
5dd50b2b84 Dependency cleanup for snapshot .bp
Reorder, remove and fix some of the dependencies in the Android.bp for
snapshot.

Test: m, snapshot_test, OTA
Bug: 142513589
Change-Id: Id214a8d6453a5675e60cda4352094dc3987292ec
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-01-29 16:31:06 +00:00
Alessio Balsini
a7383b4001 libsnapshot_test runs as root
Add flag in Android.bp to force the execution of libsnapshot_test as
root.

Test: m
Bug: 142513589
Change-Id: I9d047a9e1f9ea6d6e5540fa66fb42603ea136641
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-01-29 16:31:06 +00:00
David Anderson
c13586faea remount: Use /data for backing scratch storage.
Currently, this is only enabled for Virtual A/B devices. When /data uses
F2FS, then proper pinning support must be enabled.

Because /data cannot be mounted in recovery, we can't delete the scratch
image backed by /data while in fastbootd. Instead, we mark it as
disabled in /metadata. The remount command now has an init script that
checks for and removes a disabled scratch partition.

Bug: 134949511
Test: adb remount on V A/B device with patched F2FS
Change-Id: Ifc8720378259654472d3822e97059b6c366f601d
2020-01-28 12:04:38 -08:00
David Anderson
21394f6e85 Merge "Fix mounting /data on Virtual A/B devices without metadata encryption." 2020-01-27 16:01:59 +00:00
David Anderson
671bd812cf Fix mounting /data on Virtual A/B devices without metadata encryption.
When using partitions backed by /data, for example during a Virtual A/B
merge or "adb remount" on a Virtual A/B device, the userdata block
device is seen as in-use when /data mounts in second-stage init. This
subsequently prevents mount() or e2fsck from working. Metadata-encrypted
devices are not affected, because dm-default-key provides a wrapping
block device that can be used exclusively.

This patch addresses the problem by detecting when userdata has
device-mapper dependencies. If it does, and the device is not
metadata-encrypted, we introduce a dm-linear wrapper around userdata.
It is created on demand, but like logical partitions, it exists until
the device reboots.

Bug: 134949511
Test: adb remount, cuttlefish boots
Change-Id: Ifbfea1591a6e58978fdaffd6ef889afabd10e270
2020-01-25 10:39:47 -08:00