Commit graph

102 commits

Author SHA1 Message Date
Yabin Cui
ffa2e09921 vold: write bootloader message directly.
Bug: 27176738
Change-Id: I09bfe777e383325809d7ecc2dcb9129fe234053f
2016-04-06 17:21:38 -07:00
Paul Crowley
63c18d3ba9 Add scrypt-based password stretching.
Bug: 27056334
Change-Id: Ifa7f776c21c439f89dad7836175fbd045e1c603e
2016-02-10 14:07:59 +00:00
Jeff Sharkey
47695b29af Allow callers to prepare CE/DE user storage.
Give callers the option of preparing CE and/or DE storage.  The
framework will only prepare CE storage after the CE keys have been
unlocked for that user.

When init is calling enablecrypto, kick off the work in a thread so
that we can make other calls back into vold without causing
deadlock.  Leaves blocking call intact for framework callers.

Clean up 'vdc' tool to send useful transaction numbers, and
actually watch for the matching result to come back.  This fixes
race conditions when there are multiple 'vdc' callers.

Also add other system and misc directories to match spec.

Bug: 25796509
Change-Id: Ie4f853db6e387916b845d2b5fb92925d743b063d
2016-02-05 13:03:52 -07:00
Jeff Vander Stoep
75fc83bac8 resolve merge conflicts of 2b6f9ce823 to master.
Change-Id: I69f36f560334b11b099f2eb15999603dd2469d4f
2016-02-01 15:24:58 -08:00
Jeff Vander Stoep
df72575862 cryptfs: run e2fsck/fsck.f2fs in fsck domain
e2fsck and fsck.f2fs must run in the fsck domain. Add call to
setexeccon() to tell selinux to run in the fsck domain on exec.

Addresses:
avc: denied { execute_no_trans } for path="/system/bin/e2fsck" dev="mmcblk0p41" ino=241 scontext=u:r:vold:s0 tcontext=u:object_r:fsck_exec:s0 tclass=file

Bug: 26872236
Change-Id: Ib2a583aeefc667f8aa67532e0ac0ff9619b65461
2016-02-01 12:59:59 -08:00
Paul Crowley
13ffd8ef7a Improvements to the key storage module
The key storage module didn't comply with Android coding standards
and had room for improvemnet in a few other ways, so have cleaned up.

Change-Id: I260ccff316423169cf887e538113b5ea400892f2
2016-01-27 15:54:35 +00:00
Paul Crowley
1ef255816c Use a keymaster-based key storage module
Instead of writing raw keys, encrypt the keys with keymaster. This
paves the way to protecting them with auth tokens and passwords later.
In addition, fold in the hash of a 16k file into their encryption, to
ensure secure deletion works properly.

Now even C++ier!

Bug: 22502684
Bug: 22950892
Change-Id: If70f139e342373533c42d5a298444b8438428322
2016-01-26 18:24:03 +00:00
Paul Crowley
8bb8fcfb4f Use android-base logging not cutils in secdiscard
Much nicer C++ style logging, but the main reason is to clean up
AutoCloseFD.h so I don't have to use cutils to use it.

Change-Id: I7a7f227508418046eecce6c89f813bd8854f448a
2016-01-12 10:03:05 +00:00
Sami Tolvanen
f0500a0823 am 0331d4ae: am 685dfdd3: Merge "Error correction: Add libfec dependencies for vold"
* commit '0331d4ae3843f682e98bfa1aba0f8da7fbd9beb0':
  Error correction: Add libfec dependencies for vold
2015-10-02 10:55:10 +00:00
Sami Tolvanen
0331d4ae38 am 685dfdd3: Merge "Error correction: Add libfec dependencies for vold"
* commit '685dfdd33590ef8a93627015c434fea54b8f1b4d':
  Error correction: Add libfec dependencies for vold
2015-10-02 10:47:23 +00:00
Sami Tolvanen
efe67cd25d Error correction: Add libfec dependencies for vold
Vold requires libfec and related dependencies due to fs_mgr_mount_all.

Bug: 21893453
Change-Id: If59df0c5fd3395d4aac97dd8119b7c70c0fa5d4d
2015-09-29 14:55:35 +01:00
Tom Cherry
10b02df820 am 218f48d6: Merge "bundle init.rc contents with its service"
* commit '218f48d6c55a7ee5115a7a8fc4248d33ea01811f':
  bundle init.rc contents with its service
2015-08-21 18:24:14 +00:00
Tom Cherry
685439bbc7 am 218f48d6: Merge "bundle init.rc contents with its service"
* commit '218f48d6c55a7ee5115a7a8fc4248d33ea01811f':
  bundle init.rc contents with its service
2015-08-21 18:20:19 +00:00
Tom Cherry
a285984ae4 bundle init.rc contents with its service
Bug: 23186545
Change-Id: I82d8b6dc54ebe32ceb1ed997aaab3701ee7b6c4a
2015-08-19 17:36:11 -07:00
Paul Crowley
f4000e480d am 5bd0daf9: Add tool for scrubbing files with BLKSECDISCARD.
* commit '5bd0daf926ea8096dc091d7b99ff9e56cc5746aa':
  Add tool for scrubbing files with BLKSECDISCARD.
2015-07-14 15:06:47 +00: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
Jeff Sharkey
3ff337db56 am c86ab6f5: Trim both internal and adopted private storage.
* commit 'c86ab6f538bec63638c168d6c843fe7cf73add3b':
  Trim both internal and adopted private storage.
2015-07-02 00:58:16 +00: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
d6a77b518c am d0640f63: Add f2fs support for private volumes.
* commit 'd0640f6358041f7e2657167560b357078db73526':
  Add f2fs support for private volumes.
2015-06-09 13:01:36 +00: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
5c18a67579 Merge commit 'd0b4295c' into manualmerge
Change-Id: I6d7178edebf50663fa9622b539c8101627a84385
2015-06-04 16:01:47 -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
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
Jeff Sharkey
ddd4da1af6 am 5a6bfca1: Initial pass at storage benchmarks.
* commit '5a6bfca1638760b87cf64c5ffb48ff3557cc0563':
  Initial pass at storage benchmarks.
2015-05-15 22:22:33 +00:00
Jeff Sharkey
5a6bfca163 Initial pass at storage benchmarks.
Now that we're offering to store private app data on adopted storage
devices, the performance of those devices is much more important to
overall user experience.

To help set user expectations, this change offers to execute a
real-world benchmark on a storage device, returning a metric that can
be used to compare internal and external storage.  The benchmark is
generated from the strace-instrumented storage access patterns of
typical apps.

A typical device completes the benchmark in under two seconds on
internal storage, a UHS-3 SD card is even faster (!), but a very slow
Class 4 SD card takes about 30 seconds to complete, giving us a clear
signal.

The measured benchmark numbers are logged along with information
about the storage device, such as manufacturer, model, etc.  Card
serial numbers are scrubbed from output.

Bug: 21172095
Change-Id: I9b2713dafdfdfcf5d97bf1bc21841f39409a7e54
2015-05-15 10:48:11 -07:00
Kenny Root
e05aacfec6 resolved conflicts for merge of 9df68a13 to mnc-dev-plus-aosp
Change-Id: I5c72c27ec055195d84c58d0699b46d3942c29dde
2015-05-13 09:36:52 -07:00
Paul Crowley
75a5202d9f Add vold commands for setting up per-user encrypted user
directories

Bug: 19704432
Change-Id: I15980eed8e4960ca270cf0f8db4e480a8c2ca832
2015-05-13 10:17:14 +01:00
Paul Crowley
4f817d1bd2 am 42696d97: Merge "Make vdc a C++ file as a base for further improvement."
* commit '42696d97ce138fa5e7a1380b3841250549acb615':
  Make vdc a C++ file as a base for further improvement.
2015-05-06 23:48:01 +00:00
Paul Crowley
fde9cd8c82 Make vdc a C++ file as a base for further improvement.
Bug: 19704432
Change-Id: I784e8a91d3b0f4d6cd0dc668e9e55d0290f768e8
2015-05-06 12:41:10 +01:00
Paul Lawrence
e225260184 Merge commit 'c3e4cc29' into manualmerge
Change-Id: I1f6feaf743e0b9a62fe212af3cd9dd16abefeb00
2015-04-29 09:47:44 -07:00
Paul Lawrence
707fd6c7cc Securely encrypt the master key
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-04-28 22:41:58 +00:00
Paul Lawrence
f7de12b264 resolved conflicts for merge of bf9dcad7 to mnc-dev-plus-aosp
Change-Id: Ic0d4ed7e6c83ad857e2a4a198d069b73fcf399e6
2015-04-28 14:19:09 -07:00
Paul Lawrence
beadcb6ec0 Revert "Securely encrypt the master key"
This reverts commit 7053e9cd5e.

Change-Id: I77ed4dbdff8643c80629d2126cb29f85c24c7b43
2015-04-28 19:16:46 +00:00
Paul Lawrence
74e85f1872 resolved conflicts for merge of 86138731 to mnc-dev-plus-aosp
Change-Id: I89203aa1665bb42f9a98fd8b94b933e8406dde02
2015-04-27 14:14:36 -07:00
Paul Lawrence
7053e9cd5e Securely encrypt the master key
Move all key management into vold
Reuse vold's existing key management through the crypto footer
to manage the device wide keys

This is one of four changes to enable this functionality:
  https://android-review.googlesource.com/#/c/144586/
  https://android-review.googlesource.com/#/c/144663/
  https://android-review.googlesource.com/#/c/144672/
  https://android-review.googlesource.com/#/c/144673/

Bug: 18151196
Change-Id: I9a162b90afe5f46a4ff15b3878e2ab503795425e
2015-04-27 20:08:38 +00:00
Jeff Sharkey
1d6fbcc389 Migrate primary external storage.
When requested, kick off a thread that will migrate storage contents
between two locations.  This is performed in several steps that
also interact with the framework:

1. Take old and new volumes offline during migration
2. Wipe new location clean (10% of progress)
3. Copy files from old to new (60% of progress)
4. Inform framework that move was successful so it can persist
5. Wipe old location clean (15% of progress)

Derives a hacky progress estimate by using a rough proxy of free
disk space changes while a cp/rm is taking place.

Add new internal path for direct access to volumes to bypass any
FUSE emulation overhead, and send it to framework.  Remove mutex
around various exec calls since setexeccon() is already per-thread.

Bug: 19993667
Change-Id: Ibcb4f6fe0126d05b2365f316f53e71dc3e79a2b8
2015-04-24 16:08:07 -07:00
Mohamad Ayyash
3896727376 am 959de99a: am f8c905e0: Merge "Add dependency on libsquashfs_utils due to fs_mgr dependency"
* commit '959de99af47dec9ed7a3499ce57e4097be399d7d':
  Add dependency on libsquashfs_utils due to fs_mgr dependency
2015-04-07 18:44:08 +00:00
Mohamad Ayyash
c489d7f4e7 Add dependency on libsquashfs_utils due to fs_mgr dependency
Change-Id: I894d18c2086a6532194f478853a9837eb4b6fc09
Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
2015-04-06 18:22:35 -07:00
Jeff Sharkey
9f18fe7807 Remove unused code.
Bug: 19993667
Change-Id: I1f6519655c5a366eca25e2329e1bf95d81b3bf8c
2015-04-01 23:33:26 -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
Dan Albert
ae9e890337 Update for libbase.
Change-Id: I23b1281a63031a7481ea7b33c9ddbdbe7d3d6174
2015-03-16 10:35:17 -07: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
Kenny Root
ba5834dcea am 26970299: Merge "Remove superfluous OpenSSL include paths."
* commit '269702997153cdf92c65cfee277c76afed44e9e5':
  Remove superfluous OpenSSL include paths.
2015-01-23 01:17:16 +00:00
Adam Langley
41405bb3e5 Remove superfluous OpenSSL include paths.
The libcrypto and libssl modules (and their respective static and host
versions) use LOCAL_EXPORT_C_INCLUDE_DIRS thus just including the module
is sufficient.

Additionally, cryptfs.h was including an OpenSSL header just to get the
length of a SHA-256 hash. Rather than force all users of this header to
also depend on libcrypto, it's easier just to define that value in the
header file.

Change-Id: I3e3e0db906a212e1093944b298e4a8ff2e2fb07d
2015-01-22 16:45:28 -08:00
Dan Albert
210caabdb5 resolved conflicts for merge of 88aba541 to lmp-mr1-dev-plus-aosp
Change-Id: Ie5ef819dd8168cb6a73f84a881a92c116705fffc
2014-12-18 14:08:43 -08:00
Dan Albert
c07fa3fa5a Fix alignment of buffer used for dm_ioctl.
Since the dm_ioctl struct was being allocated on the stack as a large
character array, it was getting character alignment rather than the
proper alignment for the struct. GCC had been getting away with this
so far, but it's undefined behavior that clang managed to expose.

Bug: 18736778
Change-Id: Ied275dfad7fcc41d712b2d02c8a185f499221f57
2014-12-18 10:24:23 -08:00
Tim Murray
6c78e7d772 resolved conflicts for merge of 4be36106 to lmp-mr1-dev-plus-aosp
Change-Id: If504710a618d8c3adf85297d5fd2909558ed57a3
2014-12-17 16:41:07 -08:00
Tim Murray
8439dc9fd5 Make vold compile with -Werror -Wall.
-Wno-missing-field-initializers is used as well, but that is an
overzealous warning from initializing structs with {0} and not a
real warning.

bug 18736778 and 16868177

Change-Id: Iffde89cd7200d9a11193e1614f1819f9fcace30a
2014-12-18 00:21:21 +00:00
Dan Albert
97f3d073ac am a20bb17e: Merge "Move vold to GCC."
* commit 'a20bb17e4c6095a77425418d7eb0c1ceb50d05f7':
  Move vold to GCC.
2014-12-13 02:17:32 +00:00
Dan Albert
084f0b3dd5 Move vold to GCC.
It looks like clang might have a miscompile that is causing SIGBUS in
`ioctl_init` when the device is encrypted. Move back to GCC until we
can sort this out.

Bug: 18736778
Change-Id: I21ae3b9d7d9ebff8679ecc1a828b7c59f27d0903
2014-12-12 17:47:16 -08:00