Commit graph

74 commits

Author SHA1 Message Date
Paul Lawrence
45f10533f8 Revert "Revert "Encrypt phone even if pattern or no keyguard""
Don't block based on keyguard type, and pass type to encryption function.

Requires:
  https://googleplex-android-review.git.corp.google.com/#/c/444201/
or encryption will no longer work.

This reverts commit efec3f2927.

Change-Id: I431589a56eb11118027e0a5a84f55e973b1084aa
2014-04-10 14:30:31 +00:00
Paul Lawrence
efec3f2927 Revert "Encrypt phone even if pattern or no keyguard"
This reverts commit 5cc86c5741.

Without two more commits, this will break encryption. I'll re-commit when the other two pass code review.

Change-Id: I71720d065c16cf0f7f534e74ffe883f1e113c477
2014-04-03 20:55:47 +00:00
Paul Lawrence
5cc86c5741 Encrypt phone even if pattern or no keyguard
Add option to enablecrypto to take type, allowing us to set type
when encrypting.

Bug: 13749169
Change-Id: If22fcfa93f1ebd1a5bd3b0077bb3bd8ae71fe819
2014-04-03 19:20:28 +00:00
Paul Lawrence
0798707334 Merge "Fix setfield/getfield" 2014-03-24 17:51:59 +00:00
Paul Lawrence
cc215381dd Merge "Store password in vold" 2014-03-21 20:40:36 +00:00
Paul Lawrence
87999173dd Don't corrupt ssd when encrypting and power fails
Stop encryption when battery is low, mark position, and continue on reboot.

Note - support for multiple encrypted volumes removed as no devices seem
to exist with an fstab that uses this feature. If you want support for such
a device, contact me and we will re-add it with appropriate testing.

Bug: 13284213
Change-Id: I1f7178e4f7dd8ea816cbc03ab5c4f6543e98acaa
2014-03-21 18:30:26 +00:00
Paul Lawrence
399317ede4 Store password in vold
If we are not to double prompt, we need to pass the password from
CryptKeeper to KeyStore. Since the entire framework is taken down
and restarted, we must store the password in a secure system daemon.
There seems no better way than holding it in vold.

Change-Id: Ia60f2f051fc3f87c4b6468465f17b655f43f97de
2014-03-21 11:15:39 -07:00
Paul Lawrence
8561b5c9f5 Fix setfield/getfield
Check for versions >= feature version, not equal

Bug: 13526708
Change-Id: Ie07f6334e6b7c5ca0d7f83ba00827a508e2c2963
2014-03-18 10:52:14 -07:00
Paul Lawrence
684dbdf316 Infrastructure to securely allow only one prompt at boot when encrypted
Add a call to vold that says if we decrypted the data partition. Reset the
flag so that it only returns true the first time.

Bug: 12990752
Change-Id: Ib00be87137c00fb8ad29205c85a3ea187764b702
2014-02-14 17:41:18 +00:00
Paul Lawrence
1348603357 Enable auto-encrypt drive at startup
Modify enablecrypto command to make the password optional. When it is
not there, default encrypt the device.

Remove a warning by making at least some parts of this file const-correct.

Bug: 11985952
Change-Id: Ie27da4c4072386d9d6519d97ff46c6dc4ed188dc
2014-02-14 09:34:44 -08:00
Paul Lawrence
931f15d050 Merge "Support default, pattern, pin and password encryption types" 2014-02-14 15:24:13 +00:00
Mark Salyzyn
2c1bbe0c44 am 49dd24c2: am 1dc1fb4a: Merge "vold: suppress unused argument warning messages"
* commit '49dd24c238e86c57e97f919af7fbf8ee3d79b737':
  vold: suppress unused argument warning messages
2014-02-13 00:19:54 +00:00
Paul Lawrence
f4faa575c9 Support default, pattern, pin and password encryption types
Store encryption type in crypto footer, and provide functions to
manipulate it. Add mount_default_encrypted command to vdc to allow
mounting of default encrypted volumes at boot time.

Bug: 8769627
Change-Id: Ie41848f258e128b48b579e09789abfa24c95e2b2
2014-02-12 14:54:40 -08:00
Mark Salyzyn
5eecc449cc vold: suppress unused argument warning messages
(cherry picked from commit 3e971277db)

Change-Id: Ic1ab533f756fbd44b1f2e5ae12e2f5736ace7740
2014-02-12 14:27:51 -08:00
Mark Salyzyn
3e971277db vold: suppress unused argument warning messages
Change-Id: Ic1ab533f756fbd44b1f2e5ae12e2f5736ace7740
2014-02-12 20:18:28 +00:00
Colin Cross
88948cd60c am e985c9ab: am 1d8e3ce8: Merge "vold: fix errors inside ALOGV"
* commit 'e985c9ab10fed452b97138170b4d69288d076b06':
  vold: fix errors inside ALOGV
2014-02-10 12:51:31 +00:00
Colin Cross
59846b654e vold: fix errors inside ALOGV
Fix errors exposed by adding compile-time checking to disabled ALOGVs.

Change-Id: I29bd6e9a7648ccca02e0e9a96b79ee0ea7b5cfc6
2014-02-06 20:34:29 -08:00
Paul Lawrence
ae59fe6c19 Fast ext4 encryption
For ext4 filesystems, only encrypt blocks in use.

Needs matching ext4 utils changes from
 https://googleplex-android-review.git.corp.google.com/#/c/409575

Bug: 11985952
Change-Id: I89df051c25105daf3f469cc980195202f8be6786
2014-01-29 22:29:10 +00:00
Doug Zongker
6fd5771337 allow encrypted filesystems to be mounted readonly
By setting ro.crypto.readonly to 1, cryptfs will mount an encrypted
filesystem that is normally mounted read-write as read-only instead.
To be used when recovery mounts /data.

Bug: 12188746
Change-Id: If3f3f9a3024f29ebc4ad721a48546a332cb92b6b
2013-12-17 09:43:23 -08:00
JP Abgrall
dbf5b6652c am 46f8c2b9: am 7bdfa52d: vold: cryptfs: Don\'t update KDF without validating pwd/key.
* commit '46f8c2b954e11c2266871b8110b74bd6a11f3661':
  vold: cryptfs: Don't update KDF without validating pwd/key.
2013-11-15 14:25:37 -08:00
JP Abgrall
7bdfa52d93 vold: cryptfs: Don't update KDF without validating pwd/key.
Prior to this, the Key derivation function would get
 blindly updated even if the user entered the wrong password.
Now, we only attempt to upgrade the KDF if the pwd/key have
been verified (i.e. after a successful mount).

Bug: 11460197
Change-Id: I0469228cc9b87c47754e8ca3c7146651da177da5
2013-11-15 13:42:56 -08:00
JP Abgrall
502dc74153 vold: cryptfs: Retry encryption after killing processes using /data
Currently, if a non-framework process or service is using /data,
unmounting will fail as nothing will kill it.
Instead of rebooting on unmount failure, we now kill all processes
using /data, then try one more time.

Bug: 11291208
Change-Id: I6c5276c78aa55965914ace96e1db74dc80fca3c1
2013-11-01 13:08:46 -07:00
Ken Sumrall
e550f78a3f Use android_fork_execvp() instead of system(3) to format filesystems
With the recent selinux changes imposed on vold, it no longer has
permission to run a shell, so invoking the filesystem formatting
commands with system(3) gives an error.  So change to using
android_fork_execvp().

Bug: 10279958

Change-Id: Ifa18b28867618858ec7c5cfcc67935e377de38fb
2013-08-21 11:30:16 -07:00
Kenny Root
2947e34e41 Initialize iterator
Iterator wasn't initialized in scrypt parameter scanning.

Bug: 10330227
Change-Id: If41fc25d9f827106fa8329bdb5966b7d786fddcb
2013-08-14 23:26:19 +00:00
Ken Sumrall
558830c38a Merge "vold: Use the new method of rebooting by asking init to do it" 2013-06-28 02:47:46 +00:00
Ken Sumrall
adfba3626e vold: Use the new method of rebooting by asking init to do it
Change-Id: I7fd5f1048c3cf43fa14597f079c929690cac367c
2013-06-26 17:51:44 -07:00
Kenny Root
c4c70f15bb Change key derivation to scrypt
scrypt is a sequential memory-hard key derivation algorithm that makes
it more difficult for adversaries to brute force passwords using
specialized equipment. See http://www.tarsnap.com/scrypt/scrypt.pdf for
more details of the algorithm.

This adds support for initializing disk encryption using scrypt and
upgrading from the previous PBKDF2 algorithm.

Change-Id: I1d26db4eb9d27fea7310be3e49c8e6219e6d2c3b
2013-06-24 09:40:54 -07:00
Kenny Root
c96a5f8edf Extract some version constants to header
In order to make it easier to upgrade the crypto footer, extract some
constants to a header file instead. Then the header can control what the
current version is and the upgrade_crypto_ftr code should be the only
thing that needs to be updated.

Change-Id: I3ed5a7d3b640419cd8af91388d94a00de8cc09db
2013-06-14 12:50:02 -07:00
Kenny Root
7434b3111b Change upgrade code to allow multiple versions
In the future, we'd like to have the ability to upgrade from any
supported version to any future version. Change the upgrade function
slightly to support this.

Change-Id: I3b20ccfff51c4c86f1e5e08690c263dc95ff5ce4
2013-06-14 11:32:18 -07:00
Ken Sumrall
9caab76c6b vold: Add an optional wipe paramter to the volume format command
The new wipe option to the vold format command will invoke BLKDISCARD
on the partition before invoking newfs_msdos.  This will be used whenever
a full wipe of the device is wanted, as this is more secure than just
doing newfs_msdos.

Bug: 9392982
Change-Id: Ie106f1b9cc70abc61206006d1821641c27c7ccae
2013-06-12 18:42:02 -07:00
Ken Sumrall
e88e1eb745 am c587269c: vold: Increase timeout due to selinux changes
* commit 'c587269c5a34d4e7412ff42e53ed6312359a8505':
  vold: Increase timeout due to selinux changes
2013-05-14 19:19:22 -07:00
Ken Sumrall
c587269c5a vold: Increase timeout due to selinux changes
The new selinux_reload_policy command can take a while to complete on
some systems.  The reason is being investigated, and hopefully a fix can
be found to improve performance, but for now, increase the timeout that
vold waits for the post_fs_data section to complete when decrypting a
device on boot.

Also, emit a decent error message if the device times out.

Bug: 8967715
Change-Id: Ifb01c983dffe095a9de752c17c467a1751e9ce99
2013-05-14 15:26:31 -07:00
Alex Klyubin
707795ad39 Fix a typo in a comment
Change-Id: Ibb9667d762189849ebcbefef4ba70ffd34cf885e
2013-05-10 15:17:07 -07:00
Ken Sumrall
160b4d68ec vold: Add support for unencrypted persistent info
In order to display the correct language, timezone, airplane
mode and other settings on the decrypt screen, a copy of those
settings needs to be stored unencrypted so the framework can
query them.  This adds support to vold to store up to 32
property like key/value pairs that are not encrypted.

Change-Id: Id5c936d2c57d46ed5cff9325d92ba1e8d2ec8972
2013-04-26 15:44:59 -07:00
Ken Sumrall
56ad03cae1 vold: use unified fstab format
Change vold to use the unified fstab.  This includes both
support for sdcards, and changes to the crypto code to work
with some changes to the fs_mgr library api.

Change-Id: Id5a8aa5b699afe151db6e31aa0d76105f9c95a80
2013-02-15 18:21:56 -08:00
Ken Sumrall
db5e026058 Enable allow_discards if dm-crypt supports it
dm-crypt version 1.11.0 and later supports the allow_discards option
when setting up a crypto device.  This passes discard requests from
the filesytem to the underlying block device.  This helps make flash
based storage faster.  So query the dm-crypt version, and pass the
option if the version is 1.11.0 or greater.

Change-Id: If30e9db5a2dbd6ea0281d91344e5b2c35e75131e
2013-02-07 15:05:54 -08:00
Ken Sumrall
92736efab0 Another fix for encryption
The previous problem of the framework not properly restarting after accepting
the password to decrypt the storage is also a problem when restarting the
framework to display the encryption progress screen.  So like the previous
hacky fix, add a sleep to wait a few moments before proceeding.  Also,
increase the sleep of the previous fix from 1 second to 2, as the problem
was seen once more in testing.  A proper fix has been designed and hopefully
will work and be checked-in RSN.

Change-Id: Icc2c072ce7f7ebcdea22cd7ff8cb2b87a627c578
2012-10-17 20:57:14 -07:00
Ken Sumrall
9dedfd473d Fix encryption on certain devices
There is a race in the encryption code that after it accepts the
decryption password, it tells init to kill all the processes in
class "main", then it mounts the decrypted filesystem, preps it,
and restarts the framework.  For an unknown reason on some devices,
the new framework sometimes starts up before init has killed and
reaped all the old processes.  The proper fix is to make the killing
of the old framework synchronous, so vold waits till all the
processes have died.  But with factory rom a few days away, the
much more pragmatic solution of adding a sleep of 1 second after
telling init to kill the old framework will suffice.

Bug: 7271212
Change-Id: Ie971cd04abbc6f3f6500b4acd79d3b3b26d9561c
2012-10-09 14:30:00 -07:00
Jeff Sharkey
b77bc4696b Update environment variable for multi-user.
Bug: 7260040
Change-Id: I96d821e11a3f0be32bfe92a4151f00f2b15d100e
2012-10-01 14:36:26 -07:00
Ken Sumrall
e919efea94 Workaround a kernel race when loading dmcrypt table
The kernel seems to return from umount(2) sometimes before it has
released the underlying block device.  So until the kernel is fixed,
try up to 10 times to load the crypto mapping table, waiting 500 ms
between tries.

bug: 7220345

Change-Id: Iad3bbef37cbe2e01613bb8a8c4886babdecb8328
2012-09-29 17:24:46 -07:00
Jeff Sharkey
7382f81fba Unmount external storage on multi-user devices.
Bug: 7044670
Change-Id: If1f99968b0392cae9420d067c75bfc18d1067b2c
2012-08-23 14:09:14 -07:00
Ken Sumrall
912d0b0755 Merge "Fix a typo in cryptfs.c" 2012-06-28 17:58:50 -07:00
Ken Sumrall
319369ac11 Fix a typo in cryptfs.c
Change-Id: If629fa996b135e432bc89da7518b0c1f02750b45
2012-06-27 16:30:18 -07:00
Nick Kralevich
4684e58a8d Add mode when open(O_CREAT) is used.
When creating a new file using open(..., O_CREAT), it is an error
to fail to specify a creation mode. If a mode is not specified, a
random stack provided value is used as the "mode".

This will become a compile error in a future Android change.

Change-Id: I761708c001247d7a2faac2e286288b45bfecc6f7
2012-06-26 15:07:03 -07:00
Ken Sumrall
425524dba1 Unmount all asec apps before encrypting
Now that forward locked apps are stored on /data as asec image files
that are mounted, they need to be unmounted before /data can be unmounted
so it can be encrypted.

Change-Id: I7c87deb52aaed21c8ad8ce8aceb7c15c2338620a
2012-06-15 14:46:53 -07:00
Ken Sumrall
e5032c42da Changes to encryption to work with the new filesystem manager
The new filesystem manager is in charge of mounting the block devices now,
removing much of the knowledge from init.<device>.rc.  This also let us
clean up some init code dealing with encryption, so this change updates
vold to work with that.  More cleanup is possible, but the main goal of the
filesystem manager was to enable e2fsck, not a full cleanup of encryption.

Change-Id: I00ea80a923d14770ed8fdd190e8840be195f8514
2012-05-01 13:14:55 -07:00
Ken Sumrall
f0679f0da4 Changes to encryption to work with the new filesystem manager
The new filesystem manager is in charge of mounting the block devices now,
removing much of the knowledge from init.<device>.rc.  This also let us
clean up some init code dealing with encryption, so this change updates
vold to work with that.  More cleanup is possible, but the main goal of the
filesystem manager was to enable e2fsck, not a full cleanup of encryption.

Change-Id: I00ea80a923d14770ed8fdd190e8840be195f8514
2012-04-27 16:44:22 -07:00
Ken Sumrall
d02a47239c Merge "Fix to not return a bogus decryption error when a device is not encrypted." 2012-03-09 17:02:44 -08:00
Mike Lockwood
ee6d8c42f3 Add support for wiping data immediately if crypt fails
Needed for headless devices that need to recover with no user intervention

Bug: 5556856

Change-Id: I0f85591df513a6893324fb057bde114ac1df044b
Signed-off-by: Mike Lockwood <lockwood@google.com>
2012-02-16 09:39:27 -08:00
Ken Sumrall
e1a4585784 Fix to not return a bogus decryption error when a device is not encrypted.
If there is filesystem damage on a non-encrypted device, and /data is not
mountable, and if the device stores the keys in a file on a different
partition (like on Crespo) then, vold would return an error which caused
the crypto UI to present an option to the user to wipe the device because
it assumed encryption had failed.  This fixes it to not do that.

Change-Id: Ibff6299787b45768416dbc4052de7db3b140b808
2011-12-14 22:33:45 -08:00