Commit graph

3580 commits

Author SHA1 Message Date
Automerger Merge Worker
395edfede5 Merge "Pass volume key as a KeyBuffer" am: 334a684557 am: 4d37b4f980 am: aebcc399ea
Change-Id: I7f410a56f2c301557657f9357494bcf97c7cf92d
2020-02-13 05:41:52 +00:00
Automerger Merge Worker
aebcc399ea Merge "Pass volume key as a KeyBuffer" am: 334a684557 am: 4d37b4f980
Change-Id: Ia5a1a2f96ba406987c60cc8fa4d94bea33b68644
2020-02-13 05:30:57 +00:00
Automerger Merge Worker
4d37b4f980 Merge "Pass volume key as a KeyBuffer" am: 334a684557
Change-Id: I017400aa3ef988435914ef2770b20bd78a0c1c10
2020-02-13 05:17:07 +00:00
Treehugger Robot
334a684557 Merge "Pass volume key as a KeyBuffer" 2020-02-13 05:10:31 +00:00
Martijn Coenen
71d1a77ef5 Merge "Remove appDirRoot argument from setupAppDir." 2020-02-13 00:08:25 +00:00
Automerger Merge Worker
30b1a73b3a Merge "vold: Support Storage keys for FBE" am: 8cfb530357 am: aafbd4066a am: 54d5e5ca1e
Change-Id: I7232b8c40cd5606ce6ec801d88df9768405ffa3b
2020-02-13 00:06:10 +00:00
Automerger Merge Worker
54d5e5ca1e Merge "vold: Support Storage keys for FBE" am: 8cfb530357 am: aafbd4066a
Change-Id: I8beed2f9939aada8735df5b9c5d0deb9bb3eb5ce
2020-02-12 23:43:53 +00:00
Automerger Merge Worker
aafbd4066a Merge "vold: Support Storage keys for FBE" am: 8cfb530357
Change-Id: I933a31eefe57b8b06513ca3e7a2ee874a1b680a1
2020-02-12 23:37:24 +00:00
Treehugger Robot
8cfb530357 Merge "vold: Support Storage keys for FBE" 2020-02-12 23:32:29 +00:00
Paul Crowley
659b63fe00 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
2020-02-12 14:26:38 -08:00
Paul Crowley
3d98f5d159 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
2020-02-12 14:26:38 -08:00
Barani Muthukumaran
3dfb094cb2 vold: Support Storage keys for FBE
To prevent keys from being compromised if an attacker
acquires read access to kernel memory, some inline
encryption hardware supports protecting the keys in
hardware without software having access to or the
ability to set the plaintext keys.  Instead, software
only sees "wrapped keys", which may differ on every boot.

'wrappedkey_v0' fileencryption flag is used to denote
that the device supports inline encryption hardware that
supports this feature. On such devices keymaster is used
to generate keys with STORAGE_KEY tag and export a
per-boot ephemerally wrapped storage key to install it in
the kernel.

The wrapped key framework in the linux kernel ensures the
wrapped key is provided to the inline encryption hardware
where it is unwrapped and the file contents key is derived
to encrypt contents without revealing the plaintext key in
the clear.

Test: FBE validation with Fscrypt v2 + inline crypt + wrapped
key changes kernel.

Bug: 147733587

Change-Id: I1f0de61b56534ec1df9baef075acb74bacd00758
2020-02-12 14:26:26 -08:00
Greg Kaiser
724f0092a3 Avoid extra string copy
We directly pass a reference to our std::string, instead of
forcing the creation of a temporary std::string from the
result of c_str().

Test: TreeHugger
Change-Id: Ibab13f1e1ff43af076df60ae4032bf9dd111dd27
2020-02-12 07:11:09 -08:00
Martijn Coenen
8a68a075a2 Remove appDirRoot argument from setupAppDir.
This is no longer needed, because vold can deduce this itself now.

Bug: 146419093
Test: builds
Change-Id: Ib4f4a4109919af683722a63b305b343ef5fe972d
2020-02-12 15:38:45 +01:00
Martijn Coenen
d0d7640403 Merge changes I32bfced0,I3178694e,Icb8911f6
* changes:
  Set quota project ID and inheritance on top-level storage directory.
  Set default ACL on application-specific directories.
  Use a regex to create application directories.
2020-02-12 14:19:27 +00:00
Martijn Coenen
fd9cdbf124 Set quota project ID and inheritance on top-level storage directory.
When creating external storage directories like /data/media/0, make sure
we set the quota project ID correctly, and enable project ID
inheritance. This ensures that all directories/files under this will be
created with the correct project ID and inheritance as well.

Bug: 146419093
Test: lsattr -p on /data/media
Change-Id: I32bfced0d67eb8c1865897b085324f00c55926a0
2020-02-12 13:18:46 +01:00
Martijn Coenen
879fa8015d Set default ACL on application-specific directories.
On devices without sdcardfs, application-specific directories have a
particular GID that ensure some privileged daemons (like installers) are
able to write to them. Android applications however run with a umask of 0077, which means that
any subdirectory they create within their app-specific directory has
mode 700, which in turn prevents things like DownloadManager from
working, since it can be asked to download into a subdir of the app's
private storage.

To prevent this from happening, set a default 770 ACL on the top-level
app-specific directory (eg, /data/media/0/Android/data/com.foo); the
effect of that default ACL is that all directories that are created
within these directories automatically get a 770 mask, regardless of the
umask that the process has.

Bug: 146419093
Test: atest FuseDaemonHostTest on cf_x86 (without sdcardfs)

Change-Id: I3178694e6d25ce3d04a0918ac66862f644635704
2020-02-12 13:18:44 +01:00
Risan
82e90de23d Add disk for StubVolume
StubVolume is a volume type for ARC++ external storage. Named StubVolume
because it is managed from outside Android (not through Android kernel).

Previously, StubVolume is a diskless volume. However, as mentioned in
jsharkey@ email, a disk is needed for StubVolume to hold "kInternal"
(external storage type that is "external" from Android perspective,
but is "internal" to the device. For example shared directory from
ChromeOS to Android) and "kIndexable" (whether or not a disk should be
indexed by MediaStore).

The addition of disk means we could expose the createStubVolume API to
add a disk flags, which is also introduced in this CL.

Both kInternal and kIndexable will be introduced in separate CL.

Bug: 132796154
Test: Mount/unmount ARC++ removable device in ChromeOS.
Change-Id: I8b77fa1cf50ab38a2892272154dafdb78f079378
2020-02-12 07:42:40 +00:00
Automerger Merge Worker
d74f4949de Merge "Have vold inform keymaster that early boot ended" am: 68b9fb10ae am: fce0d92ce4 am: bf352873ad
Change-Id: I3aaebfcca61c92667de114d477cbbcf35d23bcd9
2020-02-12 04:50:35 +00:00
Automerger Merge Worker
bf352873ad Merge "Have vold inform keymaster that early boot ended" am: 68b9fb10ae am: fce0d92ce4
Change-Id: If58cc1911c477ac9bed03fc39952a573db71651e
2020-02-12 04:35:10 +00:00
Automerger Merge Worker
fce0d92ce4 Merge "Have vold inform keymaster that early boot ended" am: 68b9fb10ae
Change-Id: Ic113eea7d3282084f1eae308ae1b6df931bd7a8c
2020-02-12 04:25:19 +00:00
Treehugger Robot
68b9fb10ae Merge "Have vold inform keymaster that early boot ended" 2020-02-12 04:07:43 +00:00
Automerger Merge Worker
861a70b0ea [automerger skipped] Merge "Update vold to use KM4.1" am: 6c5f302a90 am: 53f8e2df82 am: 3660bf983c -s ours
am skip reason: Change-Id I4574a2f6eead3b71d1e89488b496b734694620c7 with SHA-1 ae8f06fe1c is in history

Change-Id: I98403470def2e60e7ff5b8b6ee55c5a34f4e463a
2020-02-12 01:24:05 +00:00
Automerger Merge Worker
3660bf983c Merge "Update vold to use KM4.1" am: 6c5f302a90 am: 53f8e2df82
Change-Id: I808df576abeec8ce2dd5fc8ea9d4784f4c8b6b0d
2020-02-12 01:11:28 +00:00
Automerger Merge Worker
53f8e2df82 Merge "Update vold to use KM4.1" am: 6c5f302a90
Change-Id: I5393adf2503586c87414a302fa24d381863bccbf
2020-02-12 01:06:54 +00:00
Treehugger Robot
6c5f302a90 Merge "Update vold to use KM4.1" 2020-02-12 00:56:18 +00:00
Shawn Willden
2b1ff5aaab Have vold inform keymaster that early boot ended
Just before mounting partition(s) not verified by verified boot, vold
should notify keymaster that early boot has ended so it won't allow
EARLY_BOOT_ONLY keys to be created or used.

Test: VtsHalKeymasterV4_1TargetTest
Change-Id: I74ffec8d5b33f01e62f845a8fc824b3a3cad50f3
Merged-In: I74ffec8d5b33f01e62f845a8fc824b3a3cad50f3
2020-02-11 15:51:04 -07:00
Shawn Willden
35f0f22c9b Update vold to use KM4.1
This CL updates vold to use the Keymaster 4.1 interface, but does not
yet call any of the new methods.

Test: Boot the device
Change-Id: I4574a2f6eead3b71d1e89488b496b734694620c7
Merged-In: I4574a2f6eead3b71d1e89488b496b734694620c7
2020-02-11 15:51:04 -07:00
Martijn Coenen
04bb17f112 Use a regex to create application directories.
A regex allows us to be more specific in what kind of directories we
accept here, which in turn makes it easier to correctly create them.

Bug: 146419093
Test: atest FuseDaemonHostTest
Change-Id: Icb8911f6516eab81b9bbd567c7287be9f605e8b0
2020-02-11 14:22:30 +01:00
Automerger Merge Worker
3fcbdbff5f Merge "Use std::string to return crypto device, not char *" am: 80731b0975 am: 2381810b99 am: 1541f9f32b
Change-Id: I68cf7bfc6ce642d46d874bb44694109b1f43258e
2020-02-11 01:18:30 +00:00
Automerger Merge Worker
1541f9f32b Merge "Use std::string to return crypto device, not char *" am: 80731b0975 am: 2381810b99
Change-Id: Ic7683749f4974ccdf251b7351110a1e3663536b7
2020-02-11 01:03:00 +00:00
Automerger Merge Worker
2381810b99 Merge "Use std::string to return crypto device, not char *" am: 80731b0975
Change-Id: I4cdc6e59713a945f9fc7b6e9d8c765e78c44b9cb
2020-02-11 00:49:53 +00:00
Paul Crowley
80731b0975 Merge "Use std::string to return crypto device, not char *" 2020-02-11 00:37:26 +00:00
Martijn Coenen
1f40bea0bb Merge "Add TEST_MAPPING for vold." 2020-02-10 09:09:29 +00:00
Martijn Coenen
b77ad3a4cc Add TEST_MAPPING for vold.
Start with FuseDaemonHostTest and AdoptableHostTest, since these heavily
rely on functionality implemented in FUSE to work correctly.

Bug: 149095627
Test: run atest in system/vold
Change-Id: Ia583505aae260584897b0ea80c419b0e34f04735
2020-02-10 08:57:30 +01:00
Martijn Coenen
a0213ff0c3 Merge "Add SetQuotaInherit API." 2020-02-10 07:54:30 +00:00
Automerger Merge Worker
cc733959f6 Merge "Refactor: make cryptfs.h smaller" am: 98c501d28e am: 645c2f40a0 am: ebbabdc8fb
Change-Id: If8c533aa196969adf38dcbf85673cebb39a79024
2020-02-08 02:27:49 +00:00
Automerger Merge Worker
ebbabdc8fb Merge "Refactor: make cryptfs.h smaller" am: 98c501d28e am: 645c2f40a0
Change-Id: I5fb7f528186b6a678a02febd9e866ca4ae467dd4
2020-02-08 02:15:04 +00:00
Automerger Merge Worker
645c2f40a0 Merge "Refactor: make cryptfs.h smaller" am: 98c501d28e
Change-Id: I85d5bacfc08245397cb4f8aa71406bfeed961c19
2020-02-08 01:50:57 +00:00
Treehugger Robot
98c501d28e Merge "Refactor: make cryptfs.h smaller" 2020-02-08 01:34:29 +00:00
Paul Crowley
81796e9dce Use std::string to return crypto device, not char *
Bug: 147814592
Test: can create private volume on Cuttlefish
Change-Id: Ic2bca81c0f0319e1b988e9204a2f4e91af57d157
2020-02-07 11:27:49 -08:00
Paul Crowley
73be12dcd5 Refactor: make cryptfs.h smaller
Move most of it into cryptfs.cpp, and include cryptfs.h in fewer files.

Bug: 147814592
Test: Treehugger
Change-Id: Ia3592d73e7abc1f07a60538e0978a3033bdea7de
2020-02-07 11:16:12 -08:00
Zim
a13d81bbf5 Create Android/media dirs
I3a879089422c7fc449b6a3e6f1c4b386b86687a4 enforces some gids on the
Android/ dirs but left out Android/media. We now create it

Test: atest FuseDaemonHostTest#testListFilesFromExternalMediaDirectory
Bug: 149072341
Change-Id: I260c414906cd491a6bdd83522ff45f8663e15604
2020-02-07 17:42:47 +00:00
Martijn Coenen
5fe1b16330 Add SetQuotaInherit API.
This allows setting the "inherit project ID" flags on directories; in
our case, we want to set this on the root of the lower filesystem, eg
"/data/media/0".

Bug: 146419093
Test: manual invocation works
Change-Id: Ic74588fd972d464e7021bef953da0e5aaafc4286
2020-02-06 18:57:47 +01:00
Martijn Coenen
ba9868bd78 Set correct quota project ID on application directories.
Use PrepareAppDirsFromRoot() to setup the quota project ID on
application-specific directories correctly. App directories use
AID_EXT_GID_START + their application ID offset, whereas cache
directories use AID_CACHE_GID_START. This is consistent with the GIDs
sdcardfs used to label these directories with.

Bug: 146419093
Test: verified project IDs with lsattr -p
Change-Id: Idca8a30d185012efb0d19ceb9b346b9a4de34f18
2020-02-04 13:02:51 +01:00
Martijn Coenen
62a4b279ab Setup Android/, Android/data and Android/obb dirs correctly.
Normally sdcardfs takes care of setting up these directories on-demand,
for example when an app requests its private data directory to be
created. On devices without sdcardfs however, we ourselves need to make
sure to setup the UID/GID of these directories correctly.

Introduce a new PrepareAndroidDirs() function which sets the dirs up
correctly. On devices without sdcardfs, that means:

Path              UID         GID         mode
/Android          media_rw    media_rw     771
/Android/data     media_rw    ext_data_rw  771
/Android/obb      media_rw    ext_obb_rw   771

Bug: 146419093
Test: wipe Android/, reboot, with and without sdcardfs, verify
      contents

Change-Id: I3a879089422c7fc449b6a3e6f1c4b386b86687a4
2020-02-04 13:02:49 +01:00
TreeHugger Robot
bff86152e5 Merge "Harden /mnt/pass_through paths" 2020-02-03 08:13:47 +00:00
Automerger Merge Worker
7b40c8e2b2 Merge changes from topics "dm-default-key-v2", "metadata_cipher" am: f60e947438 am: 0560c27092 am: 5aac6ab55f
Change-Id: Ia65e525982d7f95416345c0004f79e7ecc7e026e
2020-02-01 16:40:35 +00:00
Automerger Merge Worker
5aac6ab55f Merge changes from topics "dm-default-key-v2", "metadata_cipher" am: f60e947438 am: 0560c27092
Change-Id: I0c34298e89be72caf597c964ceeb7f3396abe20b
2020-02-01 16:29:52 +00:00
Automerger Merge Worker
0560c27092 Merge changes from topics "dm-default-key-v2", "metadata_cipher" am: f60e947438
Change-Id: I3e27ed3481542e5e6fe0db2c872d745151e50765
2020-02-01 16:19:45 +00:00