Commit graph

67451 commits

Author SHA1 Message Date
Treehugger Robot
1433d42cea Merge "trusty: keymaster-hal: Reconnect on failed VERSION" 2021-01-21 20:36:45 +00:00
Akilesh Kailash
c7e586a7bf Merge "libsnapshot: Merge completion for sector 0" 2021-01-21 16:25:15 +00:00
Akilesh Kailash
ae0783f4c7 libsnapshot: Merge completion for sector 0
Snapuserd daemon parses the merge completion request based on
how the dm-snapshot merge is done. dm-snapshot marks the merge as
complete by zeroing out the metadata viz old-chunk and new-chunk id's.

If we have a sector 0 operation such as copy/replace op,
then old-chunk id will be 0 and new-chunk id will be a non-zero
pseudo number. Once the merge is complete, then old-chunk and new-chunk will be 0.

The problem is that daemon used to track the merge completion just by checking
if old-chunk was non-zero. This check is not sufficient and ends up
tripping the assert in the daemon.

Bug: 178061207
Test: Modify cow_snapuserd_test to test this case and validate the
      IO path.
Reported-by: Kelvin Zhang <zhangkelvin@google.com>
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I6603af1c7b55e487dc3aec0c30c0a9dea0fedb56
2021-01-21 06:27:55 +00:00
Treehugger Robot
5e9fb35ba8 Merge "Fix failure of libvbmeta_test" 2021-01-21 02:17:44 +00:00
David Anderson
86ba14be16 libsnapshot: Use a two-phase merge for VABC.
If a partition shrinks in an update, it must be merged before any other
partitions. Otherwise, a copy operation may source from the tail of the
shrunk partition, which could be overwritten by a merge operation in
another partition.

This patch adds a "MergePhase" indicator to the update status that is
valid only when the state is MERGING. Partitions that shrink are merged
first, and the phase will be FIRST_PHASE. Once ProcessUpdateState() has
determined that all first-phase snapshots are merged, it will switch to
SECOND_PHASE and remaining snapshots can start merging.

Otherwise, there is no change to the merge algorithm. The phase split is
an implementation detail and not exposed to update_engine.

Bug: 177935716
Test: vts_libsnapshot_test
Change-Id: I06043f8e3b81bdecefb6a4b5944a97b7086eeb49
2021-01-20 18:17:08 -08:00
David Anderson
91c9f56d30 libsnapshot: Pass the correct source device to snapuserd.
When a partition shrinks, it is not correct to use the base device as
the "source" device for the new COW format, because we may need to read
blocks that do not exist in the new partition.

To resolve this, we store a copy of the old partition layout in /metadata,
and use it to create a "source" view of the old partition. The new
stacking looks as follows:

  partition_b (dm-snapshot):
   - partition_b-base (partition_b dm-linear)
   - partition_b-cow-user (dm-user + snapuserd):
      - partition_b-cow (COW image)
      - partition_b-src (partition_a dm-linear)

Bug: 177935716
Test: vts_libsnapshot_test
Change-Id: I872f271cc1f25cc796b94188fdde247cdc4050b4
2021-01-20 18:17:08 -08:00
David Anderson
dc73581e53 libsnapshot: Removed the unused "linear" optimization.
VAB has an unused optimization that allows bypassing snapshots for the
area of a partition that grows during an OTA. The code for this is
entirely unused since the optimization was never enabled. The benefits
are marginal, and making it safe is quite complicated. The "new" region
cannot overlap with any region being relinquished by a shrink operation,
without snapshotting the region that would be overwritten. This would be
burdensome to implement and would minimize space savings.

Let's remove the code related to this optimization until we are
confident we can implement it safely in VABC.

Bug: 177935716
Test: vts_libsnapshot_test
Change-Id: I7d6a68dce57c8a4389ea6bff9f31971276a20db4
2021-01-20 18:17:07 -08:00
Matthew Maurer
c4abbe6427 trusty: keymaster-hal: Reconnect on failed VERSION
Trusty Keymaster will currently disconnect the client on an invalid
message. This includes the newly introduced GET_VERSION2 message.

While in the future we could change this behavior, this is a backcompat
path and so we can't assume a changed Trusty. Reconnect on failed
GET_VERSION2 before attempting version negotiation.

Bug: 177843218
Test: Set PIN on device using older Trusty
Change-Id: Ie60e4aaafa43e375797e6288b97834cac42413f4
2021-01-20 13:21:37 -08:00
Treehugger Robot
da0f466da2 Merge "Remove unnecessary #includes." 2021-01-20 19:44:03 +00:00
Bowgo Tsai
5346093a19 Fix failure of libvbmeta_test
The test uses 'external/avb/test/data/testkey_rsa2048.pem' from the
source tree, which is not available when running the test. Copy
the test key with the test case in Android.bp to fix the issue.

Bug: 177906739
Test: atest libvbmeta_test

Change-Id: I528dcdc5b48ed4af36ddd360380eb39631ff4317
2021-01-20 15:41:21 +08:00
Howard Chen
79f7e3f1fc Merge "Fix the MapWithLoopDevice" 2021-01-20 02:45:23 +00:00
Pirama Arumuga Nainar
a1d04e4de4 Merge "Allow fchmod syscalls on code-coverage builds" 2021-01-20 00:17:42 +00:00
Janis Danisevskis
8e24de53c8 Merge "Integrate IKeystoreAuthorization aidl's addAuthToken with gatekeeperd." 2021-01-19 21:11:47 +00:00
Pirama Arumuga Nainar
d9bbb1acd7 Allow fchmod syscalls on code-coverage builds
Bug: http://b/177693725

fchmod is used to ensure profraw files are readable by all users with
Clang's profile merging.

Test: ensure mediaswcodec doesn't crash in code coverage build.
Change-Id: Ia1e3b5b51c1d2fc86d548cfd066e849b03004731
2021-01-19 13:09:32 -08:00
David Anderson
7e68a82860 Merge changes I1da95645,I1a2219b5,I57dbf204
* changes:
  libsnapshot: Fix incorrect CHECK in PerformInitTransition().
  libsnapshot: Propagate the compression bit across state changes.
  libsnapshot: Adjust partition sizes so tests pass with or without compression.
2021-01-19 17:46:35 +00:00
Elliott Hughes
d8af5b5e4f Remove unnecessary #includes.
Sadly, it looks like we do still really use libcutils for some of the
socket functions.

Test: treehugger
Change-Id: Ic71f97507c89b10d2f3b7a2971064a9e6b1d349d
2021-01-19 09:21:52 -08:00
Hasini Gunasinghe
6fd560377f Integrate IKeystoreAuthorization aidl's addAuthToken with gatekeeperd.
Bug: 166672367
Bug: 177830239
Bug: 177791435
Bug: 177787061
Bug: 177787180
Test: VTS test
Change-Id: I15b751ec993a240756e58c2df3352c544bced517
2021-01-19 14:42:33 +00:00
Martijn Coenen
c31f764362 Merge "Move restorecon of /data earlier in boot sequence." 2021-01-19 09:37:39 +00:00
Louis Chang
bccf7601ae Merge "Revert "Integrate IKeystoreAuthorization aidl's addAuthToken wit..."" 2021-01-18 14:58:14 +00:00
Martijn Coenen
c7a26dc263 Move restorecon of /data earlier in boot sequence.
A future early-boot daemon (on-device signing) needs to access
/data/misc before fs-verity keys are locked. Therefore, move the
restorecon of /data up a bit, to make sure the labels are correct. To be
safe, only run it after init_user0, since that function is responsible
for loading DE keys.

Also move early boot keys and fs-verity key locking a bit later, since
the on-device signing daemon needs to use both of these, but it also
needs the restorecon to function correctly.

Bug: 174740982
Test: manual
Change-Id: I9b6e44d9b547d420e1c6ba01fb3d3accc0625e20
2021-01-18 13:42:53 +01:00
Louis Chang
4c66b8a35c Revert "Integrate IKeystoreAuthorization aidl's addAuthToken wit..."
Revert "Implement addAuthToken method of IKeystoreAuthorization ..."

Revert "Integrate IKeystoreAuthorization aidl's addAuthToken wit..."

Revert submission 1519257-rename_auth_service

Reason for revert: breaking WM presubmit, b/177787180
Reverted Changes:
Ib847b68d4:Integrate IKeystoreAuthorization aidl's addAuthTok...
I7893ab452:Integrate IKeystoreAuthorization aidl's addAuthTok...
I4a092119c:Implement addAuthToken method of IKeystoreAuthoriz...

Change-Id: Icc48050a127fa3a931cb0b591db8165384e2fe25
2021-01-18 10:01:12 +00:00
Treehugger Robot
9d78718441 Merge changes I5d17fc87,If1cc6b9a
* changes:
  Cgroup APIs are guarded
  Remove __ANDROID_API__ guards
2021-01-18 09:21:00 +00:00
Howard Chen
08deaa39d2 Fix the MapWithLoopDevice
This fix is to keep the dm line in the status file and let the
UnmapImageDevice to clean up correctly.

Bug: 171861574
Test: execute following command on a device with a SD card inserted
    adb shell am start-activity \
        -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \
        -a android.os.image.action.START_INSTALL \
        -d file:///storage/emulated/0/Download/system.raw.gz \
        --el KEY_SYSTEM_SIZE $(du -b system.raw|cut -f1) \
        --el KEY_USERDATA_SIZE 4294967296

Change-Id: Ia56f8f724f04e7e20586e088c89b62a1068766e4
2021-01-18 12:40:56 +08:00
Chris Ye
f41e334922 Allow system server to access sysfs node of led lights.
To support input device lights manager feature in frameworks, provide
sysfs node access to system server process.

Bug: 161633625
Test: atest LightsManagerTest, atest InputDeviceLightsManagerTest
Change-Id: Ic823539e9dd616b6ca4ae803756746e0f5349ec1
2021-01-17 06:58:39 +00:00
Treehugger Robot
ba73e995e5 Merge "Integrate IKeystoreAuthorization aidl's addAuthToken with gatekeeperd." 2021-01-16 22:05:18 +00:00
Kelvin Zhang
8196853980 Merge "Fix macOS build." 2021-01-16 15:05:43 +00:00
David Anderson
52c6f991c5 libsnapshot: Fix incorrect CHECK in PerformInitTransition().
The sector count can decrease as the merge progresses, so we only care
that the sector count is less than or equal to the device size.

Bug: N/A
Test: reboot during VABC merge
Change-Id: I1da956456ea28ca0fdfbf9373848987c9f71ff68
2021-01-15 23:14:15 -08:00
David Anderson
116be4e2bd libsnapshot: Propagate the compression bit across state changes.
This bit was getting lost because InitiateMerge() did not save the
compression bit when overwriting the update state.

Bug: N/A
Test: vts_libsnapshot_test
Test: reboot during merge phase of VABC OTA
Change-Id: I1a2219b501088de352a9c31d4b8b1a3f72d0e159
2021-01-15 23:14:15 -08:00
Elliott Hughes
4444824902 Fix macOS build.
Bug: http://b/177702122
Test: treehugger
Change-Id: I64ad7f506fb241c5f949c7bbac55a26161bd510e
2021-01-15 17:46:28 -08:00
Tri Vo
e865d88531 Merge changes I06a7b475,Ic7a30b75,Ib22cf72b
* changes:
  trusty: Collect sancov file from confirmationui fuzzer
  trusty: coverage: Append .<pid>.sancov to sancov file names
  trusty: fuzz: Explicit errors instead of asserts
2021-01-16 01:13:35 +00:00
Treehugger Robot
5809095dab Merge "Move debuggerd_test over to mallopt()." 2021-01-16 01:07:05 +00:00
Treehugger Robot
6e6df01f3e Merge "Move cutils over to mallopt()." 2021-01-16 01:04:24 +00:00
Elliott Hughes
03b283a65f Move debuggerd_test over to mallopt().
Bug: http://b/135772972
Test: treehugger
Change-Id: I178f2a753b5608d9e72cee8874524ad4faf701d7
2021-01-15 11:34:26 -08:00
Andrew Scull
ecd550a8d7 Merge "fastboot: Add pvmfw" 2021-01-15 19:19:36 +00:00
Elliott Hughes
66304a0ada Move cutils over to mallopt().
Bug: http://b/135772972
Test: treehugger
Change-Id: I35e0fc657f2e4cecea2a29f78cad148895413e17
2021-01-15 11:18:24 -08:00
Andrew Scull
be823d71bd fastboot: Add pvmfw
The pvmfw partition holds the protected VM firmware that is used by
Protected KVM to bootstrap the trust in protected VMs. Teach fastboot
about the partition so it gets flashed with flashall.

pvmfw is an AVB chained partition so is marked as BootCritical to allow
ABL's AVB verification to pass.

Test: tab complete and flashall
Bug: 171280178
Change-Id: Ie4cc478de25a945bc510488d87c2bee3aa5031f2
2021-01-15 15:50:01 +00:00
David Anderson
cf41cb7a8c libsnapshot: Adjust partition sizes so tests pass with or without compression.
Bug: N/A
Test: vts_libsnapshot_test
Change-Id: I57dbf204b1d5c7208cbdbdf281741b67189d70dd
2021-01-14 23:29:37 -08:00
Tri Vo
8da3ee71a3 trusty: Collect sancov file from confirmationui fuzzer
Bug: 174402999
Test: trusty_confirmationui_fuzzer
Change-Id: I06a7b475c0023cf1530aff636e5ac2295009fd73
2021-01-14 21:25:10 -08:00
Tri Vo
315967e660 trusty: coverage: Append .<pid>.sancov to sancov file names
Bug: 175221942
Test: adb shell ./trusty_gatekeeper_fuzzer -runs=0 corpus
Change-Id: Ic7a30b7531e8a327fb8ebe953fa02946e8539579
2021-01-14 21:25:10 -08:00
Tri Vo
2c56d833c5 trusty: fuzz: Explicit errors instead of asserts
Bug: 171750250
Test: m \
      trusty_test_fuzzer \
      trusty_gatekeeper_fuzzer \
      trusty_keymaster_fuzzer \
      trusty_confirmationui_fuzzer
Change-Id: Ib22cf72b2db7b991e716c0116ca57d3f77459ada
2021-01-14 21:25:07 -08:00
Treehugger Robot
76d44b077e Merge "Remove healthd." 2021-01-14 23:41:46 +00:00
Tri Vo
3c651c278c Merge changes Iad1713e1,Iaee2c74b,I6bd1c8b2,I067dd077
* changes:
  trusty: Add simple fuzzer for keymaster TA
  trusty: Increase limit on coverage counters
  trusty: Write out sancov file when fuzzer exits
  trusty: Switch to dmabuf for coverage shared memory
2021-01-14 21:28:16 +00:00
Treehugger Robot
8e3826b8b1 Merge "Make ro.product.cpu.abilist* to be fetched dynamically" 2021-01-14 18:34:21 +00:00
Daniel Rosenberg
bdd1244d54 Merge "libsnapshot: Set default cluster size to 200" 2021-01-14 01:12:25 +00:00
Stephen Crane
f7b8a597f1 trusty: Add simple fuzzer for keymaster TA
Adds a simple libfuzzer-based coverage guided fuzzer for keymaster.
Current coverage is low, so we'll need to improve this with an initial
corpus or a more sophisticated protocol aware fuzzer.

Bug: 175918322
Test: make trusty_keymaster_fuzzer
Test: adb shell /data/fuzz/arm64/trusty_keymaster_fuzzer/trusty_keymaster_fuzzer
Change-Id: Iad1713e1a73cc5a6a3ec742cc433d1337aca9bc3
2021-01-13 16:21:49 -08:00
Stephen Crane
6735f8475e trusty: Increase limit on coverage counters
Keymaster has more than 4096 counters, so we need to allocate a larger
section for the libfuzzer extra counters. Increases the size of the
extra counters section to 16384.

Bug: 171750250
Test: atest libtrusty_coverage_test
Change-Id: Iaee2c74b6d0c7ae8a2e5a30525759f89f825a091
2021-01-13 16:09:33 -08:00
Stephen Crane
6bd77df8fc trusty: Write out sancov file when fuzzer exits
Add emission of sancov file when CoverageRecord is destroyed. This
will occur when a fuzzer driver exits cleanly, i.e. -runs=0 with an
existing corpus.

Test: make trusty_gatekeeper_fuzzer
Test: adb shell ./trusty_gatekeeper_fuzzer -runs=0 corpus
Bug: 175221942
Change-Id: I6bd1c8b2f2091e894c35f7a4874b54577a91c8fc
2021-01-13 16:09:31 -08:00
Stephen Crane
0d67131dd9 trusty: Switch to dmabuf for coverage shared memory
Trusty shared memory now uses dmabuf instead of memfd. Switch the
coverage buffer allocation to use libdmabufheap.

Test: atest libtrusty_coverage_test
Bug: None
Change-Id: I067dd0774d19b42380ce5cb8ceb3541fa77ef9f0
2021-01-13 15:56:25 -08:00
Josh Gao
1091d24c16 tombstoned: support for protobuf fds.
Test: debuggerd_test
Change-Id: Id0f0fa2856e4b8e57d7dc0e1495134e943b289da
2021-01-13 13:35:45 -08:00
Josh Gao
e2aa621c83 tombstoned: make it easier to add more types of outputs.
While we're at it, switch to unlinkat.

Test: debuggerd_test
Change-Id: I8d285c4b4e94effa1acb8f69ac3af4ff8c37defb
2021-01-13 13:35:45 -08:00