Commit Graph

58450 Commits

Author SHA1 Message Date
Yifan Hong 2cea7249a9 libsnapshot: Expose SnapshotMergeStats
Test: builds
Bug: 147696014
Change-Id: Ia59a3f9226628558bdd1fdb0966812c2f652190c
Merged-In: Ia59a3f9226628558bdd1fdb0966812c2f652190c
2020-03-05 08:41:45 -08:00
Yifan Hong 3634255e66 libsnapshot: delete WaitForMerge.
Now that update_engine is responsible for initiating the
merge, WaitForMerge function becomes useless.

Bug: 147696014
Test: compiles
Change-Id: I3779bdf9dd8d1716238e21d09acf0499e3fc90a3
Merged-In: I3779bdf9dd8d1716238e21d09acf0499e3fc90a3
2020-03-05 08:41:45 -08:00
Yifan Hong d5675f6728 libsnapshot: handle errors in RemoveAllUpdateState appropriately.
In CheckMergeState / HandleCancelledUpdate, if removing update state
fails, just return the previous state. It used to return Cancelled,
and the error goes unnoticed.

Test: pass
Bug: 147696014
Change-Id: I9cb3d20c5c886afa1913740c903eaad08f0cc041
Merged-In: I9cb3d20c5c886afa1913740c903eaad08f0cc041
2020-03-05 08:41:45 -08:00
Yifan Hong 7c5ae0a12e libsnapshot: remove snapshots properly after flashing
If updated then immediately flashed target slot at unverified
stage, update_engine attempts to call RemoveAllSnapshots, but
it used to fail because unmapping fails. In reality, these devices
are dm-linear targets, so unmapping them is optional.

- Introduce a GetSnapshotFlashingStatus function that expose more
information than AreAllSnapshotsCancelled. We can use the returned
map<string, bool> to determine whether a partition is flashed or
not.
- Introduce ShouldUnmapDeleteSnapshot which determines whether
unmapping / deleteting a snapshot is needed in RemoveAllSnapshots.

Test: apply OTA, flash target slot, then inspect logs
Bug: 147696014
Change-Id: I0853d1e213566af2a3401e46fac7d9586cee7aaf
Merged-In: I0853d1e213566af2a3401e46fac7d9586cee7aaf
2020-03-05 08:41:44 -08:00
Yifan Hong ae2558d900 libsnapshot: RemoveUpdateState on rollback.
If rollback is detected in ProcessUpdateState, call
RemoveUpdateState and return UpdateState::Cancelled. Now that
update_engine is reponsible for initiating the merge, it can react to
this state and clean up markers appropriately.

Test: libsnapshot_test
Test: apply OTA, manually rollback (by setting the active slot), then
  inspect /metadata/ota as well as /data/misc/update_engine/prefs.

Bug: 147696014

Change-Id: Ibfee11fb50e4f4fb7c6cf02b4921b35e77b8f5a5
Merged-In: Ibfee11fb50e4f4fb7c6cf02b4921b35e77b8f5a5
2020-03-05 08:41:44 -08:00
Yifan Hong 1d32aa1a37 libsnapshot: NeedSnapshotsInFirstStageMount don't test for IsRecovery
Init skips first stage mount entirely in recovery, so
the check is useless. Also, __ANDROID_RECOVERY__ is always
set for first stage init.

Also add logs if rollback indicator is set.

Fixes: 149956852
Test: apply OTA, manually rollback, reboot, see rollback indicator
Change-Id: Iac967baf4b51ea5ce9f6eb962a33cb7ee5819c1d
Merged-In: Iac967baf4b51ea5ce9f6eb962a33cb7ee5819c1d
2020-03-05 08:41:43 -08:00
Yifan Hong ef9e44ae78 Allow ProcessUpdateState to be paused.
Change callback type of ProcessUpdateState to bool() so that, when callback
returns false, immediately returns Merging.

Test: libsnapshot_test
Bug: 147696014

Change-Id: I9dcb8e1658b95216c0f1991e2e4c1ea2e7e7b2e5
Merged-In: I9dcb8e1658b95216c0f1991e2e4c1ea2e7e7b2e5
2020-03-05 08:41:43 -08:00
Yifan Hong f6d4e74bc6 libsnapshot: Re-expose InitiateMerge and ProcessUpdateState
These functions are used directly in update_engine now that
it is responsible for initiating the merge. update_engine has
its own message loop, so WaitForMerge / InitiateMergeAndWait
becomes useless and are deprecated.

Bug: 147696014
Test: compiles

Change-Id: Id8cb14f5f18b4893e2fc3d0d2b374a867a220e6f
Merged-In: Id8cb14f5f18b4893e2fc3d0d2b374a867a220e6f
2020-03-05 08:41:43 -08:00
Yifan Hong 83fe0a3572 libsnapshot: Add prolog to RemoveAllUpdateStates.
Add an optional prolog arg (function<bool()>) that is invoked
before snapshots are deleted and update state set to none.

This allows update_engine to delete markers before deleting snapshots
to avoid depending on the erroneous markers. Otherwise, if update_engine
delete markers after libsnapshot deletes update states, the device could
technically get into a state where update_engine thinks the update has
been applied, but snapshots are gone.

Bug: 147696014
Test: libsnapshot_test

Change-Id: I71bfc04a81ea4f94b3072558be50d2f80565113e
Merged-In: I71bfc04a81ea4f94b3072558be50d2f80565113e
2020-03-05 08:41:42 -08:00
Yifan Hong 91ffe19c4e snapshotctl don't auto-merge.
update_engine is now responsible for initiating the merge. snapshotctl
becomes a debugging tool for libsnapshot now.

Bug: 147696014
Test: libsnapshot_test

Change-Id: Ia2527a35e0c0f0789dbe5c477e174663ef406903
Merged-In: Ia2527a35e0c0f0789dbe5c477e174663ef406903
2020-03-05 08:41:42 -08:00
Alessio Balsini c6411c2d37 snapshotctl: init reports merge statistics
Enable the --report flag in init rc script to collect and send snapshot
merge statistics after OTA.

Bug: 138817833
Test: statsd_testdrive
Change-Id: Ie32a2c6d7d1671ca2b1846c6a8d33cea2ab22a4c
Signed-off-by: Alessio Balsini <balsini@google.com>
Merged-In: Ie32a2c6d7d1671ca2b1846c6a8d33cea2ab22a4c
2020-03-05 08:41:42 -08:00
Alessio Balsini 65ceecfec6 libsnapshot/test: Re-enable the failing tests
Some tests were temporarily disabled due to errors in Cuttlefish.
Now that the issues were fixed, the tests can be put back in presubmit.

Bug: 148889015
Test: vts_libsnapshot_test (Cuttlefish + Pixel 4)
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: Idcb2b7831b2183b2d734bdf8821fd34746f2beee
Merged-In: Idcb2b7831b2183b2d734bdf8821fd34746f2beee
2020-03-05 08:41:41 -08:00
TreeHugger Robot 694529d3ff Merge "Fixed a typo in the version name" into rvc-dev 2020-03-04 03:36:39 +00:00
Josh Gao 2da5520aab Merge changes Ic2af40b8,I9c8cfebe into rvc-dev
* changes:
  Reland "adb: turn CHECKs into an error + transport restart."
  Reland "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor"
2020-03-04 00:07:46 +00:00
Hridya Valsaraju 6c889bb9cb fastbootd: use FastbootDevice::GetCurrentSlot to get current slot suffix
Using FastbootDevice::GetCurrentSlot to get the current slot suffix
instead of reading the same from the device's boot control HAL
is required to account for the prior set_active commands issued via
fastbootd in the same boot.

Test: fuzzy_fastboot
--gtest_filter=Conformance.Slots:Conformance.SetActive --gtest_repeat=10
Bug: 146589281

Change-Id: I2edb0f024d93c2483659623423ef5c69c717c7af
Merged-In: I2edb0f024d93c2483659623423ef5c69c717c7af
2020-03-03 17:38:19 +00:00
Tom Cherry 2c005614f5 Merge changes from topic "libinit_test_utils-build-error" into rvc-dev
* changes:
  Stop & Resume property service when switching to bootstrap namespace
  init: handle property service callbacks asynchronously
  Refactor libinit_test_utils to not use libinit and expose its libraries
2020-03-03 16:22:28 +00:00
Tom Cherry 1c6f44b0d1 Merge "logd: don't coalesce identical log messages in the security buffer" into rvc-dev 2020-03-03 16:06:20 +00:00
Jiyong Park 3d79b37a41 Fixed a typo in the version name
Bug: 149569129
Test: m
Change-Id: I7401e8c092d4ee329fb1b5f23b7797f706b58faa
2020-03-03 16:19:07 +09:00
Josh Gao 1e18ac38da Reland "adb: turn CHECKs into an error + transport restart."
This reverts commit 2547f740ea.

Bug: http://b/134695864
Bug: http://b/133872605
Test: manually unplugged/replugged
Change-Id: Ic2af40b81354138a7842eb93aacc303885ac952e
(cherry picked from commit 7b3048446d)
2020-03-02 22:59:54 -08:00
Josh Gao d9684d5943 Reland "adb: daemon: Assign valid fd to usb_handle ep0 file descriptor"
This reverts commit ba4684c2b2.

Bug: http://b/129283234
Test: manually unplugged/replugged
Change-Id: I9c8cfebe09b2855cab986068273a835a13247b77
(cherry picked from commit bfe3dac36d)
2020-03-02 22:59:54 -08:00
Jaegeuk Kim 9e1bcc25f9 Merge "fs_mgr: remain elapsed time of fsck in prop" into rvc-dev 2020-03-03 00:37:17 +00:00
Jaegeuk Kim 34da2061d4 fs_mgr: remain elapsed time of fsck in prop
Bug: 149595111
Bug: 149844577
Bug: 138909685
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I8f11ca2680558dc54efd6788ee0dd56e5d65a356
Merged-In: I8f11ca2680558dc54efd6788ee0dd56e5d65a356
2020-03-03 00:35:04 +00:00
TreeHugger Robot 552729b9d6 Merge "fsck.f2fs: enable cache" into rvc-dev 2020-03-03 00:21:32 +00:00
Automerger Merge Worker 0f52deaf32 [automerger skipped] Allowing R and S developer GSI for DSU am: 99651b012b -s ours
am skip reason: Change-Id I6bc1e068368e64cb0bbf6ef63805444b35a1fdfb with SHA-1 a2ac846ff3 is in history

Change-Id: Ib423d80893de7cf45e231221764b1e1d99ea21bb
2020-03-02 21:30:48 +00:00
Automerger Merge Worker c4f86ac7a6 [automerger skipped] Adding new GSI public keys am: 14b8c451c4 -s ours
am skip reason: Change-Id Iaa7521ef40b94f13fe3c9c61d276678f47c60b98 with SHA-1 b697d47eb3 is in history

Change-Id: Ib97982ceb61dc853f2080ec8205e7cff7ced2b65
2020-03-02 21:30:46 +00:00
Josh Gao 9978c36754 Merge changes Ib97acc6d,I8f14004a,Id5bbfd6d,I4dfc3f52 into rvc-dev
* changes:
  adbd: add runtime-configurable logging.
  adb: don't hardcode ports in test_adb.
  adbd: add usb thread spawn logging.
  base: add CachedProperty.
2020-03-02 20:46:15 +00:00
Josh Gao bbe3385097 adbd: add runtime-configurable logging.
Add some requested logging options that can be turned on at runtime
without having to restart adbd.

Bug: http://b/141959374
Test: manual
Change-Id: Ib97acc6d199e0b91238a6758e18b7cb75f8688d9
(cherry picked from commit 52d0b67f19)
2020-03-02 12:44:54 -08:00
Josh Gao 9ddc42aa93 adb: don't hardcode ports in test_adb.
If we get unlucky and something else (or ourselves, in another thread)
beats us to listening on our hardcoded ports, we can deadlock.

Bug: http://b/149829737
Test: ./test_adb.py
Change-Id: I8f14004a6b2e77366abad6e88786ea8941629020
(cherry picked from commit e8829c6bfc)
2020-03-02 12:44:50 -08:00
David Anderson acb49fd07d Merge changes Iac986bca,I0f40b1f2 into rvc-dev
* changes:
  snapshotctl: Not necessary to link to libdm.
  libdm: Make static std::string inline for DmTargetDefaultKey.
2020-03-02 20:31:56 +00:00
Jaegeuk Kim ba446ce785 fsck.f2fs: enable cache
Bug: 149418646
Bug: 149844577
Bug: 111241572
Bug: 134988435
Change-Id: I8f5a9701442302339f7b5880133a960e89114b55
Merged-In: I8f5a9701442302339f7b5880133a960e89114b55
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2020-03-02 19:19:16 +00:00
Nikita Ioffe 352ae2d225 Stop & Resume property service when switching to bootstrap namespace
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 148236233
Bug: 149745936
Merged-In: I9d30b75f4b4177175ce086c3b6a7c0bba9a17396
Change-Id: I9d30b75f4b4177175ce086c3b6a7c0bba9a17396
(cherry picked from commit 6963f81a2b)
2020-03-02 11:09:42 -08:00
Tom Cherry d2dab830d3 init: handle property service callbacks asynchronously
A previous change moved property_service into its own thread, since
there was otherwise a deadlock whenever a process called by init would
try to set a property.  This new thread, however, would send a message
via a blocking socket to init for each property that it received,
since init may need to take action depending on which property it is.
Unfortunately, this means that the deadlock is still possible, the
only difference is the socket's buffer must be filled before init deadlocks.

There are possible partial solutions here: the socket's buffer may be
increased or property_service may only send messages for the
properties that init will take action on, however all of these
solutions still lead to eventual deadlock.  The only complete solution
is to handle these messages asynchronously.

This change, therefore, adds the following:
1) A lock for instructing init to reboot
2) A lock for waiting on properties
3) A lock for queueing new properties
4) A lock for any actions with ServiceList or any Services, enforced
   through thread annotations, particularly since this code was not
   designed with the intention of being multi-threaded.

Bug: 146877356
Bug: 148236233
Test: boot
Test: kill hwservicemanager without deadlock
Merged-In: I84108e54217866205a48c45e8b59355012c32ea8
Change-Id: I84108e54217866205a48c45e8b59355012c32ea8
(cherry picked from commit 7205c62933)
2020-03-02 11:08:50 -08:00
Tom Cherry eb04526a1e Refactor libinit_test_utils to not use libinit and expose its libraries
Users of libinit_test_utils must include all libraries that it uses.
If it uses libinit, then there is a large number of libraries that
must be included.  To avoid this, make libinit_test_utils only use
init_common_sources and the small number of required libraries that go
along with those sources.  Additionally, expose these sources as a
default for users of libinit_test_utils.

Bug: 148236233
Test: build
Merged-In: I224fa7e0590d073e4cd40412b5dcb6f72a64b6bf
Change-Id: I224fa7e0590d073e4cd40412b5dcb6f72a64b6bf
(cherry picked from commit a2f9136b2c)
2020-03-02 11:08:26 -08:00
Nikita Ioffe efab99063d Merge "Reset post_data_ and services_update_finished_ on userspace reboot" into rvc-dev 2020-03-02 18:01:54 +00:00
Tom Cherry 1405f22b32 Merge "Revert "liblog: disable header_abi_checker"" into rvc-dev 2020-03-02 17:56:59 +00:00
Tom Cherry d5d2c6a4fa Revert "liblog: disable header_abi_checker"
All planned changes to liblog have been made, so it's time to
re-enable this.

This reverts commit 896fb9e57a.

Bug: 150608248
Test: build
(cherry picked from commit cfcf684c83)
Merged-In: I93553da6207976c83091f21936b0ecdd31e82848
Change-Id: I93553da6207976c83091f21936b0ecdd31e82848
2020-03-02 17:56:23 +00:00
Tom Cherry 9fb0c55c24 Merge "logwrap: add missing O_CLOEXEC" into rvc-dev 2020-03-02 16:49:56 +00:00
Nikita Ioffe 284d0cf746 Reset post_data_ and services_update_finished_ on userspace reboot
Test: adb reboot userspace
Bug: 143970043
Change-Id: I77d47a8460b1526337a318547a59141334e11cdd
Merged-In: I77d47a8460b1526337a318547a59141334e11cdd
(cherry picked from commit 3ad292025c)
2020-02-29 13:18:39 +00:00
David Anderson c4bf521d09 snapshotctl: Not necessary to link to libdm.
The symbols are provided by libfs_mgr_binder.

Bug: 149942628
Test: snapshotctl builds
Merged-In: Ie4313c7add5c71bb9614a4d97eec41329425f23d
Change-Id: Iac986bcaaf4a8738b2938c6f95569eb8f5154805
2020-02-28 22:00:11 -08:00
David Anderson e4f24b6d9d libdm: Make static std::string inline for DmTargetDefaultKey.
Bug: 149942628
Test: snapshotctl w/ ASAN build
Change-Id: I0f40b1f29e46bc9afaf19d8c21d62280e2c01074
Merged-In: I0f40b1f29e46bc9afaf19d8c21d62280e2c01074
2020-02-28 22:00:05 -08:00
Josh Gao f6b7731868 adbd: add usb thread spawn logging.
Bug: http://b/141959374
Test: adbd shell killall adbd; adb wait-for-device logcat | grep UsbFfs
Change-Id: Id5bbfd6d2198005bf10b94c691499059e130afe7
(cherry picked from commit e3d34e1f8b)
2020-02-28 15:20:29 -08:00
Josh Gao b7814e8c32 base: add CachedProperty.
Copy bionic's CachedProperty with some minor API tweaks, to allow for
efficient querying of properties that rarely change.

Bug: http://b/141959374
Test: treehugger
Change-Id: I4dfc3f527d30262b35e871d256cec69e69f2e1d7
(cherry picked from commit 891e6dad73)
2020-02-28 15:20:29 -08:00
Joshua Duong caca3a9f5a Remove pairing_auth, pairing_connection from recovery.
Also remove statically linking libc++, because these libraries are not
exported native shared libraries.

We are slightly over the 12MB limit for ramdisk recovery size, so let's
remove the adb pairing libraries, since they won't be used in recovery
mode.

These are only used in normal boot mode, and currently, only by adb
client. The pairing server is used by system server.

Bug: 150317254

Test: Check size of ramdisk-recovery.img in walleye, walleye-hwasam
build to be under 12MB. Also verify installed-files-recovery.txt no
longer contains libadb_pairing*.
Also put phone into recovery mode, check system/lib64 for no
libadb_pairing*.

Change-Id: Ida7c4fdc9dda2b09091b853feac8df8f125e4274
(cherry picked from commit afc2cf0dec)
Exempt-From-Owner-Approval: cherry-pick
2020-02-28 19:02:28 +00:00
Tom Cherry 784a099d62 logd: don't coalesce identical log messages in the security buffer
This buffer isn't human readable and the parsers aren't set up to
handle the 'chatty' message for identical log messages.  Further, it
is a low volume buffer so there's not much in terms of memory saving
if this were enabled.

Bug: 137093665
Test: security unit tests
Change-Id: I03fce518d3308a6d9240bd29e83ff3237203fe3b
Merged-In: I03fce518d3308a6d9240bd29e83ff3237203fe3b
(cherry picked from commit 2ac86de15a)
2020-02-28 10:28:39 -08:00
Nikita Ioffe dffbb4f148 If userspace reboot watchdog triggers, don't store reason in persistent property
If init is wedged, then the write will never succeed and reboot won't
happen.

Also, in case of normal reboot, move call to PersistRebootReason to the
top of DoReboot() function, to make sure we persist it even if /data is
not mounted.

Test: builds
Test: adb shell svc power reboot userspace
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 148767783
Change-Id: I4ae40e1f6fdc41cc0bcae57020fa3d3385dda1b4
Merged-In: I4ae40e1f6fdc41cc0bcae57020fa3d3385dda1b4
2020-02-28 11:40:10 +00:00
TreeHugger Robot c7177f4a55 Merge "Make libstatssocket a shared_lib" into rvc-dev 2020-02-28 08:55:59 +00:00
TreeHugger Robot 21302df932 Merge "Mark fs-verity support for ext4 userdata if first_api_level >= R" into rvc-dev 2020-02-27 22:44:41 +00:00
Tej Singh d78f4dab02 Make libstatssocket a shared_lib
Make libstatssocket unable to be linked as a static lib on the platform.

Test: bit libstatssocket_test:*
Test: bit statsd_test:*
Test: atest LibStatsPullTests
Bug: 149340100

Change-Id: I5889dd718536f5f2c693b4c2e7331c9cc2eb2ac9
2020-02-27 11:37:33 -08:00
Victor Hsieh 4674b5593a Mark fs-verity support for ext4 userdata if first_api_level >= R
fs-verity is required for new devices launched with R. This change
remove a manual setup for vendors going forward. The original fs mgr
flag still allows old devices to opt in, which can only to be done
manually because of kernel dependency.

Test: build
Bug: 150034150
Change-Id: I152b63d7889153d41f29677f72074afb1881b65d
Merged-In: I152b63d7889153d41f29677f72074afb1881b65d
2020-02-27 09:44:43 -08:00
Tom Cherry 9f0c0c7923 logwrap: add missing O_CLOEXEC
Bug: 148236233
Bug: 150260863
Test: build
Merged-In: Ibe070d5d4f3a7ada0718f74c7cee12db7b9f920e
Change-Id: Ibe070d5d4f3a7ada0718f74c7cee12db7b9f920e
(cherry picked from commit b5b162e204)
2020-02-27 09:41:24 -08:00