Commit Graph

12 Commits

Author SHA1 Message Date
Kees Cook
9b98929ec1 mount-encrypted: explicitly use uint64_t for sizes
On very large HDDs, the sector count was wrapping around. Switch most
calculations to bytes using uint64_t, and use BLKGETSIZE64 for checking
the loopback device size.

BUG=chrome-os-partner:12705
TEST=parrot build, manual testing
STATUS=Fixed

Change-Id: I1f7aea81151ed5cc130b1f6a05fda83f7a85150f
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/31073
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-08-22 08:43:11 -07:00
Kees Cook
7c118da2d6 mount-encrypted: calculate inode ratio based on final size
mkfs.ext4 does not use the resize= hint for calculating inode ratios.
This means very tiny initial filesystems will not get enough inodes
once it has been resized. This calculates the desired inode ratio based
on the expected final size of the filesystem.

BUG=chrome-os-partner:12678
TEST=lumpy build, manual testing
STATUS=Fixed

Change-Id: I216aaaa6e0ef50e82265ee46ecac5a65bb077387
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/30579
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
2012-08-16 17:40:48 -07:00
Kees Cook
02add5f433 mount-encrypted: write key to disk initially
The encrypted partition has been plagued with TPM problems, which means
systems that have a wedged TPM, or interrupt the TPM Ownership, Lockbox
creation, etc, all fail to keep the encrypted partition across a reboot.
As a result, we're forced to write the encryption key to disk initially,
and then throw it away once the system key from NVRAM can be used to
encrypt it.

On most systems that have a sane unowned TPM, the key will only be on
disk until the first login finishes and Cryptohome can Finalize the
NVRAM area. For all the other systems, they will continue to run, but
with their encryption key effectively in the clear. Technically, this
is not a regression from R21, so at least we can move forward and work
to improve this in the future.

Some attempt is made to wipe out the key, but this is especially ugly for
SSDs, since doing a "shred" just means the blocks will get moved around.
When ext4 supports "secure delete", we can move to that instead.

BUG=chromium-os:32951
TEST=alex build, manual testing

Change-Id: I9b9a0190ea0f47a277a150eb0882e4a507ff2927
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29123
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
2012-08-06 13:55:16 -07:00
Kees Cook
a8fae24b25 mount-encrypted: fix some minor security TODOs
Force mode of created key file to 0600, and make sure there is enough
room in the decryption buffer for any possible change to the decryption
algo.

BUG=None
TEST=alex build, manual testing

Change-Id: I89dceec22683ff66b5e1f61a63f14a1db1c4e2ee
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28892
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-08-01 10:57:46 -07:00
Kees Cook
7b20efdc4a mount-encrypted: handle lack of dm-crypt "allow_discard"
On kernels prior to 3.1, the "allow_discard" option does not exist.
Allow for this by attempting to set up the table twice if the
allow_discard attempt fails.

BUG=chrome-os-partner:11529
TEST=link build, boots 3.2 ok, falls back when option is invalid.

Change-Id: I904d3770543ebdeb0eace9ffa8e6c654cf97976d
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28024
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-07-20 11:42:52 -07:00
Kees Cook
6a312261fd mount-encrypted: use minimum mkfs size on migration
When doing a migration, try to guess at a smaller minimum size for the
initial filesystem so that systems with giant drives are not needlessly
penalized. Start with an even smaller initial filesystem size (16M).

Move debug time counters into the main .o file to avoid compiler
insanity when turning debug on and off.

BUG=chromium-os:22172
TEST=link build & boot, manual testing

Change-Id: I47c3ffb6e4cd88c4f0ead6fa21724704c7ed1630
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25638
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-06-20 14:08:24 -07:00
Kees Cook
3dae2288bb mount-encrypted: use correct ownership test
Check for ownership via Capabilities instead of Perm Flags. Clean up
missing "static" declarations, disable DEBUG-by-default, clean up spawner
reporting, explicitly check TPM_SUCCESS for Tlcl calls and document.

BUG=chromium-os:22172
TEST=x86-alex build & manual test

Change-Id: Ida6813307b7dfcecb8fb2e240ff88982db5430c5
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25053
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
2012-06-14 14:41:53 -07:00
Kees Cook
655cc112b4 mount-encrypted: allow dynamic root directory
When testing mount-encrypted, allow for the "MOUNT_ENCRYPTED_ROOT"
environment variable to define the root directory of all the internal
mount paths. By default, it remains "/". This changes all the formerly
static globals to dynamic.

Add support for environment variable "MOUNT_ENCRYPTED_FSCK" which
causes a fsck during the "umount" phase.

Improve loopback name handling and add debugging.

Rename "device" command to "info", add path details.

BUG=chromium-os:22172
TEST=x86-alex build, manual testing

Change-Id: Icf89a0a5283d38e098fa8e1d92a84b1cccacb4db
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/23580
Reviewed-by: Will Drewry <wad@chromium.org>
2012-06-07 14:00:14 -07:00
Kees Cook
e97760cec3 mount-encrypted: provide umount option for shutdown
When shutting the system down, mount-encrypted can be used to clean up
all its bind mounts and devices.

BUG=None
TEST=x86-alex build, manual testing

Change-Id: I025ce8c16c55f8556d7fff45eb6ac2b7a835101a
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/21913
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-05-17 13:32:27 -07:00
Kees Cook
beb3be1c0b mount-encrypted: handle migration better
Fix migration of mounts that are over-mounted.

BUG=chromium-os:22172
TEST=lumpy build & manual testing

Change-Id: I005edc6fe789a3e0585ffdcaa45ef5a136318ee3
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/19673
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-04-17 14:44:20 -07:00
Kees Cook
f9e82e9695 mount-encrypted: close TPM when spawning resizer
When the filesystem resizing process starts, it has the TPM open,
which means it can collide with tcsd after the main process exits.
Additionally, improve the debugging around TPM usage for better timing
analysis.

BUG=None
TEST=lumpy build & manual testing

Change-Id: I7028131015fb972c99e8b3d035f58346f08fbd06
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/19535
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-04-05 13:27:17 -07:00
Kees Cook
498977af89 mount-encrypted: add encrypted mount helper
This adds the utility needed to mount the encrypted partition at boot
time, as defined by the design document:
https://docs.google.com/a/google.com/document/d/1VQTDXvNsEFcrUOmNC4OmCfJst49Pd_mxZ41nfKu5EPc/edit
This still needs Cryptohome support and chromeos_startup to switch to
using it.

BUG=chromium-os:22172
TEST=lumpy build & manual testing

Change-Id: Ib9f0b4e5ba1a8aeb4737d0c8ec72a8e0dee049da
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/16889
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-04-04 12:47:23 -07:00