OSDN Git Service

android-x86/system-vold.git
4 years agoMerge "Choose options format using property" into rvc-dev
TreeHugger Robot [Wed, 8 Apr 2020 00:10:59 +0000 (00:10 +0000)]
Merge "Choose options format using property" into rvc-dev

4 years agoChoose options format using property
Paul Crowley [Sun, 22 Mar 2020 15:02:06 +0000 (08:02 -0700)]
Choose options format using property

To make it easier to support disk formats created using old versions
of dm-default-key with new kernels, choose the disk format to use
based on options_format_version and first_api_version properties
instead of checking the version number of the kernel module.

Bug: 150761030
Test: crosshatch and cuttlefish boot normally; cuttlefish
    fails with "default-key: Not enough arguments" as expected when
    option is set to 1
Cherry-Picked-From: f56d553babc368e557fe90513e78a5ba06626b0d
Merged-In: Ib51071b7c316ce074de72439741087b18335048c
Change-Id: Ib51071b7c316ce074de72439741087b18335048c

4 years agoAdditional operation check when enabling read logs.
Alex Buynytskyy [Thu, 2 Apr 2020 22:21:47 +0000 (15:21 -0700)]
Additional operation check when enabling read logs.

Vold now does not check caller's permission, but only accepts
transactions from system_server. And it's up to system server to do the
right thing and check permissions/appops.

Bug: b/152633648
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest
Test: adb shell appops set 1000 GET_USAGE_STATS deny
Change-Id: Id56c1673b135b72b3ec86e572aa4bcca3afc19ab

4 years agoReplace EnsureDirExists with a call to setupAppDir
Linus Tufvesson [Mon, 23 Mar 2020 11:59:43 +0000 (11:59 +0000)]
Replace EnsureDirExists with a call to setupAppDir

Test: Manually verified ownership of /storage/emulated/0/Android/data on cf_x86_phone-userdebug after enabling feature
Bug: 151455752

Change-Id: I75a1e3b769476e56094e41d82e7f8e1a72827ded

4 years agoMerge "Checking LOADER_USAGE_STATS before enabling read logs." into rvc-dev
Alex Buynytskyy [Thu, 2 Apr 2020 00:36:26 +0000 (00:36 +0000)]
Merge "Checking LOADER_USAGE_STATS before enabling read logs." into rvc-dev

4 years agoMerge "Send earlyBootEnded notice to all Keymasters" into rvc-dev
TreeHugger Robot [Wed, 1 Apr 2020 22:31:35 +0000 (22:31 +0000)]
Merge "Send earlyBootEnded notice to all Keymasters" into rvc-dev

4 years agoSend earlyBootEnded notice to all Keymasters
Shawn Willden [Wed, 1 Apr 2020 16:02:16 +0000 (10:02 -0600)]
Send earlyBootEnded notice to all Keymasters

Vold incorrectly sends the earlyBootEnded signal only to the Keymaster
instance used for device encryption, but all of them need it.

Bug: 152932559
Test: VtsHalKeymasterV4_1TargetTest
Change-Id: Id8f01a1dc7d2398395f369c3ea74656a82888829

4 years agoChecking LOADER_USAGE_STATS before enabling read logs.
Alex Buynytskyy [Tue, 31 Mar 2020 21:46:25 +0000 (14:46 -0700)]
Checking LOADER_USAGE_STATS before enabling read logs.

Bug: b/152633648
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest
Change-Id: I29bf16d06a013566c8dd08e64be2a23ad805e37d

4 years agoMerge "Prefer f2fs for virtual (private) storage volumes." into rvc-dev
TreeHugger Robot [Tue, 31 Mar 2020 11:00:31 +0000 (11:00 +0000)]
Merge "Prefer f2fs for virtual (private) storage volumes." into rvc-dev

4 years ago[automerger skipped] Block and wait for /dev/block/loop<N> to appear in case it was...
David Anderson [Mon, 30 Mar 2020 09:00:04 +0000 (09:00 +0000)]
[automerger skipped] Block and wait for /dev/block/loop<N> to appear in case it was created asynchronously. am: 5ba8aeaa80 -s ours

am skip reason: Change-Id Id8616804bba622226ca21b8eff0d3eb577b4b7e0 with SHA-1 1dd5c4f787 is in history

Change-Id: Iaffd50d7b736066cfa429edf28b3f18fb956715d

4 years ago[vold] update with incfs_ndk.h
Songchun Fan [Wed, 4 Mar 2020 01:58:20 +0000 (17:58 -0800)]
[vold] update with incfs_ndk.h

BUG: 150470163
Test: atest PackageManagerShellCommandIncrementalTest
Change-Id: I5166c49cf48f353dab35e385571ada517cb751ac

4 years agoBlock and wait for /dev/block/loop<N> to appear in case it was created asynchronously.
David Anderson [Tue, 11 Jun 2019 21:51:25 +0000 (14:51 -0700)]
Block and wait for /dev/block/loop<N> to appear in case it was created asynchronously.

Bug: 134711825
Bug: 149462396
Test: StorageManagerTest
Change-Id: Id8616804bba622226ca21b8eff0d3eb577b4b7e0
Merged-In: Id8616804bba622226ca21b8eff0d3eb577b4b7e0

4 years ago[vold] Add argument verification to IncFS methods
Yurii Zubrytskyi [Wed, 25 Mar 2020 06:49:02 +0000 (23:49 -0700)]
[vold] Add argument verification to IncFS methods

+ Get rid of an extra string copy in path validation function

Bug: 152349257
Test: atest vold_tests
Change-Id: I03a8cab0dd6abd7d5c9dcbbc2acb651e818e6cd8

4 years agoMerge "Bind mount Android/data and Android/obb individually." into rvc-dev
Martijn Coenen [Tue, 24 Mar 2020 08:31:44 +0000 (08:31 +0000)]
Merge "Bind mount Android/data and Android/obb individually." into rvc-dev

4 years agoMerge "Add quota / casefold options to f2fs if needed." into rvc-dev
TreeHugger Robot [Fri, 20 Mar 2020 14:35:07 +0000 (14:35 +0000)]
Merge "Add quota / casefold options to f2fs if needed." into rvc-dev

4 years agoBind mount Android/data and Android/obb individually.
Martijn Coenen [Mon, 16 Mar 2020 13:37:33 +0000 (14:37 +0100)]
Bind mount Android/data and Android/obb individually.

Because we want all other paths (in particular Android/media) to go
through FUSE.

Also use scope_guard to make unwinding some failures easier.

Bug: 151272568
Test: atest AdoptableHostTest
Change-Id: Ib487b9071b5b212c7bb12ce54f80c96d98acaef5

4 years agoFix vold wedge when unmounting Android/
Zim [Tue, 17 Mar 2020 15:15:42 +0000 (15:15 +0000)]
Fix vold wedge when unmounting Android/

In EmulatedVolume#doMount, if some operations fail, we call
EmulatedVolume#doUnmount.

During this unmount we try to unmount Android/ causing a FUSE_LOOKUP
on the FUSE mount. If the FUSE mount is not up, this can hang.

Now we introduce a new state to prevent unmounting Android/ if it
wasn't mounted.

Test: atest AdoptableHostTest
Bug: 151685786
Change-Id: I6246d3910c352034d2a4fb09ad9c1e7fd91cba5e

4 years agoMake storage dirs remount fork() safe
Ricky Wai [Fri, 28 Feb 2020 16:30:47 +0000 (16:30 +0000)]
Make storage dirs remount fork() safe

Also, use the pids provided by system server to remount all existing
processes, so we don't need to do the heavy and unreliable scanning in
/proc anymore.

Bug: 149548518
Test: atest AdoptableHostTest
Change-Id: Ifb5b79a3bc5438f36e0d61ec8aec96bdbc60ca13

4 years agoPrefer f2fs for virtual (private) storage volumes.
Martijn Coenen [Wed, 11 Mar 2020 14:33:22 +0000 (15:33 +0100)]
Prefer f2fs for virtual (private) storage volumes.

Since ext4 currently doesn't have the required kernel patches in place
on cuttlefish.

Bug: 150935323
Test: sm set-virtual-disk true
      sm partition disk:7,xyz private
      inspect mount output
Change-Id: Ief5bd9ace9d39bdfbae8d3857044a2143801f6be

4 years agoAdd quota / casefold options to f2fs if needed.
Martijn Coenen [Tue, 10 Mar 2020 08:28:39 +0000 (09:28 +0100)]
Add quota / casefold options to f2fs if needed.

These were only added for ext4.

Bug: 150935323
Test: when creating a private f2fs volume, things work as expected.
Change-Id: I11ee04bfddecb6c95e223e66c9bf532c425e6fac

4 years agoMerge "Only set quota project ID inheritance on app-private dirs." into rvc-dev
TreeHugger Robot [Wed, 11 Mar 2020 12:54:58 +0000 (12:54 +0000)]
Merge "Only set quota project ID inheritance on app-private dirs." into rvc-dev

4 years agoMerge "fskeyring & userspace reboot: support CE keys" into rvc-dev
Nikita Ioffe [Wed, 11 Mar 2020 11:43:30 +0000 (11:43 +0000)]
Merge "fskeyring & userspace reboot: support CE keys" into rvc-dev

4 years agoOnly set quota project ID inheritance on app-private dirs.
Martijn Coenen [Wed, 11 Mar 2020 10:51:45 +0000 (11:51 +0100)]
Only set quota project ID inheritance on app-private dirs.

Previously every directory on external storage had project ID quota
inheritance enabled; this means that if any new file/directory is
created under such a directory, it will inherit the project ID from the
parent. We use a default project ID of 1000 for generic directories, and
application-specific project IDs for app-specific directories.

MediaProvider is responsible for updating the quota type in the generic
directories, as it scans all files there. However, there is a problem
with this approach: if you move a file to a directory with project ID
inheritance set, and the project ID of that file differs from the
project ID of the dir, that results in an EXDEV error, and requires a
copy instead. For example, if /sdcard/DCIM/test.jpg has a project ID of
1003 (for images), and you try to move it to /sdcard/Pictures/test.jpg,
that would require a copy, because the project ID of /sdcard/Pictures is
1000.

While this is not a very common scenario, it's still better to avoid it.
Luckily we can - since MediaProvider anyway scans all files, it will set
the project ID on individual files correctly - there's no need to
inherit them.

We then only need to inherit quota in application-specific directories,
since in those directories the app can create files itself, and those
need to be tagged correctly.

This change enables that, by removing quota inheritance setting from the
top-level directory, and instead doing it for app-specific directories
instead.

Bug: 151078664
Test: atest StorageHostTest
      atest com.android.tests.fused.host.FuseDaemonHostTest#testRenameAndReplaceFile
Change-Id: I38a057ec61cb627e39a3ff7ac58c7218dc251bdc

4 years agofskeyring & userspace reboot: support CE keys
Nikita Ioffe [Fri, 28 Feb 2020 19:50:31 +0000 (19:50 +0000)]
fskeyring & userspace reboot: support CE keys

During userspace reboot /data might be unmounted & remounted, meaning
that CE keys stored in fs-level keyring will be lost. In order to be
able to restore them, when installing new key to fs-level keyring, it's
also added to session-level keyring with type "fscrypt-provisioning".

Then when init_user0 is called during userspace reboot, vold will try to
load CE keys from the session-level keyring back into fs-level keyring
for all the users that were unlocked before the reboot.

If for any user vold fails to install the key, init_user0 will fail and
fallback to hard reboot will be triggered.

Test: set a pin pattern
Test: adb shell setprop sys.init.userdata_remount.force_umount 1
Test: adb shell svc power reboot userspace
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 143970043
Change-Id: I37603dc136c7ededc7b0381e4d730cb0ffd912b4

4 years agoUse the blk_device supplied by vdc encryptFstab
Paul Crowley [Mon, 2 Mar 2020 20:57:58 +0000 (12:57 -0800)]
Use the blk_device supplied by vdc encryptFstab

fs_mgr may put other dm devices on top of the raw disk, such as for
checkpointing, and it hands metadata encryption the uppermost device in
vdc. That's what should be encrypted, not the raw disk.

Bug: 150354860
Test: Treehugger
Merged-In: I279f087b1b7aded40c5a62281154851ce970ba70
Change-Id: I279f087b1b7aded40c5a62281154851ce970ba70

4 years agoMerge "umount /data/user/0 before umount /data" into rvc-dev
Hung-ying Tyan [Thu, 5 Mar 2020 00:24:34 +0000 (00:24 +0000)]
Merge "umount /data/user/0 before umount /data" into rvc-dev

4 years agoMerge "fskeyring & userspace reboot: support DE keys" into rvc-dev
Nikita Ioffe [Wed, 4 Mar 2020 12:13:55 +0000 (12:13 +0000)]
Merge "fskeyring & userspace reboot: support DE keys" into rvc-dev

4 years agoumount /data/user/0 before umount /data
Hyangseok Chae [Thu, 27 Feb 2020 09:21:50 +0000 (18:21 +0900)]
umount /data/user/0 before umount /data

FDE device has shut down and restart the framework.
But restart is not triggered due to umount fail.
umount /data fail with "device is busy"
It is because bind mount /data/data to /data/user/0

We need umount /data/user/0 before umount /data

Bug: 148004718
Test: Flash GSI and check boot with FDE and FBE device.
Change-Id: I919f9e31a9d2d745b297a7ab99b399aa9b293b39
Merged-In: I919f9e31a9d2d745b297a7ab99b399aa9b293b39
(cherry picked from commit 3cf3233bac176744d43c682b7f9244db58c3402a)

4 years agoAdd Android/data mounting along with obb mounting in vold
Ricky Wai [Thu, 20 Feb 2020 16:10:01 +0000 (16:10 +0000)]
Add Android/data mounting along with obb mounting in vold

We should mount Android/data also, not only Android/obb.

Test: After flag is enabled, AdoptableHostTest still pass.
Bug: 148049767
Bug: 150584566
Change-Id: I26dc3756aa5843b85565495e9c2698130113f49a
Merged-In: I26dc3756aa5843b85565495e9c2698130113f49a
(cherry picked from commit d88e090098d4a95112aecb135d1bcba96150bdd1)

4 years agofskeyring & userspace reboot: support DE keys
Nikita Ioffe [Thu, 27 Feb 2020 18:21:55 +0000 (18:21 +0000)]
fskeyring & userspace reboot: support DE keys

During userspace reboot /data might be unmounted, which means that if
device supports filesystem keyring, DE keys will be lost and are needed
to be re-installed.

Test: adb shell setprop sys.init.userdata_remount.force_umount 1
Test: adb shell svc power reboot userspace
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 143970043
Change-Id: I153caa1d7c373b3c906a34f1184c681e52854a9d

4 years agoMerge "Switch to new project ID constants."
Martijn Coenen [Thu, 20 Feb 2020 08:58:56 +0000 (08:58 +0000)]
Merge "Switch to new project ID constants."

4 years agoMerge "Make CTS not HEH the default post Q" am: 39969f0288 am: 17d85205bd am: f0bea38daa
Automerger Merge Worker [Thu, 20 Feb 2020 00:22:25 +0000 (00:22 +0000)]
Merge "Make CTS not HEH the default post Q" am: 39969f0288 am: 17d85205bd am: f0bea38daa

Change-Id: I3cf8f261ce7ecf41315ffddbf4964cf47bca1655

4 years agoSwitch to new project ID constants.
Martijn Coenen [Tue, 18 Feb 2020 15:29:25 +0000 (16:29 +0100)]
Switch to new project ID constants.

Use new constants, instead of reusing previous sdcardfs values.

Bug: 146419093
Test: lsattr -pR
Change-Id: I7409d86cac5360e125e843cc79f3c5f41d74dd1e

4 years agoMerge "Make CTS not HEH the default post Q" am: 39969f0288 am: 17d85205bd
Automerger Merge Worker [Wed, 19 Feb 2020 23:37:01 +0000 (23:37 +0000)]
Merge "Make CTS not HEH the default post Q" am: 39969f0288 am: 17d85205bd

Change-Id: I0c3114a77c37b30e542c45fc4d4d6ea592444b1a

4 years agoMerge "Make CTS not HEH the default post Q" am: 39969f0288
Automerger Merge Worker [Wed, 19 Feb 2020 23:20:59 +0000 (23:20 +0000)]
Merge "Make CTS not HEH the default post Q" am: 39969f0288

Change-Id: I0cb0430214ab69656c6e7f3116194b63eb54672b

4 years agoMerge "Make CTS not HEH the default post Q"
Treehugger Robot [Wed, 19 Feb 2020 23:04:37 +0000 (23:04 +0000)]
Merge "Make CTS not HEH the default post Q"

4 years agoMerge "Fix unaligned access to auth token user_id" am: 21a17b091e am: 01759662fd...
Automerger Merge Worker [Wed, 19 Feb 2020 22:20:32 +0000 (22:20 +0000)]
Merge "Fix unaligned access to auth token user_id" am: 21a17b091e am: 01759662fd am: 7b9b164946

Change-Id: Ibe10561445571d7607ea93d7a988a9ab847e234a

4 years agoMerge "Remove unused code in VoldUtil.h" am: e19189bd7f am: b6421644ec am: 923309aae2
Automerger Merge Worker [Wed, 19 Feb 2020 22:19:46 +0000 (22:19 +0000)]
Merge "Remove unused code in VoldUtil.h" am: e19189bd7f am: b6421644ec am: 923309aae2

Change-Id: I0ec249df609cbad7f80ac739545c6cf0199e6232

4 years agoMerge changes from topics "metadata_wrapped_key_aosp", "volume_metadata" am: 36fd1ebf...
Automerger Merge Worker [Wed, 19 Feb 2020 22:19:26 +0000 (22:19 +0000)]
Merge changes from topics "metadata_wrapped_key_aosp", "volume_metadata" am: 36fd1ebfae am: 6891eb7e2d am: c14f46d114

Change-Id: I89f51bfaeb61c235aeccbe8a5a5a447ab14c46cb

4 years agoMerge "Mount direct boot apps obb dir after fuse is ready."
Ricky Wai [Wed, 19 Feb 2020 19:42:13 +0000 (19:42 +0000)]
Merge "Mount direct boot apps obb dir after fuse is ready."

4 years agoMake CTS not HEH the default post Q
Paul Crowley [Tue, 18 Feb 2020 18:10:08 +0000 (10:10 -0800)]
Make CTS not HEH the default post Q

Making HEH the default was always a mistake and a giant foot-gun.
Let's make life easier for people by making the default depend on
first_api_level, so it's automatically set up right for new devices
without breaking old ones. Also use v2 fscrypt keys instead of v1 post
Q.

Bug: 147107322
Test: Various Cuttlefish configurations
Change-Id: I5432bdfd6fec6ed34e7f9ab7cdd32cdeb2a03472

4 years agoMount direct boot apps obb dir after fuse is ready.
Ricky Wai [Tue, 11 Feb 2020 14:31:24 +0000 (14:31 +0000)]
Mount direct boot apps obb dir after fuse is ready.

- Remove bind mounting Android/ code as we want to bind mount obb dir
for each process instead.
- Set property "vold.vold.fuse_running_users" as an array of user id
for which fuse is ready to use.
- After fuse is ready for a user, fork a background process in vold
to bind mount all direct boot apps for that user so its direct boot
apps obb dir will be mounted to lower fs for imporoved performance.

Bug: 148049767
Bug: 137890172
Test: After flag is enabled, AdoptableHostTest still pass.
Change-Id: I90079fbeed1c91f9780ca71e37b0012884680b7c

4 years agoAdd fixupAppDir() API.
Martijn Coenen [Tue, 18 Feb 2020 14:06:37 +0000 (15:06 +0100)]
Add fixupAppDir() API.

This can be used to fixup application directories in case they have been
created by some other entity besides vold; the main use case for this
API right now is OBB directories, which can be created by installers
outside of vold; on devices without sdcardfs, such directories and the
files contained therein are not setup correctly. This API will make sure
everything is setup the way it needs to be setup.

Bug: 146419093
Test: inspect OBB dir after install
Change-Id: I2e35b7ac2992dbb21cc950e53651ffc07cfca907

4 years agoMerge "Fix unaligned access to auth token user_id" am: 21a17b091e am: 01759662fd
Automerger Merge Worker [Wed, 19 Feb 2020 00:06:04 +0000 (00:06 +0000)]
Merge "Fix unaligned access to auth token user_id" am: 21a17b091e am: 01759662fd

Change-Id: I224885ade242636a9806574c164f34494a8f377f

4 years agoMerge "Remove unused code in VoldUtil.h" am: e19189bd7f am: b6421644ec
Automerger Merge Worker [Wed, 19 Feb 2020 00:05:34 +0000 (00:05 +0000)]
Merge "Remove unused code in VoldUtil.h" am: e19189bd7f am: b6421644ec

Change-Id: If68c55c8e6f3db5e00e08f958845ceab8cf36f4e

4 years agoMerge changes from topics "metadata_wrapped_key_aosp", "volume_metadata" am: 36fd1ebf...
Automerger Merge Worker [Wed, 19 Feb 2020 00:05:22 +0000 (00:05 +0000)]
Merge changes from topics "metadata_wrapped_key_aosp", "volume_metadata" am: 36fd1ebfae am: 6891eb7e2d

Change-Id: I39904b704f983124afd8ff62cd3b863fd600e6a2

4 years agoMerge "Fix unaligned access to auth token user_id" am: 21a17b091e
Automerger Merge Worker [Tue, 18 Feb 2020 23:40:09 +0000 (23:40 +0000)]
Merge "Fix unaligned access to auth token user_id" am: 21a17b091e

Change-Id: If1b44823f6758c9428b5874b2629579f384399b7

4 years agoMerge "Remove unused code in VoldUtil.h" am: e19189bd7f
Automerger Merge Worker [Tue, 18 Feb 2020 23:40:04 +0000 (23:40 +0000)]
Merge "Remove unused code in VoldUtil.h" am: e19189bd7f

Change-Id: I52b8e04f85890a1a320c47a191bf1c0429e058a4

4 years agoMerge changes from topics "metadata_wrapped_key_aosp", "volume_metadata" am: 36fd1ebfae
Automerger Merge Worker [Tue, 18 Feb 2020 23:39:37 +0000 (23:39 +0000)]
Merge changes from topics "metadata_wrapped_key_aosp", "volume_metadata" am: 36fd1ebfae

Change-Id: Ieb478426e40feffcefd3a5e478e5e1c5d72539b7

4 years agoMerge "Fix unaligned access to auth token user_id"
Paul Crowley [Tue, 18 Feb 2020 23:18:46 +0000 (23:18 +0000)]
Merge "Fix unaligned access to auth token user_id"

4 years agoMerge "Remove unused code in VoldUtil.h"
Paul Crowley [Tue, 18 Feb 2020 23:18:30 +0000 (23:18 +0000)]
Merge "Remove unused code in VoldUtil.h"

4 years agoMerge changes from topics "metadata_wrapped_key_aosp", "volume_metadata"
Paul Crowley [Tue, 18 Feb 2020 23:17:07 +0000 (23:17 +0000)]
Merge changes from topics "metadata_wrapped_key_aosp", "volume_metadata"

* changes:
  On newer devices, use dm-default-key to encrypt SD cards
  vold: Wrapped key support for metadata encryption
  Refactor: make makeGen local

4 years agoOn newer devices, use dm-default-key to encrypt SD cards
Paul Crowley [Fri, 7 Feb 2020 20:51:56 +0000 (12:51 -0800)]
On newer devices, use dm-default-key to encrypt SD cards

The dm-crypt solution requires a kernel patch that won't be present in
the GKI kernel, while the new metadata encryption system in the GKI
kernel solves this problem in a much cleaner way.

Test: create private volume on Cuttlefish, setting property both ways.
Bug: 147814592
Change-Id: Ie02bd647c38d8101af2bbc47637f65845d312cea

4 years agovold: Wrapped key support for metadata encryption
Barani Muthukumaran [Fri, 7 Feb 2020 06:56:27 +0000 (22:56 -0800)]
vold: Wrapped key support for metadata encryption

metadata_encryption fstab option provides details on the cipher
and flags used for metadata encryption. wrappedkey_v0 is provided
to dm-default-key dm device when a wrapped key is used. The
inline encryption hardware unwraps the key and derives the
encryption key used to encrypt metadata without returning the key
in the clear to software.

Bug: 147733587
Test: FBE with metadata encryption using wrapped keys.
Change-Id: Ibf69bdc12bb18d2f0aef8208e65f3a8dececfd2a

4 years agoRefactor: make makeGen local
Paul Crowley [Fri, 7 Feb 2020 20:51:56 +0000 (12:51 -0800)]
Refactor: make makeGen local

No need for KeyUtil to know how to make a KeyGeneration, it's cleaner
if each module handles it separately. Also, create a CryptoOptions
structure to track metadata encryption options, and simplify legacy
cipher/option handling.

Test: Treehugger
Bug: 147814592
Change-Id: I740063882914097329ff72348d0c0855c26c7aab

4 years agoFix unaligned access to auth token user_id
Paul Crowley [Thu, 30 Aug 2018 22:25:19 +0000 (15:25 -0700)]
Fix unaligned access to auth token user_id

Bug: 65232288
Test: Set a pattern on cuttlefish, ensure we can unlock
Change-Id: I5ee09cf72ab7d3d636a25755134bfad6f88265f9

4 years agoRemove unused code in VoldUtil.h
Paul Crowley [Fri, 7 Feb 2020 23:08:12 +0000 (15:08 -0800)]
Remove unused code in VoldUtil.h

Test: Treehugger
Change-Id: I87585852af49ee49d63e3b1cde579114f855118b

4 years agoSet a default ACL on the top-level OBB directory.
Martijn Coenen [Tue, 18 Feb 2020 12:44:59 +0000 (13:44 +0100)]
Set a default ACL on the top-level OBB directory.

Since installers can create directories in Android/obb, make sure those
directories end up with the correct ACL bits as well.

Bug: 146419093
Test: inspect filesystem manually
Change-Id: I211e921197560a40599938463f3171a0ff92d9aa

4 years agoAdd sticky dir bit to Android/ dirs.
Martijn Coenen [Tue, 18 Feb 2020 09:41:37 +0000 (10:41 +0100)]
Add sticky dir bit to Android/ dirs.

We want subdirectories of Android/data, Android/obb etc. to
automatically maintain their group-id.

Bug: 146419093
Test: manual inspection of /sdcard/Android
Change-Id: I36883febb01aa155dfafb0e86f8b99223cde9815

4 years agoMerge "Retry deleting dm devices."
TreeHugger Robot [Tue, 18 Feb 2020 13:59:56 +0000 (13:59 +0000)]
Merge "Retry deleting dm devices."

4 years agoFix vold cannot create obb directory
Ricky Wai [Mon, 17 Feb 2020 18:57:01 +0000 (18:57 +0000)]
Fix vold cannot create obb directory

Test: setupAppDir works now
Change-Id: I4bc67ecb57c30b1d0728580abc738e91f97de722

4 years agoresolve merge conflicts of bdd9fbf9dbda429393ee0d86a74c71fdfbaa6a19 to master
Paul Crowley [Sun, 16 Feb 2020 15:37:18 +0000 (07:37 -0800)]
resolve merge conflicts of bdd9fbf9dbda429393ee0d86a74c71fdfbaa6a19 to master

Bug: None
Test: Treehugger
Change-Id: I17a300687bc7f56feb79b820b7196b2a9124c5f4

4 years agoMerge "Refactor key generation to handle both normal and metadata encryption." am...
Paul Crowley [Sat, 15 Feb 2020 02:13:22 +0000 (02:13 +0000)]
Merge "Refactor key generation to handle both normal and metadata encryption." am: 8e0780cba2 am: 79b853551d

Change-Id: I644d55df9c5a5441ead5b6790efff159b292c957

4 years agoMerge "Refactor key generation to handle both normal and metadata encryption." am...
Paul Crowley [Sat, 15 Feb 2020 02:03:19 +0000 (02:03 +0000)]
Merge "Refactor key generation to handle both normal and metadata encryption." am: 8e0780cba2

Change-Id: I59510b64f6803f5e76fefa359abfcc9207420126

4 years agoMerge "Refactor key generation to handle both normal and metadata encryption."
Paul Crowley [Sat, 15 Feb 2020 01:40:26 +0000 (01:40 +0000)]
Merge "Refactor key generation to handle both normal and metadata encryption."

4 years agoRetry deleting dm devices.
Ricky Wai [Sat, 15 Feb 2020 01:15:42 +0000 (01:15 +0000)]
Retry deleting dm devices.

For some reason this can be racy; until we understand the root cause,
retry to unblock AdoptableHostTest.

Bug: 149396179
Test: atest AdoptableHostTest no longer hangs
Change-Id: I162ff8ad305535e7a4fab3d88f38b687b50cf4a3

4 years agoRefactor key generation to handle both normal and metadata encryption.
Paul Crowley [Wed, 12 Feb 2020 19:04:05 +0000 (11:04 -0800)]
Refactor key generation to handle both normal and metadata encryption.

Bug: 147733587
Test: Treehugger
Change-Id: Iee176037dec2621c84da325c2627f988fcebbc8d
Merged-In: Iee176037dec2621c84da325c2627f988fcebbc8d

4 years agoRefactor key generation to handle both normal and metadata encryption.
Paul Crowley [Wed, 12 Feb 2020 19:04:05 +0000 (11:04 -0800)]
Refactor key generation to handle both normal and metadata encryption.

Bug: 147733587
Test: Treehugger
Change-Id: Iee176037dec2621c84da325c2627f988fcebbc8d

4 years agoMerge "Refactor MetadataCrypt.cpp to make create_crypto_blk_dev more general" am...
Paul Crowley [Fri, 14 Feb 2020 21:35:09 +0000 (21:35 +0000)]
Merge "Refactor MetadataCrypt.cpp to make create_crypto_blk_dev more general" am: 7566e467ab am: b272b21a0a am: 41bac014cf

Change-Id: Id9e2e9b5b9f720635218d16b2d5a65780dea1974

4 years agoMerge "Refactor MetadataCrypt.cpp to make create_crypto_blk_dev more general" am...
Paul Crowley [Fri, 14 Feb 2020 21:19:41 +0000 (21:19 +0000)]
Merge "Refactor MetadataCrypt.cpp to make create_crypto_blk_dev more general" am: 7566e467ab am: b272b21a0a

Change-Id: I6afc145de2a06a5d3bb9af516fa20cdeeb4f2c56

4 years agoMerge "Refactor MetadataCrypt.cpp to make create_crypto_blk_dev more general" am...
Paul Crowley [Fri, 14 Feb 2020 21:07:09 +0000 (21:07 +0000)]
Merge "Refactor MetadataCrypt.cpp to make create_crypto_blk_dev more general" am: 7566e467ab

Change-Id: Ib59c92bf516a171bfebc7c11be92502b37acf375

4 years agoMerge "Refactor MetadataCrypt.cpp to make create_crypto_blk_dev more general"
Paul Crowley [Fri, 14 Feb 2020 20:48:35 +0000 (20:48 +0000)]
Merge "Refactor MetadataCrypt.cpp to make create_crypto_blk_dev more general"

4 years agoMerge changes Ic3993c1f,I06645bb4 am: ac34e9aa3e am: b62afed286 am: 54d05de798
Paul Crowley [Fri, 14 Feb 2020 18:57:33 +0000 (18:57 +0000)]
Merge changes Ic3993c1f,I06645bb4 am: ac34e9aa3e am: b62afed286 am: 54d05de798

Change-Id: Ib122e011bb7be162b76b94a31885863d2aff6d1e

4 years agoMerge changes Ic3993c1f,I06645bb4 am: ac34e9aa3e am: b62afed286
Paul Crowley [Fri, 14 Feb 2020 18:45:55 +0000 (18:45 +0000)]
Merge changes Ic3993c1f,I06645bb4 am: ac34e9aa3e am: b62afed286

Change-Id: Id009631e1622d1534674332a1f146934fb4841a5

4 years agoMerge changes Ic3993c1f,I06645bb4 am: ac34e9aa3e
Paul Crowley [Fri, 14 Feb 2020 18:25:49 +0000 (18:25 +0000)]
Merge changes Ic3993c1f,I06645bb4 am: ac34e9aa3e

Change-Id: I4e11f42f1f302f8a08f60756cf08356aac8652cd

4 years agoMerge changes Ic3993c1f,I06645bb4
Paul Crowley [Fri, 14 Feb 2020 18:17:56 +0000 (18:17 +0000)]
Merge changes Ic3993c1f,I06645bb4

* changes:
  Generalize CryptoType infrastructure
  Refactor CryptoType to use better names, and size_t not uint32_t

4 years agoMerge "Stop using a regex for setupAppDir."
Martijn Coenen [Fri, 14 Feb 2020 11:44:13 +0000 (11:44 +0000)]
Merge "Stop using a regex for setupAppDir."

4 years agoRefactor MetadataCrypt.cpp to make create_crypto_blk_dev more general
Paul Crowley [Fri, 14 Feb 2020 09:15:35 +0000 (01:15 -0800)]
Refactor MetadataCrypt.cpp to make create_crypto_blk_dev more general

Bug: 147814592
Test: Treehugger
Change-Id: I13c6f84d729f2953f78626493d6e6d34d578a013

4 years agoGeneralize CryptoType infrastructure
Paul Crowley [Fri, 7 Feb 2020 20:45:20 +0000 (12:45 -0800)]
Generalize CryptoType infrastructure

More consistency between MetadataCrypt and cryptfs, and steps towards
supporting Adiantum properly in MetadataCrypt.

Test: create private volume on Cuttlefish
Bug: 147814592
Change-Id: Ic3993c1fde11b4f5a9e6cc8ee588a7d92241c6ab

4 years agoPassed kUsb and kSd flags
Risan [Fri, 7 Feb 2020 09:03:44 +0000 (18:03 +0900)]
Passed kUsb and kSd flags

Initially, we were thinking to pass kInternal for non usb drive/sd card
drive (for local external storage like directory shared from ChromeOS).
Fortunately, the DocumentsUI logic apparently has TYPE_LOCAL with
R.drawable.ic_root_smartphone (that is overlayable) for external storage
other than TYPE_USB and TYPE_SD.

Therefore, instead of creating a kInternal flags, we can just passed kUsb
and kSd and not passing anything for "internal external storage" - which
will render ic_root_usb, ic_root_sd, and ic_root_smartphone as icons
accordingly. And since ic_root_smartphone is already overlayable,  we
could overlayed in /vendor - which effectively is what we initially
wanted when thinking of introducing kInternal flag.

Bug: 132796154
Test: Customize flags in /vendor for different devices and DocumentsUI
shows the ic_root_smartphone (which can be overlayed) when kUsb is not
passed, and USB icon when kUsb is passed.
Change-Id: I55f13e214bbb2aeed96b6950bcf391121174c354

4 years agoMerge "Add disk for StubVolume"
TreeHugger Robot [Fri, 14 Feb 2020 04:35:15 +0000 (04:35 +0000)]
Merge "Add disk for StubVolume"

4 years agoRefactor CryptoType to use better names, and size_t not uint32_t
Paul Crowley [Wed, 12 Feb 2020 00:21:54 +0000 (16:21 -0800)]
Refactor CryptoType to use better names, and size_t not uint32_t

Test: treehugger
Bug: 147814592
Change-Id: I06645bb4941794797beebf05b817c4ac52e09cd7

4 years agoStop using a regex for setupAppDir.
Martijn Coenen [Thu, 13 Feb 2020 22:30:38 +0000 (23:30 +0100)]
Stop using a regex for setupAppDir.

This was hard to read and understand. Instead, fall back to explicit
string operations with more comments on what we're doing and what we're
allowing.

This also fixes an issue where apps were asking us to create dirs on
their behalf that our more than 2 levels deep, eg
com.foo/files/downloads ; I thought such paths weren't allowed, but
apparently they are (and there's no good reason for us to not set them
up correctly).

Bug: 149407572
Test: launch opera
Change-Id: I7c64831032b66e90960b96e41ee42c7d616a759c

4 years agoMerge "Use DM layer directly to manage private DM volumes" am: dd12ea5bd2 am: 47aff87...
Automerger Merge Worker [Thu, 13 Feb 2020 19:08:54 +0000 (19:08 +0000)]
Merge "Use DM layer directly to manage private DM volumes" am: dd12ea5bd2 am: 47aff8772d am: e3609aa837

Change-Id: I663a0ad6990acfc2cd936b52e39b346c2e48b6ed

4 years agoMerge "Use DM layer directly to manage private DM volumes" am: dd12ea5bd2 am: 47aff8772d
Automerger Merge Worker [Thu, 13 Feb 2020 18:59:58 +0000 (18:59 +0000)]
Merge "Use DM layer directly to manage private DM volumes" am: dd12ea5bd2 am: 47aff8772d

Change-Id: Id3af32b4e83fbfc71492d9050b2215a04b7830a9

4 years agoMerge "Use DM layer directly to manage private DM volumes" am: dd12ea5bd2
Automerger Merge Worker [Thu, 13 Feb 2020 18:43:57 +0000 (18:43 +0000)]
Merge "Use DM layer directly to manage private DM volumes" am: dd12ea5bd2

Change-Id: Ifb77dd72e810e758ac3a6105e13f7ea4341dca36

4 years agoMerge "Use DM layer directly to manage private DM volumes"
Paul Crowley [Thu, 13 Feb 2020 18:35:26 +0000 (18:35 +0000)]
Merge "Use DM layer directly to manage private DM volumes"

4 years agoMerge "Retry deleting dm devices."
Martijn Coenen [Thu, 13 Feb 2020 18:17:42 +0000 (18:17 +0000)]
Merge "Retry deleting dm devices."

4 years agoRetry deleting dm devices.
Martijn Coenen [Thu, 13 Feb 2020 15:20:52 +0000 (16:20 +0100)]
Retry deleting dm devices.

For some reason this can be racy; until we understand the root cause,
retry to unblock presubmit.

Bug: 149396179
Test: atest AdoptableHostTest no longer hangs
Change-Id: I3fb4f1d966172bac2f6c52d41c4564f905765212

4 years agoMerge "Pass volume key as a KeyBuffer" am: 334a684557 am: 4d37b4f980 am: aebcc399ea
Automerger Merge Worker [Thu, 13 Feb 2020 05:41:52 +0000 (05:41 +0000)]
Merge "Pass volume key as a KeyBuffer" am: 334a684557 am: 4d37b4f980 am: aebcc399ea

Change-Id: I7f410a56f2c301557657f9357494bcf97c7cf92d

4 years agoMerge "Pass volume key as a KeyBuffer" am: 334a684557 am: 4d37b4f980
Automerger Merge Worker [Thu, 13 Feb 2020 05:30:57 +0000 (05:30 +0000)]
Merge "Pass volume key as a KeyBuffer" am: 334a684557 am: 4d37b4f980

Change-Id: Ia5a1a2f96ba406987c60cc8fa4d94bea33b68644

4 years agoMerge "Pass volume key as a KeyBuffer" am: 334a684557
Automerger Merge Worker [Thu, 13 Feb 2020 05:17:07 +0000 (05:17 +0000)]
Merge "Pass volume key as a KeyBuffer" am: 334a684557

Change-Id: I017400aa3ef988435914ef2770b20bd78a0c1c10

4 years agoMerge "Pass volume key as a KeyBuffer"
Treehugger Robot [Thu, 13 Feb 2020 05:10:31 +0000 (05:10 +0000)]
Merge "Pass volume key as a KeyBuffer"

4 years agoMerge "Remove appDirRoot argument from setupAppDir."
Martijn Coenen [Thu, 13 Feb 2020 00:08:25 +0000 (00:08 +0000)]
Merge "Remove appDirRoot argument from setupAppDir."

4 years agoMerge "vold: Support Storage keys for FBE" am: 8cfb530357 am: aafbd4066a am: 54d5e5ca1e
Automerger Merge Worker [Thu, 13 Feb 2020 00:06:10 +0000 (00:06 +0000)]
Merge "vold: Support Storage keys for FBE" am: 8cfb530357 am: aafbd4066a am: 54d5e5ca1e

Change-Id: I7232b8c40cd5606ce6ec801d88df9768405ffa3b

4 years agoMerge "vold: Support Storage keys for FBE" am: 8cfb530357 am: aafbd4066a
Automerger Merge Worker [Wed, 12 Feb 2020 23:43:53 +0000 (23:43 +0000)]
Merge "vold: Support Storage keys for FBE" am: 8cfb530357 am: aafbd4066a

Change-Id: I8beed2f9939aada8735df5b9c5d0deb9bb3eb5ce

4 years agoMerge "vold: Support Storage keys for FBE" am: 8cfb530357
Automerger Merge Worker [Wed, 12 Feb 2020 23:37:24 +0000 (23:37 +0000)]
Merge "vold: Support Storage keys for FBE" am: 8cfb530357

Change-Id: I933a31eefe57b8b06513ca3e7a2ee874a1b680a1

4 years agoMerge "vold: Support Storage keys for FBE"
Treehugger Robot [Wed, 12 Feb 2020 23:32:29 +0000 (23:32 +0000)]
Merge "vold: Support Storage keys for FBE"

4 years agoUse DM layer directly to manage private DM volumes
Paul Crowley [Fri, 7 Feb 2020 20:15:56 +0000 (12:15 -0800)]
Use DM layer directly to manage private DM volumes

Abolish cryptfs_revert_ext_volume, handle in caller. This allows us to
use DeleteDeviceIfExists, avoiding a spurious error message.

Test: create private volume on Cuttlefish, eject, check logs
Bug: 147814592
Change-Id: I836d8bd11b29e32da0863aaa75144543bb9cab9c

4 years agoPass volume key as a KeyBuffer
Paul Crowley [Fri, 7 Feb 2020 19:49:09 +0000 (11:49 -0800)]
Pass volume key as a KeyBuffer

Not for security, but for consistency with the way we handle other
keys, and to move the length check to where it belongs.

Test: create private volume on Cuttlefish
Bug: 147814592
Change-Id: I10fc4896183d050ce25ff174faf78f525cf62930