Commit graph

800 commits

Author SHA1 Message Date
Jeff Sharkey
95c87cce35 Different blkid and fsck execution domains.
vold works with two broad classes of block devices: untrusted devices
that come in from the wild, and trusted devices like PrivateVolume
which are encrypted.

When running blkid and fsck, we pick which SELinux execution domain
to use based on which class the device belongs to.

Bug: 19993667
Change-Id: I2695f028710a4863f0c3b2ed6da437f466401272
2015-04-01 14:08:40 -07:00
Jeff Sharkey
9c48498f45 Support for private (adopted) volumes.
This adds support for private volumes which is just a filesystem
wrapped in a dm-crypt layer.  For now we're using the exact same
configuration as internal encryption (aes-cbc-essiv:sha256), but we
don't store any key material on the removable media.  Instead, we
store the key on internal storage, and use the GPT partition GUID
to identify which key should be used.

This means that private external storage is effectively as secure as
the internal storage of the device.  That is, if the internal storage
is encrypted, then our external storage key is also encrypted.

When partitioning disks, we now support a "private" mode which has
a PrivateVolume partition, and a currently unused 16MB metadata
partition reserved for future use.  It also supports a "mixed" mode
which creates both a PublicVolume and PrivateVolume on the same
disk.  Mixed mode is currently experimental.

For now, just add ext4 support to PrivateVolume; we'll look at f2fs
in a future change.  Add VolumeBase lifecycle for setting up crypto
mappings, and extract blkid logic into shared method.  Sprinkle some
more "static" around the cryptfs code to improve invariants.

Bug: 19993667
Change-Id: Ibd1df6250735b706959a1eb9d9f7219ea85912a0
2015-04-01 10:45:05 -07:00
Jeff Sharkey
38cfc02860 Fix 64 bit builds.
Change-Id: I4e30ecff3c29d0f8351c6f43de1c979c8c792fab
2015-03-30 21:23:16 -07:00
Jeff Sharkey
36801cccf2 Progress towards dynamic storage support.
Wire up new Disk and VolumeBase objects and events to start replacing
older DirectVolume code.  Use filesystem UUID as visible PublicVolume
name to be more deterministic.

When starting, create DiskSource instances based on fstab, and watch
for kernel devices to appear.  Turn matching devices into Disk
objects, scan for partitions, and create any relevant VolumeBase
objects.  Broadcast all of these events towards userspace so the
framework can decide what to mount.

Keep track of the primary VolumeBase, and update the new per-user
/storage/self/primary symlink for all started users.

Provide a reset command that framework uses to start from a known
state when runtime is restarted.  When vold is unexpectedly killed,
try recovering by unmounting everything under /mnt and /storage
before moving forward.

Remove UMS sharing support for now, since no current devices support
it; MTP is the recommended solution going forward because it offers
better multi-user support.

Switch killProcessesWithOpenFiles() to directly take signal.  Fix
one SOCK_CLOEXEC bug, but SELinux says there are more lurking.

Bug: 19993667
Change-Id: I2dad1303aa4667ec14c52f774e2a28b3c1c1ff6d
2015-03-30 19:46:31 -07:00
Elliott Hughes
2a8c10965a am 8a0fde27: am e9623fed: Merge "Fixed type mismatch for ioctl(BLKGETSIZE)"
* commit '8a0fde272be430f66b2e5db6236aa732d2ba6efc':
  Fixed type mismatch for ioctl(BLKGETSIZE)
2015-03-30 21:28:10 +00:00
Elliott Hughes
8a0fde272b am e9623fed: Merge "Fixed type mismatch for ioctl(BLKGETSIZE)"
* commit 'e9623fede7a89d61952f983f0c0a294fc3563c9c':
  Fixed type mismatch for ioctl(BLKGETSIZE)
2015-03-30 21:14:49 +00:00
Elliott Hughes
e9623fede7 Merge "Fixed type mismatch for ioctl(BLKGETSIZE)" 2015-03-30 21:03:04 +00:00
Hiroaki Miyazawa
14eab550e8 Fixed type mismatch for ioctl(BLKGETSIZE)
ioctl(BLKGETSIZE) expects unsigned long
(8 bytes on 64 bit environment).

This is fixing fails in android.os.storage.StorageManagerIntegrationTest
(in FrameworkCoreTests).

To verify, install FrameworksCoreTests.apk and do:

adb shell am instrument -r -w -e class android.os.storage.\
StorageManagerIntegrationTest#testMountSingleEncryptedObb \
com.android.frameworks.coretests/android.test.InstrumentationTestRunner

Change-Id: Ib6d5c7490c02521c93f107c35ad0aac49f6a3f1a
2015-03-30 11:28:11 -07:00
Paul Lawrence
36b7b0c681 am 836e7860: am 8120c3d1: Merge "Adding e4crypt support"
* commit '836e78608dcb16a490330e051416787df2ee14db':
  Adding e4crypt support
2015-03-27 23:31:44 +00:00
Paul Lawrence
836e78608d am 8120c3d1: Merge "Adding e4crypt support"
* commit '8120c3d1b2a8b4c6570c36bcdaf7c55392f5fa45':
  Adding e4crypt support
2015-03-27 21:42:21 +00:00
Paul Lawrence
8120c3d1b2 Merge "Adding e4crypt support" 2015-03-27 20:46:05 +00:00
Paul Lawrence
8175a0b65d Adding e4crypt support
Redirect all crypto calls to e4crypt equivalents if file level encryption
detected. Note this change implements only the ones needed for minimal
functionality.

Requires matching change:
  https://googleplex-android-review.git.corp.google.com/#/c/642778/

Change-Id: I622d1a91704de4b3ab655486e6d38cd6718e6016
2015-03-27 13:38:41 -07:00
Paul Lawrence
05335c344d Adding e4crypt support
Redirect all crypto calls to e4crypt equivalents if file level encryption
detected. Note this change implements only the ones needed for minimal
functionality.

Requires matching change:
  https://googleplex-android-review.git.corp.google.com/#/c/642778/

Change-Id: I622d1a91704de4b3ab655486e6d38cd6718e6016
2015-03-19 09:46:47 -07:00
JP Abgrall
0b9489b027 fstrim: Don't double trim mountpoints with alternative fs types.
Now we skip mountpoints that are repeated.

Bug: 19744511
Change-Id: Iff1618274a07180e62a01c3e2479dc1d52baf267
Signed-off-by: JP Abgrall <jpa@google.com>
2015-03-16 15:07:59 -07:00
Dan Albert
ae9e890337 Update for libbase.
Change-Id: I23b1281a63031a7481ea7b33c9ddbdbe7d3d6174
2015-03-16 10:35:17 -07:00
Jeff Sharkey
9e02365a9f Merge "Follow NetlinkEvent refactoring." 2015-03-13 20:47:51 +00:00
Jeff Sharkey
2e0b4a2c54 Follow NetlinkEvent refactoring.
Change-Id: I130b250a663cdfb379def24583523d0287ec31dd
2015-03-13 13:40:50 -07:00
Jeff Sharkey
6f90ce0f8a Merge "Checkpoint of better dynamic device support." 2015-03-13 18:05:09 +00:00
Jeff Sharkey
deb2405737 Checkpoint of better dynamic device support.
This is the first in a series of changes that are designed to
introduce better support for dynamic block devices.

It starts by defining a new Volume object which represents a storage
endpoint that knows how to mount, unmount, and format itself.  This
could be a filesystem directly on a partition, or it could be an
emulated FUSE filesystem, an ASEC, or an OBB.

These new volumes can be "stacked" so that unmounting a volume will
also unmount any volumes stacked above it.  Volumes that provide
shared storage can also be asked to present themselves (through bind
mounts) into user-specific mount areas.

This change also adds a Disk class which is created based on block
kernel netlink events.  Instead of waiting for partition events from
the kernel, it uses gptfdisk to read partition details and creates
the relevant Volume objects.

Change-Id: I0e8bc1f8f9dcb24405f5e795c0658998e22ae2f7
2015-03-13 10:12:57 -07:00
JP Abgrall
6bbb3906d0 fstrim: don't trim mount points flagged as notrim
Bug: 19624276
Change-Id: I84eeb029114d6ba2a26a53d4155d123d8acd7502
2015-03-05 17:30:20 -08:00
Nick Kralevich
68fe15243b am 58819cde: am cdcffc0d: am 3393bb65: Merge "fstrim.c: use open(O_DIRECTORY) instead of stat"
* commit '58819cde54c61776bf72e8b3369d240cd2dc5b4d':
  fstrim.c: use open(O_DIRECTORY) instead of stat
2015-03-05 21:15:39 +00:00
Nick Kralevich
58819cde54 am cdcffc0d: am 3393bb65: Merge "fstrim.c: use open(O_DIRECTORY) instead of stat"
* commit 'cdcffc0d29da177399eb403df00e6693ce5e83bb':
  fstrim.c: use open(O_DIRECTORY) instead of stat
2015-03-05 21:10:01 +00:00
Nick Kralevich
cdcffc0d29 am 3393bb65: Merge "fstrim.c: use open(O_DIRECTORY) instead of stat"
* commit '3393bb650fd931e494a0280fc13717f36aea22fc':
  fstrim.c: use open(O_DIRECTORY) instead of stat
2015-03-05 21:03:15 +00:00
Nick Kralevich
3393bb650f Merge "fstrim.c: use open(O_DIRECTORY) instead of stat" 2015-03-05 20:57:54 +00:00
Nick Kralevich
24751743d7 fstrim.c: use open(O_DIRECTORY) instead of stat
open(O_DIRECTORY) returns an error if the open attempt
is against anything other than a directory. This basically
duplicates the check that the stat() call was trying to do.
Eliminate the unnecessary stat() call and use O_DIRECTORY
instead.

Change-Id: I1821abbed325f29a7214fdc41ed27cd9e26817d0
2015-03-05 12:50:23 -08:00
Shawn Willden
ac6d753079 am 42c79333: am 47bc0ffa: am 5054f7ee: Merge "Rename keymaster_device_t to keymaster0_device_t."
* commit '42c793333c7cfdb311e0abbe0dfeb64074c9f34f':
  Rename keymaster_device_t to keymaster0_device_t.
2015-02-26 23:55:44 +00:00
Shawn Willden
42c793333c am 47bc0ffa: am 5054f7ee: Merge "Rename keymaster_device_t to keymaster0_device_t."
* commit '47bc0ffaddacc3514d12db1b8b8bb4b10eae13ea':
  Rename keymaster_device_t to keymaster0_device_t.
2015-02-26 23:44:34 +00:00
Shawn Willden
47bc0ffadd am 5054f7ee: Merge "Rename keymaster_device_t to keymaster0_device_t."
* commit '5054f7ee4fa6e747eb8d08f60ec91ba6a9363878':
  Rename keymaster_device_t to keymaster0_device_t.
2015-02-26 23:31:10 +00:00
Shawn Willden
5054f7ee4f Merge "Rename keymaster_device_t to keymaster0_device_t." 2015-02-26 23:24:54 +00:00
JP Abgrall
282ec3c37a am af057b52: am aac44855: am c19c6738: Merge "vold: acquire wakelock on fstrim thread"
* commit 'af057b52ea152701d30591be5ea0b74473a5c466':
  vold: acquire wakelock on fstrim thread
2015-02-26 19:16:57 +00:00
JP Abgrall
af057b52ea am aac44855: am c19c6738: Merge "vold: acquire wakelock on fstrim thread"
* commit 'aac44855caf0f2f7f2e655fc06ce9782b9c80af7':
  vold: acquire wakelock on fstrim thread
2015-02-26 19:10:57 +00:00
JP Abgrall
aac44855ca am c19c6738: Merge "vold: acquire wakelock on fstrim thread"
* commit 'c19c67388cca4bda7b2042f065a7dc596f72fee8':
  vold: acquire wakelock on fstrim thread
2015-02-26 19:03:35 +00:00
JP Abgrall
c19c67388c Merge "vold: acquire wakelock on fstrim thread" 2015-02-26 18:56:16 +00:00
Shawn Willden
f8f712f559 am b87264fb: Rename keymaster_device_t to keymaster0_device_t.
* commit 'b87264fb82818d5c64ccae454718845796953a88':
  Rename keymaster_device_t to keymaster0_device_t.
2015-02-26 18:48:10 +00:00
Young-ho Cha
e72cd592b3 vold: acquire wakelock on fstrim thread
If fstrim thread creation or detachment is failed, wakelock can be leaked.
So move wakelock acquire to do_fstrim_filesystems function

Change-Id: I4da3164343af83fae3e5b01700f43d1752661276
Signed-off-by: Young-ho Cha <ganadist@gmail.com>
2015-02-26 18:45:52 +00:00
Shawn Willden
8af33350cd Rename keymaster_device_t to keymaster0_device_t.
This is to accomodate the new keymaster1_device_t, which has an entirely
different interface.

Soon I'll provide a libkeymaster which provides a unified (and nicer)
interface for dealing with both v0 and v1 keymaster implementations
using a v1 keymaster API.  For now this change is just so that vold will
build and run.

Change-Id: I5c54282c12d1c4b8b22ed4929b6e6c724a94ede4
2015-02-25 23:08:46 -07:00
Shawn Willden
b87264fb82 Rename keymaster_device_t to keymaster0_device_t.
This is to accomodate the new keymaster1_device_t, which has an entirely
different interface.

Soon I'll provide a libkeymaster which provides a unified (and nicer)
interface for dealing with both v0 and v1 keymaster implementations
using a v1 keymaster API.  For now this change is just so that vold will
build and run.

Change-Id: I5c54282c12d1c4b8b22ed4929b6e6c724a94ede4
2015-02-25 21:40:18 -07:00
Shawn Willden
d1fd8468d0 Rename keymaster_device_t to keymaster0_device_t.
This is to accomodate the new keymaster1_device_t, which has an entirely
different interface.

Soon I'll provide a libkeymaster which provides a unified (and nicer)
interface for dealing with both v0 and v1 keymaster implementations
using a v1 keymaster API.  For now this change is just so that vold will
build and run.

Change-Id: I5c54282c12d1c4b8b22ed4929b6e6c724a94ede4
2015-02-24 09:55:04 -07:00
JP Abgrall
933216c886 crytpfs: fix clobbering of crypto info on keymaster failure
Changing the device lock (even from swipe to none) will cause the
master key to be re-encrypted.
If at that point keymaster fails (e.g. due to an incompatible keymaster update)
cryptfs will write back the now-incomplete crypto metadata.
Upon next reboot, userdata can't be decrypted.

Now we don't bother writing on keymaster failure.

Bug: 19301883
Change-Id: I2b9a1278f8b4d333ac8d567e17e2263005e99409
2015-02-11 13:44:32 -08:00
Elliott Hughes
d32b75e6dc am 33b6de4b: am d55d8dac: Merge "prevent ioctl_init() to write outside buffer"
* commit '33b6de4b94e018b3cb621db5eabcb3a4f18bdd3d':
  prevent ioctl_init() to write outside buffer
2015-02-09 04:15:13 +00:00
Elliott Hughes
450cfd189b am d773fc11: am 8c0a0db1: Merge "Change strncpy to strlcpy"
* commit 'd773fc118a30d3273888391ebf9f0ea5a916cd75':
  Change strncpy to strlcpy
2015-02-09 04:15:13 +00:00
Paul Lawrence
a655b9a39f am 38394c7d: am 223fd1ca: Revert "Make encryption configurable"
* commit '38394c7d2d6d5bd8c7467155587a78b912e2b7ab':
  Revert "Make encryption configurable"
2015-02-09 04:14:28 +00:00
Elliott Hughes
33b6de4b94 am d55d8dac: Merge "prevent ioctl_init() to write outside buffer"
* commit 'd55d8dac45dc60cb2cc9e599d3e89532db0cfc39':
  prevent ioctl_init() to write outside buffer
2015-02-07 07:38:37 +00:00
Elliott Hughes
d773fc118a am 8c0a0db1: Merge "Change strncpy to strlcpy"
* commit '8c0a0db1ad217f3238e31c291afa6b5e6a6fc98d':
  Change strncpy to strlcpy
2015-02-07 07:38:37 +00:00
Elliott Hughes
d55d8dac45 Merge "prevent ioctl_init() to write outside buffer" 2015-02-07 07:29:43 +00:00
Elliott Hughes
8c0a0db1ad Merge "Change strncpy to strlcpy" 2015-02-07 07:28:06 +00:00
Paul Lawrence
38394c7d2d am 223fd1ca: Revert "Make encryption configurable"
* commit '223fd1cad8d627dc36e11da8cdd342c1a810d226':
  Revert "Make encryption configurable"
2015-02-07 00:11:29 +00:00
Paul Lawrence
223fd1cad8 Revert "Make encryption configurable"
This reverts commit 6a69cfc411.

The original fix seems to have led to boot failures in QA. Rather than
risk shipping, revert the change. Bug 18764230 reopened.

Requires change
    https://googleplex-android-review.git.corp.google.com/#/c/629950/

Bug: 19278390
Bug: 19199624

Change-Id: Ia858c4db0abb917f9364ec8048f59ca4fb48e233
2015-02-06 17:32:56 +00:00
Nick Kralevich
5b5bbc18d7 am cf694550: am d9f2082f: Merge "VolumeManager: don\'t use faccessat(AT_SYMLINK_NOFOLLOW)"
* commit 'cf694550b2ab718ddc28810b5a1ebe9cf5f46e7d':
  VolumeManager: don't use faccessat(AT_SYMLINK_NOFOLLOW)
2015-02-06 17:26:25 +00:00
Nick Kralevich
cf694550b2 am d9f2082f: Merge "VolumeManager: don\'t use faccessat(AT_SYMLINK_NOFOLLOW)"
* commit 'd9f2082fd798e77cc15735bc582507abb64c8ed4':
  VolumeManager: don't use faccessat(AT_SYMLINK_NOFOLLOW)
2015-02-06 17:20:23 +00:00