Commit graph

882 commits

Author SHA1 Message Date
Jeff Sharkey
157ba4356d am 8474ee32: Return useful path when not visible.
* commit '8474ee323131fdadcc17f09eab25003a7ae934e0':
  Return useful path when not visible.
2015-07-31 01:51:32 +00:00
Jeff Sharkey
8474ee3231 Return useful path when not visible.
This allows apps like ExternalStorageProvider to still read/write
files on transient storage devices which aren't mounted as visible.

Bug: 22545248
Change-Id: Idacb15f2233245a8e1861d9be977535a82b218ec
2015-07-30 16:54:23 -07:00
Jeff Sharkey
4864af926d am d46687ee: Use random data for benchmark instead of zeros.
* commit 'd46687ee5da7c9847c6188241ccc699d3a0826c2':
  Use random data for benchmark instead of zeros.
2015-07-29 20:10:22 +00:00
Jeff Sharkey
d46687ee5d Use random data for benchmark instead of zeros.
If we always write zeros, we're leaving a giant pile of known
plaintext at an almost deterministic location on newly formatted
volumes.  To avoid this, repeat a 64K chunk of random data.

Bug: 22816936
Change-Id: Iedc067a519bd676a93b9d74ea4f9f77c84c8461c
2015-07-29 10:03:11 -07:00
Jeff Sharkey
27f98a12df am 20642ae7: Give secondary users read-only physical cards.
* commit '20642ae71aa93ec2658d09c92a1ffc3844f5a555':
  Give secondary users read-only physical cards.
2015-07-29 01:34:47 +00:00
Jeff Sharkey
20642ae71a Give secondary users read-only physical cards.
Long ago, we mounted secondary physical cards as readable by all
users on the device, which enabled the use-case of loading media on
a card and viewing it from all users.

More recently, we started giving write access to these secondary
physical cards, but this created a one-directional channel for
communication across user boundaries; something that CDD disallows.

This change is designed to give us the best of both worlds: the
package-specific directories are writable for the user that mounted
the card, but access to those "Android" directories are blocked for
all other users.  Other users remain able to read content elsewhere
on the card.

Bug: 22787184
Change-Id: I75dbd339f11402ae774c7e4b8f2b15ee216270e8
2015-07-28 17:47:11 -07:00
Jeff Sharkey
78003caff3 am 32679a82: Create user directory on emulated storage.
* commit '32679a82d9542ec26ea8b4e32d29dd7b02202611':
  Create user directory on emulated storage.
2015-07-23 19:12:57 +00:00
Jeff Sharkey
32679a82d9 Create user directory on emulated storage.
When mounting a primary external storage device that is multi-user
aware, ensure that the user-specific directory actually exists before
moving forward.

Bug: 22472026
Change-Id: I33c8eed261a9c0d5acedd5be6133ed9990679d08
2015-07-21 14:22:03 -07:00
Paul Crowley
9336348200 Evict the key before we delete it.
Change-Id: I9eef440a1f406c2c73c859f5ae7cee35f6a36ca4
2015-07-13 21:12:58 +01:00
Paul Crowley
e76d9e6be6 Fix erroneous comment in secdiscard.cpp, plus style fixes.
Bug: 19706593

(cherry picked from commit 747e1f7a6d)

Change-Id: I9a605c736a2fa909cd4999e1e8d022d49a562767
2015-07-13 21:08:45 +01:00
Paul Crowley
cd307b7c63 Scrub the key from the disk with BLKSECDISCARD.
Bug: 19706593

(cherry-picked from commit 8d0cd7ffd903a753c6bb5c6f33987a7a66621cef)

Change-Id: Ieea73da233fe53767b5adcdb4d49f9bb00fedac1
2015-07-13 21:08:45 +01:00
Paul Crowley
5bd0daf926 Add tool for scrubbing files with BLKSECDISCARD.
Bug: 19706593

(based on work in commit 8d0cd7ffd903a753c6bb5c6f33987a7a66621cef)

Change-Id: I9699275a63f2d0a110435bd4a725d7dfcce4ed90
2015-07-13 21:08:45 +01:00
Paul Crowley
b33e8873ea Add "cryptfs deleteuserkey" command to vold.
Bug: 19706593

(cherry-picked from commit eebf44563b)

Change-Id: I50dc4c39595c06bf0016d6a490130bbbc25de91b
2015-07-13 21:08:45 +01:00
Paul Crowley
95376d612c Add vold commands for setting up per-user encrypted user
directories

Bug: 19704432

(cherry-picked from commit 75a5202d9f)

Change-Id: I733e8745ec21f8e53c2cc6d8a98313275db7d897
2015-07-13 21:08:45 +01:00
Paul Crowley
f25a35a1c9 Break key installation into its own function so we can install
non-master keys.

Bug: 19704432
(cherry-picked from commit 1da96dc549)

Change-Id: I762e8f6c927db3a337fa8ce6bd428262d9e05c7a
2015-07-13 21:08:44 +01:00
Paul Lawrence
f733ae6306 Don't break on setting default password
Bug: 22329642
Change-Id: I58dac4dba8e65c7015d50ca0c3575f77f550a215
2015-07-13 16:59:12 +00:00
Jeff Sharkey
81f55c6dc1 Mount emulated volumes as consistent location.
We really only support a single emulated volume on the device at a
time, either on internal storage, or moved to a private volume.  To
avoid kicking off a giant rescan of all media when moved, keep all
the paths the same when mounted as primary.

Also ensure we have /data/media/0 ready on private volumes.

Bug: 20275423
Change-Id: I0c102f430b865ca7536772b1fae56d8c9660a97a
2015-07-08 14:07:39 -07:00
Jeff Sharkey
c86ab6f538 Trim both internal and adopted private storage.
Refactor fstrim code to be encapsulated in unique task object, and
give it option of benchmarking when finished.  Trimming now includes
both storage from fstab and adopted private volumes.  Cleaner timing
stats are logged for each unique volume.

Add wakelock during ongoing async move tasks.  Push disk sysfs path
to framework so it can parse any SD card registers as desired.

Bug: 21831325
Change-Id: I76577685f5cae4929c251ad314ffdaeb5eb1c8bf
2015-07-01 15:53:51 -07:00
Jeff Sharkey
c7b5b570bd Null-terminate readlink() result, full remount.
In order to compare results from readlink() calls, we need to null
terminate the read value, otherwise we can end up doing an infinitely
recursive remount in the root namespace.

When remounting inside a namespace, unmount all existing mounts before
mounting the new storage into place.  This also means we need to mount
the user-specific symlinks back into place.

Skip spinning up the FUSE daemon when not visible, otherwise we get
stuck waiting for a daemon that never shows up.

Bug: 22192518, 22204412
Change-Id: Icc7db822354ab7ffc47c39cd0611f65edecc32e5
2015-06-30 15:54:17 -07:00
Jeff Sharkey
63123c067a Last ditch check for partition on raw disk.
Some storage devices can be formatted as bare partitions, without an
MBR or GPT header.  If we found no partitions, try poking at the raw
disk, and treat it as a public volume if we found a valid filesystem.

Bug: 20503551
Change-Id: I80304e1ad865435321c341b667c0daf2daf4d56c
2015-06-26 11:16:17 -07:00
Jeff Sharkey
66270a21df Let's reinvent storage, yet again!
Now that we're treating storage as a runtime permission, we need to
grant read/write access without killing the app.  This is really
tricky, since we had been using GIDs for access control, and they're
set in stone once Zygote drops privileges.

The only thing left that can change dynamically is the filesystem
itself, so let's do that.  This means changing the FUSE daemon to
present itself as three different views:

/mnt/runtime_default/foo - view for apps with no access
/mnt/runtime_read/foo - view for apps with read access
/mnt/runtime_write/foo - view for apps with write access

There is still a single location for all the backing files, and
filesystem permissions are derived the same way for each view, but
the file modes are masked off differently for each mountpoint.

During Zygote fork, it wires up the appropriate storage access into
an isolated mount namespace based on the current app permissions.  When
the app is granted permissions dynamically at runtime, the system
asks vold to jump into the existing mount namespace and bind mount
the newly granted access model into place.

Bug: 21858077
Change-Id: Iade538e4bc7af979fe20095f74416e8a0f165a4a
2015-06-25 22:40:08 -07:00
Makoto Onuki
5d268fdac4 Merge "Make sure volume is vfat before fsck'ing." into mnc-dev 2015-06-24 20:33:57 +00:00
Makoto Onuki
c82c9ce18c Make sure volume is vfat before fsck'ing.
Bug 21948137

Change-Id: I6843423fd8809d9e2f352059a810aa17dd83b3e3
2015-06-24 13:30:45 -07:00
Shawn Willden
86af3557e3 Add purpose to vold-generated keymaster1 keys.
Also remove the app ID and additional padding and digest options.

Bug: 22009890
Change-Id: Ibff9bbd0e0c11d651d11fac85d4ac907588f1cd2
2015-06-24 09:27:31 -07:00
Jeff Sharkey
bc40cc8f07 Add method to forget private partition keys.
Report both the disk and the partition GUID for private volumes to
userspace, and offer to forget the encryption key for a given
partition GUID.

Bug: 21782268
Change-Id: Ie77a3a58e47bf3563cdb3e4b0edfab1de4d0e6b4
2015-06-22 14:04:54 -07:00
Shawn Willden
0417060e8e Use correct error code for rate limiting.
Note that this CL depends on cl 712195, which must be submitted first.

Bug: 21607106
Change-Id: Iafc42d1c8a1145a31ea252b33b404044f92ec62b
2015-06-19 09:14:51 -06:00
Shawn Willden
da6e899f4e Add keymaster1 support to vold.
Bug: 21607106
Change-Id: I498141b90888d4f0652912413b04519f61886935
2015-06-17 10:27:07 -06:00
Paul Lawrence
b1ef4665e8 Improve boot time by 0.1s by reducing a polling sleep interval
Bug: 21516860
Change-Id: I9e28f4d9cc20ec2a7d9e325c02ef85f0ad9b3d60
2015-06-11 11:36:18 -07:00
Jeff Sharkey
210228a089 Merge "Start tracking added users with serial numbers." into mnc-dev 2015-06-10 16:44:54 +00:00
Jeff Sharkey
bd3038df74 Start tracking added users with serial numbers.
vold will eventually use the serial numbers to clean up stale user
directories when mounting private storage devices.

Bug: 20275572
Change-Id: Ia29cb5da23e969f3087bb5caa5dc8f4e88f07613
2015-06-10 09:42:01 -07:00
Paul Lawrence
3bd36d5e5f Remove hex encoding and password adjusting now that patterns are '1' based
Bug: 21606650
Change-Id: I3486ad394d563135c5171a1d4785f7a27eeea3ae
2015-06-10 07:21:19 -07:00
Jeff Sharkey
34824129de Run restorecon over mounted private volumes.
This ensures that we have consistent SELinux policy in place before
going any further, and it mirrors the way we restorecon /data when
first mounted.

Bug: 21121357
Change-Id: I2a7e3584ade655fe1fae8916cf54f9eae3a0f99d
2015-06-09 16:28:44 -07:00
Jeff Sharkey
d0640f6358 Add f2fs support for private volumes.
When formatting volumes, pass along fsType string which can be "auto"
to let the volume select the best choice.  For now, private volumes
assume that MMC devices (like SD cards) are best off using f2fs when
both kernel support and tools are present, otherwise fall back to
ext4.  Use blkid when mounting to pick the right set of tools.

Move filesystem utility methods into namespaces and place in separate
directory to be more organized.

Bug: 20275581
Change-Id: Id5f82d8672dda2e9f68c35b075f28232b0b55ed4
2015-06-08 20:21:25 -07:00
Paul Lawrence
d0b4295ccc Move crypt commands to a different listener in vold
In order to prevent this bug from happening, we must allow vold cryptfs
commands to complete while a long running mount is underway.

While waiting for vold to be changed to a binder interface, we will simply
create two listeners, one for cryptfs and one for everything else.

Bug: 19197175
Change-Id: If74142aa81abd58f718a9de6c9e387f6ea442754
2015-06-04 21:29:01 +00:00
Paul Lawrence
0628fa2514 Improve boot time
Bug: 21516860
Change-Id: I3153c7f9a414a8eeadc0118f0a642ad8e96c81ce
2015-06-04 10:49:25 -07:00
Elliott Hughes
d25e107440 Merge "Don't use TEMP_FAILURE_RETRY on close in vold." into mnc-dev 2015-05-29 22:04:26 +00:00
Paul Lawrence
86c942a253 DO NOT MERGE Delete password as per block encryption
(cherry-picked from commit 00f4aade5c)

Bug: 18151196
Change-Id: Iee0f932c61ff4a309dc2861725b24bf976adb4c7
2015-05-29 14:22:18 -07:00
Paul Lawrence
0d9cd9e9cf DO NOT MERGE Fix problem that reading/writing crypto footers wasn't identity
(cherry-picked from commit 75c922f49b)

Bug: 18151196
Change-Id: Ideef6bcdbccf068a64ed3e042be50c4837a373f8
2015-05-29 14:21:33 -07:00
Paul Lawrence
2f32cda63b DO NOT MERGE Retry unmounts in ext4 encryption
(cherry-picked from commit 29b54aab8e)

Bug: 18151196
Change-Id: I52ca23b2ce3adcff44bd003d4a12243a0bd6ac34
2015-05-29 14:20:51 -07:00
Paul Lawrence
b7f0702ea6 DO NOT MERGE Use default key permissions for ext4enc
(cherry-picked from commit 1190a26f6d)

As per discussion default permissions are the correct ones.
Note that since we use logon keys, they cannot be read outside
the kernel.

Note also that we limit who can read/write keys in selinux policy.

Bug: 18151196
Change-Id: Icc916f430a70eff22e6b74c20ec361c8f3789c1c
2015-05-29 14:20:06 -07:00
Paul Lawrence
a56d3134b0 DO NOT MERGE Simplify password checking logic
(cherry-picked from commit aaccfac344)

Bug: 18151196
Change-Id: I07ffde534dee7d1032149cfcbaa1a61c5246d759
2015-05-29 14:17:48 -07:00
Paul Lawrence
368d79459e DO NOT MERGE Enable properties in ext4enc
(cherry-picked from 4e7274551c)

Enables OwnerInfo and pattern suppression

Bug: 18151196

Change-Id: I46144e16cb00319deeb5492ab82c67f5dd43d6d3
2015-05-29 14:16:42 -07:00
Paul Lawrence
c78c71b171 DO NOT MERGE Check password is correct by checking hash
(cherry-picked from commit 3ca21e227a)

Handle failures gracefully

Change-Id: Ifb6da8c11a86c50fb11964c18cc1be1326461f78
2015-05-29 14:13:50 -07:00
Paul Lawrence
fd7db73243 DO NOT MERGE New ext4enc kernel switching from xattrs to ioctl
(cherrypicked from commit 5e7f004231)

This is one of three changes to enable this functionality:
  https://android-review.googlesource.com/#/c/146259/
  https://android-review.googlesource.com/#/c/146264/
  https://android-review.googlesource.com/#/c/146265/

Bug: 18151196

Change-Id: Iba5146b8be1e15050ae901e08b3aaa26d96dcf7e
2015-05-29 17:50:43 +00:00
Paul Lawrence
731a7a242d DO NOT MERGE Securely encrypt the master key
(cherry-picked from commit 707fd6c7cc)

Move all key management into vold
Reuse vold's existing key management through the crypto footer
to manage the device wide keys.

Use ro.crypto.type flag to determine crypto type, which prevents
any issues when running in block encrypted mode, as well as speeding
up boot in block or no encryption.

This is one of four changes to enable this functionality:
  https://android-review.googlesource.com/#/c/148586/
  https://android-review.googlesource.com/#/c/148604/
  https://android-review.googlesource.com/#/c/148606/
  https://android-review.googlesource.com/#/c/148607/

Bug: 18151196

Change-Id: I3c68691717a61b5e1df76423ca0c02baff0dab98
2015-05-29 17:25:54 +00:00
Elliott Hughes
4e378be81e Don't use TEMP_FAILURE_RETRY on close in vold.
Bug: http://b/20501816
Change-Id: Ia0a3899947582b8dd0e8e185c203d1ad7dad572e
2015-05-28 22:02:14 -07:00
Jeff Sharkey
65427f1a80 Offer debug flag to force default primary.
Useful for transforming a secondary SD card slot into a primary SD
card slot without doing a completely different lunch target.

$ adb shell stop
$ adb shell setprop vold.debug.default_primary 1
$ adb shell setprop ro.vold.primary_physical 1
$ adb shell setprop ctl.restart vold
$ adb shell start

Bug: 21017105
Change-Id: I45aac7ab3bb4c5ac3e0140572844883823fc3e4f
2015-05-19 15:54:15 -07:00
Jeff Sharkey
721e5807ed Fully sync filesystem before time measurements.
Also drop unneeded SCR register logging.

Bug: 21172095
Change-Id: I17c5aae2edc0eb7144ab38701f90a1fd54e119da
2015-05-19 11:20:48 -07:00
Elliott Hughes
4351c9a08b Merge "Don't use TEMP_FAILURE_RETRY on close in vold." into mnc-dev 2015-05-16 02:42:31 +00:00
Elliott Hughes
a623108ef4 Don't use TEMP_FAILURE_RETRY on close in vold.
Bug: http://b/20501816
Change-Id: Ieecce9304539c250ed1728252b8c2c09d29afd7f
2015-05-15 18:34:24 -07:00