Commit graph

6050 commits

Author SHA1 Message Date
David Anderson
870ec56622 Merge "Populate the dm table of the early userdata device." am: 3937b479bd am: d334e77348
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2336136

Change-Id: I65c3cb33e0988f4212cb85600fc4cdda4d946382
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-12 19:25:04 +00:00
David Anderson
d334e77348 Merge "Populate the dm table of the early userdata device." am: 3937b479bd
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2336136

Change-Id: Iabe97790ca7753d4de9c8c612e900b4e5b64238f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-12 18:54:35 +00:00
David Anderson
3937b479bd Merge "Populate the dm table of the early userdata device." 2022-12-12 18:38:05 +00:00
Martijn Coenen
fb64fa92a9 Merge "Support bind mounting volumes into other volume's mountpoint." am: 35eb1ae88a am: 1968bd5a1b am: ba9d81bfc8
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2189643

Change-Id: I3a391b569c01bb58363dc02cc8436afc0793c29f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-09 08:58:14 +00:00
Martijn Coenen
ba9d81bfc8 Merge "Support bind mounting volumes into other volume's mountpoint." am: 35eb1ae88a am: 1968bd5a1b
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2189643

Change-Id: I9712ae9dd4965ba0038b0b255294728462a2985a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-09 08:24:46 +00:00
Martijn Coenen
1968bd5a1b Merge "Support bind mounting volumes into other volume's mountpoint." am: 35eb1ae88a
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2189643

Change-Id: I3e0528ff7a114971a8b6da9cc939c3de0de9fd4f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-09 08:03:52 +00:00
Martijn Coenen
35eb1ae88a Merge "Support bind mounting volumes into other volume's mountpoint." 2022-12-09 07:42:00 +00:00
David Anderson
7b769bc5b1 Populate the dm table of the early userdata device.
DM_DEV_CREATE no longer creates sysfs nodes as of Linux kernel 5.15. It
is now necessary to DM_TABLE_LOAD as well.

Bug: 259328366
Test: userdata mounts
Change-Id: I0f88afdf95a97d44eb365e4302bbfdc7c28c0bcb
2022-12-08 16:23:45 -08:00
Martijn Coenen
73e3010a25 Support bind mounting volumes into other volume's mountpoint.
With the way the FUSE mount point are currently setup for emulated
volumes, there can be multiple paths that serve the same files on the
lower filesystem; eg

* /mnt/user/0/emulated/0/Android
* /mnt/user/10/emulated/0/Android

both refer to the same file on the lower filesystem:
* /data/media/0/Android

this is normally not a problem, because cross-user file access is not
allowed, and so the FUSE daemon won't serve files for other users.

With clone profiles this is no longer true however, as their volumes
are accessible by each other.

So, it can happen that an app running in clone profile 10 accesses
"/mnt/user/10/emulated/0/Android", which would be served by the FUSE
daemon for the user 10 filesystem.

At the same time, an app running in the owner profile 0 accesses
"mnt/user/0/emulated/0/Android", which would be served by the FUSE
daemon for the user 0 filesystem.

This can cause page cache inconsistencies, because multiple FUSE daemons
can be running on top of the same entries in the lower filesystem.

To prevent this, use bind mounts to make sure that cross-profile
accesses actually end up in the FUSE daemon to which the volume
belongs: "/mnt/user/10/emulated/0" is bind-mounted to
"/mnt/user/0/emulated/0", and vice-versa.

Bug: 228271997
Test: manual
Change-Id: Iefcbc813670628b329a1a5d408b6126b84991e09
2022-12-07 09:01:27 +00:00
Treehugger Robot
bc817a6d8e Merge "Ignore DE retrieveKey failure for non-user-0" am: 1cb65f9de5 am: c63d77bc61 am: 910acad3c3
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242642

Change-Id: I587777b8834f656a151051d9ab40c7a579a0511b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-29 04:21:46 +00:00
Treehugger Robot
910acad3c3 Merge "Ignore DE retrieveKey failure for non-user-0" am: 1cb65f9de5 am: c63d77bc61
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242642

Change-Id: I638cd7a1e85a670352054ec44308e4e3bba25ee6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-29 03:17:33 +00:00
Treehugger Robot
c63d77bc61 Merge "Ignore DE retrieveKey failure for non-user-0" am: 1cb65f9de5
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242642

Change-Id: Iecab2ad6f570e4083c1ad8dc8b432c56125befa4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-29 02:17:11 +00:00
Treehugger Robot
1cb65f9de5 Merge "Ignore DE retrieveKey failure for non-user-0" 2022-11-29 01:19:25 +00:00
liulvping
69b048507f Ignore DE retrieveKey failure for non-user-0
retrieveKey can fail in load_all_de_keys if a user
is partially removed, i.e. cases where
fscrypt_destroy_user_key() got interrupted. So just
ignore the failure, else could reboot into recovery.

Test: pm create-user foo
      pm remove-user 10
      adb reboot && check device not enter recovery

Signed-off-by: liulvping <liulvping@xiaomi.com>
Change-Id: Iba9d53a0833524d00e65d0427ab03002c5d8d509
2022-11-25 00:59:14 +00:00
Eric Biggers
2cc7babc5b Merge "Defer CE key fixations to checkpoint commit" 2022-11-14 22:16:55 +00:00
Eric Biggers
b615f3beac Defer CE key fixations to checkpoint commit
On the first boot after an upgrade, ensure that any Keystore key
deletions triggered by fscrypt_set_user_key_protection() are deferred
until the userdata filesystem checkpoint is committed, so that the
system doesn't end up in a bad state if the checkpoint is rolled back.

Test: see I77d30f9be57de7b7c4818680732331549ecb73c8
Bug: 232452368
Ignore-AOSP-First: depends on other changes in internal master
Change-Id: I59b758bc13b7a2ae270f1a6c409affe2eb61119c
2022-11-14 17:45:32 +00:00
Paul Crowley
fcaf3c7804 Merge "Fix unhandled exception when FUSE disabled" am: 20b1532b85 am: 3589e76deb am: 54654ba918
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2282933

Change-Id: I6612217a14471d995186c3b3dd9abbd66007cdf6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-09 15:11:18 +00:00
Paul Crowley
54654ba918 Merge "Fix unhandled exception when FUSE disabled" am: 20b1532b85 am: 3589e76deb
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2282933

Change-Id: I55051756a3d2821b51146951f7b06ba2931afd3f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-09 14:38:07 +00:00
Paul Crowley
3589e76deb Merge "Fix unhandled exception when FUSE disabled" am: 20b1532b85
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2282933

Change-Id: Iaceb4670a0032ac31bfe330e3f879b06fa351050
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-09 14:09:34 +00:00
Paul Crowley
20b1532b85 Merge "Fix unhandled exception when FUSE disabled" 2022-11-09 13:42:39 +00:00
Oleg Lyovin
667de184ed Fix unhandled exception when FUSE disabled
When running on kernel without FUSE, fs::directory_iterator
throws exception since /sys/fs/fuse/connections is missing.

This patch uses non-throwing fs::directory_iterator
and adds explicit error check.

Test: vold doesn't fail with FUSE disabled
Signed-off-by: Oleg Lyovin <ovlevin@sberdevices.ru>
Change-Id: I51b68363edf75033fcec3ce5623f419d5a68c991
2022-11-08 18:49:18 +03:00
Alfred Piccioni
f13b5d9aa2 Merge "Add NTFS support in vold" 2022-11-07 09:30:12 +00:00
Alfred Piccioni
28858c9b3f Add NTFS support in vold
Ignore-AOSP-First: Internal CR while awaiting security and legal review.

This CR, when paired with a functional NTFS implementation and the
corresponding SEPolicy updates, will allow NTFS USB drives to be mounted
on Android.

Bug: 254407246

Test: Extensive testing with an ADT-4 and NTFS USB drives.

Change-Id: If4197c4c588866c611cd6ba3483707d3cb0e0cf8
2022-10-28 15:43:37 +02:00
Eric Biggers
4cf16915f3 Initialize the /data encryption options only once
Cache the EncryptionOptions for /data in a static variable so that it
doesn't have to be repeatedly regenerated from the fstab.

Bug: 232452368
Bug: 251131631
Bug: 251147505
Ignore-AOSP-First: depends on other changes in internal master
Change-Id: I24b27190ed807f142b793d3cf250ec271d092f34
2022-10-26 21:24:36 +00:00
Eric Biggers
11409cbf30 Don't unconditionally sync directory in fixate_user_ce_key()
Directory syncs can be expensive, so only sync the directory in
fixate_user_ce_key() if something was actually done, i.e. if at least
one key directory was deleted or renamed.  Previously, the unconditional
sync in this function was being executed whenever the CE key was
retrieved or stored.  Note that all the syncs needed when storing the
key already happen in storeKeyAtomically(); this one was unrelated.

Bug: 232452368
Bug: 251131631
Bug: 251147505
Ignore-AOSP-First: depends on other changes in internal master
Change-Id: Ib0f2b9e27cdd11e359a1618cddc1f5480bd2fd37
2022-10-26 19:02:48 +00:00
Eric Biggers
ce50a43322 Regenerate CE key for non-system users when needed
Try to be more robust in the case where the device is rebooted during
the first boot, in between the generation and the storage of the CE key
for a user other than user 0.  This is relevant when users are created
during early boot, which Automotive devices do.

Bug: 232452368
Bug: 251213447
Ignore-AOSP-First: depends on other changes in internal master
Change-Id: Ic8f19a36c1385a71a168a330e87675433925a60f
2022-10-20 03:30:11 +00:00
Eric Biggers
733fa2913c Merge "Stop using the "stretching" file" am: b0a170136c am: 20695553e1 am: 72f359dd27
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2252876

Change-Id: Ib5e51cfb1aac6cdffe7f51446937dca7034f311a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-13 21:28:29 +00:00
Eric Biggers
72f359dd27 Merge "Stop using the "stretching" file" am: b0a170136c am: 20695553e1
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2252876

Change-Id: I99d3b6ab789c897ae888e83b5e5130f877ab3768
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-13 20:55:57 +00:00
Eric Biggers
20695553e1 Merge "Stop using the "stretching" file" am: b0a170136c
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2252876

Change-Id: Idc5c0d3e11e9091e4c83d34188d961d5531718e3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-13 20:17:14 +00:00
Eric Biggers
b0a170136c Merge "Stop using the "stretching" file" 2022-10-13 19:46:32 +00:00
Eric Biggers
f187f05110 Stop using the "stretching" file
As a small optimization and code simplification, stop reading and
writing the "stretching" file alongside each stored key.  vold never
does key stretching anymore.

There was one special case in the code where if the stretching file
existed and contained "nopassword", then the secret was ignored.
However, this didn't seem to be of any use, especially since it didn't
cause Keystore to be used, so it did *not* allow a key stored with no
secret to be read if a secret was unexpectedly provided.

Bug: 232452368
Bug: 251131631
Bug: 251147505
Change-Id: I5a7cbba7492526e51c451f222b9413d9fae6bce5
2022-10-13 04:11:27 +00:00
Eric Biggers
9544f8c7b2 Regenerate user 0's CE key when needed
Try to be more robust in the case where the device is rebooted during
the first boot, in between the generation and the storage of user 0's CE
key.  We can automatically recover from this scenario by generating a
new CE key and replacing /data/data.

This might resolve b/251213447.

Bug: 232452368
Bug: 251213447
Ignore-AOSP-First: depends on other changes in internal master
Change-Id: If0675de9167f7f855c0c0c6afe55fd1da39f5ce1
2022-10-10 18:18:15 +00:00
Eric Biggers
5467685595 Merge "Don't use a secdiscardable file for keys encrypted by SP" am: 7cc31eb7b0 am: da999d55e5 am: 1118f5fc4e
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242561

Change-Id: I1d8e6a48b4dd53d8418275d23aacf03c1f7c15f0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-10 17:55:17 +00:00
Eric Biggers
1118f5fc4e Merge "Don't use a secdiscardable file for keys encrypted by SP" am: 7cc31eb7b0 am: da999d55e5
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242561

Change-Id: Id33248ab1c5f46ae350dd73a826bb4797f0584c4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-10 17:23:42 +00:00
Eric Biggers
da999d55e5 Merge "Don't use a secdiscardable file for keys encrypted by SP" am: 7cc31eb7b0
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2242561

Change-Id: Id6c2f7797065a1bdec29996ef8433b8721bacfa7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-10 16:55:00 +00:00
Eric Biggers
7cc31eb7b0 Merge "Don't use a secdiscardable file for keys encrypted by SP" 2022-10-10 16:26:26 +00:00
Eric Biggers
08f4bdfe98 Don't use a secdiscardable file for keys encrypted by SP
Storage keys that are encrypted by the user's synthetic password don't
need to be securely deletable by vold, since secure deletion is already
implemented at a higher level: the synthetic password protectors managed
by LockSettingsService.  Therefore, remove the use of the secdiscardable
file by vold in this case to improve performance.

Bug: 232452368
Bug: 251131631
Bug: 251147505
Change-Id: I847d6cd3b289dbeb1ca2760d6e261a78c179cad0
2022-10-07 16:26:29 +00:00
Eric Biggers
0da75b7568 Merge "Make the CE key always be encrypted by the synthetic password" 2022-10-04 20:21:46 +00:00
Eric Biggers
dcf6369f1d Merge "cryptfs: Update the size of dm-crypt device according to sector size" am: 03ad91c3c2 am: c33624f8b2 am: cfa19bbb92 am: 56c8e62553 am: 17cf387bca
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2230826

Change-Id: Iebce7f4f32045013ec75e122277bee66814f81cf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 19:42:49 +00:00
Eric Biggers
17cf387bca Merge "cryptfs: Update the size of dm-crypt device according to sector size" am: 03ad91c3c2 am: c33624f8b2 am: cfa19bbb92 am: 56c8e62553
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2230826

Change-Id: I564af10985e9f957d981f9985f1c0bfe18a107d6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 18:38:39 +00:00
Eric Biggers
56c8e62553 Merge "cryptfs: Update the size of dm-crypt device according to sector size" am: 03ad91c3c2 am: c33624f8b2 am: cfa19bbb92
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2230826

Change-Id: I2e226ca8f977ca2f0297754808ebd78d2b0a1b8b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 17:56:58 +00:00
Eric Biggers
cfa19bbb92 Merge "cryptfs: Update the size of dm-crypt device according to sector size" am: 03ad91c3c2 am: c33624f8b2
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2230826

Change-Id: I29988364b1584f326b39fdabeb4b51d167758aa5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 17:27:23 +00:00
Eric Biggers
c33624f8b2 Merge "cryptfs: Update the size of dm-crypt device according to sector size" am: 03ad91c3c2
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2230826

Change-Id: I73de338c1bd35c3257a473183bf0e0cfebe179b5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 16:57:43 +00:00
Eric Biggers
03ad91c3c2 Merge "cryptfs: Update the size of dm-crypt device according to sector size" 2022-09-29 16:26:44 +00:00
Hongyu Jin
8eeb028338 cryptfs: Update the size of dm-crypt device according to sector size
The legacy method for metadata encryption on adoptable storage failed
when the size of the block device isn't a multiple of the crypto sector size.

Update the size of dm-crypt device according to sector size
before construct dm_target.

Bug: 248582018
Change-Id: I5c78889bdfedca7f7b0704500fc313d7a48d5a3b
Signed-off-by: Hongyu Jin <hongyu.jin@unisoc.com>
2022-09-28 17:44:44 +08:00
Eric Biggers
8c1659e271 Make the CE key always be encrypted by the synthetic password
When generating a CE key, don't persist it immediately with
kEmptyAuthentication.  Instead, cache it in memory and persist it later
when the secret to protect it with is given.  This is needed to make it
so that the CE key is always encrypted by the user's synthetic password
while it is stored on-disk.  See the corresponding system_server changes
for more information about this design change and its motivation.

As part of this, simplify vold's Binder interface by replacing the three
methods addUserKeyAuth(), clearUserKeyAuth(), and
fixateNewestUserKeyAuth() with a single method setUserKeyProtection().
setUserKeyProtection() handles persisting the key for a new user or
re-encrypting the default-encrypted key for an existing unsecured user.

Bug: 232452368
Ignore-AOSP-First: This depends on frameworks/base changes that can only
                   be submitted to internal master, due to conflicts.
Test: see Ia753ea21bbaca8ef7a90c03fe73b66c896b1536e
Change-Id: Id36ba8ee343ccb6de7ec892c3f600abd636f6ce5
2022-09-06 21:30:36 +00:00
Automerger Merge Worker
c954f8d8bf [automerger skipped] Merge changes from topic "am-96e5992b2dd4470eae48f4ad98b53c99" into stage-aosp-master am: 9ac39c470e -s ours am: b4a0098b68 -s ours am: 86b47687be -s ours am: af757e65cb -s ours
am skip reason: Merged-In I648a1af9e16787dfcfeefa2b2f2e4a72cac2c6a6 with SHA-1 2d30b890d2 is already in history

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

Change-Id: I59c62e854707afe4020522a45f497454fe0017bc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-17 16:01:40 +00:00
Xin Li
9cf39025cd [automerger skipped] Merge "DO NOT MERGE - Merge Android 13" am: 3f658163ee -s ours am: 54f0f20543 -s ours am: 597549b42f -s ours am: 2a7108b74d -s ours am: 0a83c797d7 -s ours
am skip reason: subject contains skip directive

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

Change-Id: I1b924482e93f0db06151cd2b37ed798fc481e2a0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-17 16:01:15 +00:00
Xin Li
c636dab2a1 [automerger skipped] Merge "DO NOT MERGE - Merge Android 13" am: 3f658163ee -s ours am: e23109dbf7 -s ours am: dadfcc26b9 -s ours am: 3fae96b70b -s ours am: 09f73b0583 -s ours
am skip reason: subject contains skip directive

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

Change-Id: I05cee8fb3298ba3034e0828d6f3dcb4520a926e9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-17 15:44:41 +00:00
Xin Li
f12d28a5ba [automerger skipped] DO NOT MERGE - Merge Android 13 am: 302f60e5f3 -s ours am: 24dc4748aa -s ours am: 1919d625b8 -s ours am: 169df91cca -s ours am: 0bf71b45f0 -s ours
am skip reason: subject contains skip directive

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

Change-Id: Ie7bd4882a3767b95f86aaf0d2b826b6e8fe813d5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-17 15:44:17 +00:00