Commit graph

4976 commits

Author SHA1 Message Date
Treehugger Robot
827dfe6e75 Merge "cryptfs: try harder to unmount subdirectory mounts" 2021-06-08 19:39:12 +00:00
Eric Biggers
8953430064 cryptfs: try harder to unmount subdirectory mounts
ensure_subdirectory_unmounted() was ignoring the return value from
umount(), so it wasn't possible to tell whether it succeeded or failed.
Make it log an error message on failure.

Also, there might be cases where ensure_subdirectory_unmounted() fails
initially but would succeed later, e.g. due to files in a subdirectory
mount being open and requiring processes to be killed.  To make this
more robust, keep calling ensure_subdirectory_unmounted() before each
attempt of umount("/data").

I'm not sure whether this will actually fix bug 189250652, as it hasn't
been root-caused yet, but this might help.

Bug: 189250652
Change-Id: I979b12d3c6a88fe3335ff548b1f8a5db43683c4f
2021-06-07 12:45:54 -07:00
Eric Biggers
67db7b9786 Merge "Remove /data/misc/vold/user_keys/ce/${user_id} when no longer needed" 2021-06-01 17:07:31 +00:00
Eric Biggers
d863b2cd4a Remove /data/misc/vold/user_keys/ce/${user_id} when no longer needed
When a user is removed, vold is deleting the subdirectories of
/data/misc/vold/user_keys/ce/${user_id} but not that directory itself.
This is unexpected, as none of the user's directories should be left
around.  Delete it too.

Bug: 188702840
Test: pm create-user foo
      pm remove-user 10
      stat /data/misc/vold/user_keys/ce/10 # no longer exists
Change-Id: Id4033a668fa6de1debb9ba6fdd1351c940bd35fc
2021-05-27 17:34:19 -07:00
Wale Ogunwale
c7df297a9d Revert "Change mounting storage data and obb flag to on by default" am: 6cc9a1d3dd
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/vold/+/14536506

Change-Id: I788cc3e244516d066400f489490b3411bad83872
2021-05-14 13:41:44 +00:00
Wale Ogunwale
6cc9a1d3dd Revert "Change mounting storage data and obb flag to on by default"
Revert "Change mounting storage data and obb flag to on by default"

Revert "Remove storage app data isolation checking in CTS"

Revert submission 14325408-enable_storage_iso_2

Reason for revert: b/187939590
Reverted Changes:
I6391b7381:Change mounting storage data and obb flag to on by...
Ic2f3d1be2:Remove storage app data isolation checking in CTS
Iffa8339b1:Change mounting storage data and obb flag to on by...

Bug: 187939590
Bug: 148049767
Change-Id: I8ef3e6fe0210bdf58e1292605ac1cc33a2eaafea
2021-05-14 10:31:12 +00:00
Satya Tangirala
ca14dff337 Merge "Fix bug with deferred commits for key upgrades in temporary directories" am: 54ebfb5806 am: 38c07b96a1 am: a387eda4d4 am: a1837ca9fe
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1706645

Change-Id: Ib58f5ff7a09d6a9c9a1008c05fc7d7df5d736a5b
2021-05-13 23:14:40 +00:00
Satya Tangirala
a1837ca9fe Merge "Fix bug with deferred commits for key upgrades in temporary directories" am: 54ebfb5806 am: 38c07b96a1 am: a387eda4d4
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1706645

Change-Id: I25a94c70abac50c65c1d04215bd58995e73f72ff
2021-05-13 22:58:51 +00:00
Satya Tangirala
a387eda4d4 Merge "Fix bug with deferred commits for key upgrades in temporary directories" am: 54ebfb5806 am: 38c07b96a1
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1706645

Change-Id: If03725290c7a6307255212471d682933360d2d9c
2021-05-13 22:42:09 +00:00
Satya Tangirala
38c07b96a1 Merge "Fix bug with deferred commits for key upgrades in temporary directories" am: 54ebfb5806
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1706645

Change-Id: I441e7684b9e35d168ef034456311e95c01e8b18b
2021-05-13 22:26:53 +00:00
Satya Tangirala
54ebfb5806 Merge "Fix bug with deferred commits for key upgrades in temporary directories" 2021-05-13 21:59:41 +00:00
Satya Tangirala
9475b11a1e Fix bug with deferred commits for key upgrades in temporary directories
storeKeyAtomically() stores keys in a temp directory before renaming
that directory to the real target directory. However when the key is
stored in the temporary directory, the Keymaster storage key might get
upgraded, and it's possible that the temp directory is scheduled for a
deferred commit. storeKeyAtomically() renames that temp directory, but
doesn't update the list of directories marked for deferred commit.

This patch fixes this by removing the temp directory from the list and
adding the real target directory to that list instead.

This bug was found when trying to switch from using the guest keymint to
using the host remote keymint implementation on cuttlefish
(aosp/1701925).  The device triggers this bug (and boots to recovery)
when aosp/1701925 is cherry-picked.

Co-Developed-By: Eric Biggers <ebiggers@google.com>
Test: Cuttlefish boots with and without aosp/1701925
Change-Id: I3b6fd6ad32ed415da94423cca6f5a121c16472f2
2021-05-13 11:21:23 -07:00
Satya Tangirala
ff906f994d Merge changes from topic "vold-keystore2-fixes" am: 98692ab9bb am: 545a13a568 am: 041bbff0bb am: 6c0c4e8f94
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1705226

Change-Id: I7847aee550538de11bd755d2783ecc517e4e2f6d
2021-05-12 23:54:30 +00:00
Satya Tangirala
6c0c4e8f94 Merge changes from topic "vold-keystore2-fixes" am: 98692ab9bb am: 545a13a568 am: 041bbff0bb
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1705226

Change-Id: I160caec0094cf97c65cab0309d50c034016e0204
2021-05-12 23:31:40 +00:00
Satya Tangirala
041bbff0bb Merge changes from topic "vold-keystore2-fixes" am: 98692ab9bb am: 545a13a568
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1705226

Change-Id: I5506a4ed4c7105d6102277b6fb659c3e39312197
2021-05-12 23:07:33 +00:00
Satya Tangirala
545a13a568 Merge changes from topic "vold-keystore2-fixes" am: 98692ab9bb
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1705226

Change-Id: I310d09e283e3d8804ba7154295d9b004e95cda98
2021-05-12 22:52:36 +00:00
Satya Tangirala
98692ab9bb Merge changes from topic "vold-keystore2-fixes"
* changes:
  Remove unused constants and cleanup KeyStorage.cpp
  Remove unused parameter "salt" from stretchSecret()
  Use AServiceManager_waitForService() to connect to keystore2
2021-05-12 22:32:32 +00:00
Satya Tangirala
6b98fb6122 Remove unused constants and cleanup KeyStorage.cpp
Now that the salt and hardware auth token related code has been removed,
we can remove the associated (and now unused) constants.

Also cleanup some comments and remove includes related to hardware auth
token support.

Bug: 181910578
Test: Cuttlefish boots.
Change-Id: I3733d5c6bbf6989adc165c554ee53faa2484f4b6
2021-05-12 13:05:35 -07:00
Satya Tangirala
478cea9783 Remove unused parameter "salt" from stretchSecret()
stretchSecret() no longer uses the "salt" parameter, so remove it and
simplify callers

Bug: 181910578
Test: Cuttlefish boots.
Change-Id: Ic2d0742b22b98a66da37f435e274c9d385b8e188
2021-05-12 13:05:35 -07:00
Satya Tangirala
6ef4e37351 Use AServiceManager_waitForService() to connect to keystore2
Vold currently uses AServiceManager_getService() to connect to
keystore2, which has an internal timeout of 5s. Since a lot of vold
keystore2 connection failures are fatal, we instead use
AServiceManager_waitForService(), which will wait efficiently for
keystore2 to start, instead of timing out after 5s.

Bug: 185934601
Test: Cuttlefish boots.
Change-Id: Ib4e977a997e020082382e0686f448d1aa72834ec
2021-05-11 19:30:30 -07:00
Songchun Fan
38969cfc6c Merge "[vold] pass along sysfs name in setOptions" into sc-dev am: 29a6d6bb46
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/vold/+/14490318

Change-Id: If3c7d07bf8b365eb3f847f65442dbaab5f67c50d
2021-05-11 22:41:16 +00:00
Songchun Fan
29a6d6bb46 Merge "[vold] pass along sysfs name in setOptions" into sc-dev 2021-05-11 22:36:55 +00:00
Treehugger Robot
791faea201 Merge "Show names of processes killed by KillProcessesWithOpenFiles()" am: 93dd933d85 am: 274804863c am: c591e3d68f am: 85a78a5ad1
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1697789

Change-Id: Iaea1920deace15c05a41d06cf3cc195eb32c3a5e
2021-05-11 21:18:05 +00:00
Eric Biggers
7b80629c84 Merge "cryptfs: kill processes more quickly in wait_and_unmount()" am: 297b23837e am: 03e021ba56 am: 9d7718cf05 am: 1e0cdac620
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1702389

Change-Id: I3c73357c29bc6f598bd15b36b3af59f12edaf38e
2021-05-11 21:17:55 +00:00
Treehugger Robot
85a78a5ad1 Merge "Show names of processes killed by KillProcessesWithOpenFiles()" am: 93dd933d85 am: 274804863c am: c591e3d68f
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1697789

Change-Id: I80cf3cf6b9d4e5e7f0ac32b0230cd9b6418cd047
2021-05-11 21:04:06 +00:00
Eric Biggers
1e0cdac620 Merge "cryptfs: kill processes more quickly in wait_and_unmount()" am: 297b23837e am: 03e021ba56 am: 9d7718cf05
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1702389

Change-Id: Ice91b35eda0f09cbb9d4a4e500a1e9984940b0f1
2021-05-11 21:04:02 +00:00
Treehugger Robot
c591e3d68f Merge "Show names of processes killed by KillProcessesWithOpenFiles()" am: 93dd933d85 am: 274804863c
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1697789

Change-Id: I367b674134c4af229a6490c0c03bee93e3d46cdb
2021-05-11 21:02:19 +00:00
Treehugger Robot
274804863c Merge "Show names of processes killed by KillProcessesWithOpenFiles()" am: 93dd933d85
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1697789

Change-Id: Ifc538a3c7cee0df30b727b08333f2e037011656d
2021-05-11 20:39:27 +00:00
Eric Biggers
9d7718cf05 Merge "cryptfs: kill processes more quickly in wait_and_unmount()" am: 297b23837e am: 03e021ba56
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1702389

Change-Id: I56fa2f1b0a434c15e846319774028c435b905671
2021-05-11 20:32:28 +00:00
Treehugger Robot
93dd933d85 Merge "Show names of processes killed by KillProcessesWithOpenFiles()" 2021-05-11 20:24:49 +00:00
Eric Biggers
03e021ba56 Merge "cryptfs: kill processes more quickly in wait_and_unmount()" am: 297b23837e
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1702389

Change-Id: I48bdc416c72646af7a6f87bad78e0b759e9f1080
2021-05-11 20:17:12 +00:00
Eric Biggers
297b23837e Merge "cryptfs: kill processes more quickly in wait_and_unmount()" 2021-05-11 20:00:14 +00:00
Eric Biggers
b4faeb8d44 cryptfs: kill processes more quickly in wait_and_unmount()
In wait_and_unmount(), kill the processes with open files after umount()
has been failing for 2 seconds rather than 17 seconds.  This avoids a
long boot delay on devices that use FDE.

Detailed explanation:

On FDE devices, vold needs to unmount the tmpfs /data in order to mount
the real, decrypted /data.  On first boot, it also needs to unmount the
unencrypted /data in order to encrypt it in-place.

/data can't be unmounted if files are open inside it.  In theory, init
is responsible for killing all processes with open files in /data, via
the property trigger "vold.decrypt=trigger_shutdown_framework".

However, years ago, commit 6e8440fd50 ("cryptfs: kill processes with
open files on tmpfs /data") added a fallback where vold kills the
processes itself.  Since then, in practice people have increasingly been
relying on this fallback, as services keep being added that use /data
but don't get stopped by trigger_shutdown_framework.

This is slowing down boot, as vold sleeps for 17 seconds before it
actually kills the processes.

The problematic services include services that are now started
explicitly in the post-fs-data trigger rather than implicitly as part of
a class (e.g., tombstoned), as well as services that now need to be
started as part of one of the early-boot classes like core or early_hal
but can still open files in /data later (e.g. keystore2 and credstore).

Another complication is that on default-encrypted devices (devices with
no PIN/pattern/password), trigger_shutdown_framework isn't run at all,
but rather it's expected that the relevant services simply weren't
started yet.  This means that we can't fix the problem just by fixing
trigger_shutdown_framework to kill all the needed processes.

Therefore, given that the vold fallback is being relied on in practice,
and FDE won't be supported much longer anyway (so simple fixes are very
much preferable here), let's just change wait_and_unmount() in vold to
use more appropriate timeouts.  Instead of waiting for 17 seconds before
killing processes, just wait for 2 seconds.  Keep the total timeout of
20 seconds, but spend most of it retrying killing the processes, and
only if the unmount is still failing.

This avoids the long boot delays in practice.

Bug: 187231646
Bug: 186165644
Test: Tested FDE on Cuttlefish, and checked logcat to verify that the
      boot delay is gone.
Change-Id: Id06a9615a87988c8336396c49ee914b35f8d585b
2021-05-10 20:44:07 -07:00
Songchun Fan
0e53c1cdb0 [vold] pass along sysfs name in setOptions
Ignore-AOSP-First: Will cherry-pick to AOSP

BUG: 187308584
Test: atest CtsContentTestCases:android.content.pm.cts.PackageManagerShellCommandIncrementalTest#testInstallWithIdSigNoMissingPages
Change-Id: Iacfe6b735458051f2848b1b766c2b00198b397d9
2021-05-10 16:22:40 -07:00
Eric Biggers
c78ae60087 Show names of processes killed by KillProcessesWithOpenFiles()
Otherwise only the pids are shown, and it's hard to tell which
processes actually got killed.

Bug: 187231646
Change-Id: Icccf60d0ad4439d702f36ace31abe092df1c69c2
2021-05-10 17:34:11 +00:00
Xin Li
9eb4ac8427 [automerger skipped] Merge "DO NOT MERGE - Mark RQ2A.210105.001 as merged." am: ef439c5367 -s ours am: 477eb9ac9c -s ours am: 4e3d21ca95 -s ours am: 0ae5274090 -s ours
am skip reason: Merged-In Ic37985f98e6cbfe4fa38b981d3332c4dfc40c5b8 with SHA-1 5f2a9fee66 is already in history

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1699301

Change-Id: I498383258dd4de3f5b632ea0768c19e6e7863f9c
2021-05-08 03:04:10 +00:00
Xin Li
0ae5274090 [automerger skipped] Merge "DO NOT MERGE - Mark RQ2A.210105.001 as merged." am: ef439c5367 -s ours am: 477eb9ac9c -s ours am: 4e3d21ca95 -s ours
am skip reason: subject contains skip directive

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1699301

Change-Id: I4e3c7fc2fad871976660fa73053cfc3e5d8ea041
2021-05-08 02:37:01 +00:00
Xin Li
4e3d21ca95 [automerger skipped] Merge "DO NOT MERGE - Mark RQ2A.210105.001 as merged." am: ef439c5367 -s ours am: 477eb9ac9c -s ours
am skip reason: Merged-In Ic37985f98e6cbfe4fa38b981d3332c4dfc40c5b8 with SHA-1 5f2a9fee66 is already in history

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1699301

Change-Id: Ifbb2163da12fde662e0f36a992feb1991ef8e37c
2021-05-08 02:13:44 +00:00
Xin Li
477eb9ac9c [automerger skipped] Merge "DO NOT MERGE - Mark RQ2A.210105.001 as merged." am: ef439c5367 -s ours
am skip reason: Merged-In Ic37985f98e6cbfe4fa38b981d3332c4dfc40c5b8 with SHA-1 5f2a9fee66 is already in history

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1699301

Change-Id: Icb4c65c9d0b4e9f1dfefb9d7bdf3e68a799e7fa2
2021-05-08 01:48:49 +00:00
Xin Li
ef439c5367 Merge "DO NOT MERGE - Mark RQ2A.210105.001 as merged." 2021-05-08 01:28:13 +00:00
Xin Li
140116266e DO NOT MERGE - Mark RQ2A.210105.001 as merged.
Bug: 180401296
Merged-In: Ic37985f98e6cbfe4fa38b981d3332c4dfc40c5b8
Change-Id: Ic82b58f8975ae7b5410d87536342f83e827a7893
2021-05-07 14:32:31 -07:00
rickywai
7a3113c385 Merge "Always unmount data and obb directory that mounted" am: ae11ab712f am: 270b1dabbc am: 61ae848c4d am: 2645038034
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1697365

Change-Id: I00da114099a854a70765aa8822507163f31b9f55
2021-05-06 09:25:13 +00:00
rickywai
2645038034 Merge "Always unmount data and obb directory that mounted" am: ae11ab712f am: 270b1dabbc am: 61ae848c4d
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1697365

Change-Id: Ief7e515c3e4ebe52fc9dbcfc781bbcd66c020f80
2021-05-06 09:11:49 +00:00
rickywai
61ae848c4d Merge "Always unmount data and obb directory that mounted" am: ae11ab712f am: 270b1dabbc
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1697365

Change-Id: I3d068df59d9ba0786437a32f1750d271f142581d
2021-05-06 08:40:40 +00:00
rickywai
270b1dabbc Merge "Always unmount data and obb directory that mounted" am: ae11ab712f
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1697365

Change-Id: I44aaffd7ecd95ec60af7559592d684460b32c5da
2021-05-06 08:25:13 +00:00
rickywai
ae11ab712f Merge "Always unmount data and obb directory that mounted" 2021-05-06 08:09:05 +00:00
Alan Stokes
1446f6fb32 [automerger skipped] Merge "Only kill apps with storage app data isolation enabled" am: b2678b6654 am: 53d7796ccd am: dedb2c1a13 -s ours am: d24f5a26e8 -s ours
am skip reason: Merged-In I45d9a63ed47cbc27aebb63357a43f51ad62275db with SHA-1 a58b535495 is already in history

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1690874

Change-Id: Iee959b054ab7d6104e0d3713347e57c301ba7976
2021-05-05 15:26:57 +00:00
Alan Stokes
d24f5a26e8 [automerger skipped] Merge "Only kill apps with storage app data isolation enabled" am: b2678b6654 am: 53d7796ccd am: dedb2c1a13 -s ours
am skip reason: Merged-In I45d9a63ed47cbc27aebb63357a43f51ad62275db with SHA-1 a58b535495 is already in history

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1690874

Change-Id: I641a83e69e7b3ffc267997503cc741cb8a04f030
2021-05-05 15:04:04 +00:00
Alan Stokes
dedb2c1a13 Merge "Only kill apps with storage app data isolation enabled" am: b2678b6654 am: 53d7796ccd
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1690874

Change-Id: I807f10f18d56c8ff1ef36f6b5cad85f2ee911184
2021-05-05 14:45:44 +00:00
Ricky Wai
5f2a9fee66 Always unmount data and obb directory that mounted
Otherwise, when system removes user's volume, it will hang
as there are mounts (obb and data mounts) still remain mounted in system.

Bug: 187122943
Test: atest UserLifecycleTests#managedProfileUnlock_stopped, it's not blocked anymore

Change-Id: Ic37985f98e6cbfe4fa38b981d3332c4dfc40c5b8
2021-05-05 14:44:16 +00:00