Commit Graph

314 Commits

Author SHA1 Message Date
Kees Cook
b59d06e6e8 mount-encrypted: fix mount detection to use device
Instead of fsid, which is unpopulated for tmpfs, use device number
since that will increment for each different tmpfs.

BUG=chrome-os-partner:15192
TEST=parrot build, manual testing
BRANCH=none

Change-Id: I0024f7283c90684daaf1278d3cf6b76cc85bb253
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35615
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-10-16 11:26:39 -07:00
Kees Cook
adc6764229 mount-encrypted: handle missing TPM on Chrome OS
While not having a TPM was supported for non-Chrome devices, it was not
expected for Chrome devices. This adds logic to fail the TPM calls
before making them when the TPM is missing. The tpm_lite library doesn't
handle the TPM being missing, so we have to do this ourselves.

BUG=chrome-os-partner:15192
TEST=parrot build, verified operation after "mv /dev/tpm0 /dev/tpm0.bak"
BRANCH=none

Change-Id: I2f625305dce7fa698fcad33e412ee37c60da9bc2
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35440
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
2012-10-12 14:24:42 -07:00
Bill Richardson
788dbc34b0 Allow vbutil_what_keys to examine shellballs too
Currently vbutil_what_keys only displays the kernel keyblock info for disk
images. This adds a -v option (requiring sudo) to cause it to attempt to look
inside any rootfs partitions and extract the BIOS image from the shellball.

This CL also updates the list of known sha1sums.

Without -v:

  vbutil_what_keys recovery_image.bin
  IMAGE: recovery_image.bin
    part 2 kernel:   49d40533b0812d3f31232c5eedd47e7e11acc293 (!DEV DEV REC)
    part 4 kernel:   cc887372ac2d1c415eac93fc11e753629c387358 (!DEV DEV !REC)

With -v:

  vbutil_what_keys -v recovery_image.bin
  IMAGE: recovery_image.bin
    part 2 kernel:   49d40533b0812d3f31232c5eedd47e7e11acc293 (!DEV DEV REC)
    part 4 kernel:   cc887372ac2d1c415eac93fc11e753629c387358 (!DEV DEV !REC)
    part 3 shellball:
      hwid:          X86 LUMPY TEST 6638
      recovery key:  0d800afb53cdd05dd849addee0143ca1d96e893c
      root key:      4e92f07efd4a920c4e4f1ed97cf47b7b04ee1428

BUG=none
BRANCH=none
TEST=manual

This is an optional feature to a debugging utility. You can try the examples
above if you feel like testing it yourself.

Change-Id: Ie0dc918c1a99705c408314e960f4dc98aee7c1a9
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34537
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-10-03 14:37:55 -07:00
Stefan Reinauer
a2326ee152 Add CTRL-L in dev screen to support a "legacy boot option"
This option is disabled per default and can be enabled with
crossystem dev_boot_legacy=1
or by setting the GBB flag
GBB_FLAG_FORCE_DEV_BOOT_LEGACY      0x00000080

BUG=chrome-os-partner:6108
TEST=crossystem dev_boot_legacy=1
     boot to dev mode screen, press CTRL-L, see SeaBIOS start
     (other CLs needed)
BRANCH=link
Signed-off-by: Stefan Reinauer <reinauer@chromium.org>

Change-Id: I593d2be7cff5ca07b8d08012c4514a172bd75a38
Reviewed-on: https://gerrit.chromium.org/gerrit/31265
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
2012-09-20 17:32:22 -07:00
Hung-Te Lin
b4b324a8b4 utility: Add "enable_dev_usb_boot".
A shortcut and easier way to enable USB booting without always calling the huge
firmware updater.

BRANCH=none
BUG=none
TEST=./enable_dev_usb_boot # successfully set dev_usb_boot value.

Change-Id: I9ebb3ce79ef58bc0a32926866d5e1827a92b6e74
Reviewed-on: https://gerrit.chromium.org/gerrit/33046
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
2012-09-12 20:39:46 -07:00
Vincent Palatin
56c85db710 Allow vbutil_kernel to work on block devices
Block devices return a size of 0 when stat'ed.
In order to be able to verify directly a raw partition, let's add a
special case to query the block device size.

BUG=chromium-os:34176
TEST="vbutil_kernel --verify /dev/sda4 --verbose" shows the actual
content not an error message.
BRANCH=none

Change-Id: Ibecf0a88816abf97305f0f87c0131ba7b66e386c
Reviewed-on: https://gerrit.chromium.org/gerrit/32302
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Jon Salz <jsalz@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-06 17:32:38 -07:00
Kees Cook
fe4ad9f992 mount-encrypted: mount with commit=600
Mount with commit=600, just as the unencrypted stateful is mounted.

BUG=chrome-os-partner:13185
TEST=x86-alex build

Change-Id: I0cee85c8bdabccb6545ca2238f6d5a120300e3aa
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/31762
Commit-Ready: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2012-08-31 15:41:45 -07:00
Bill Richardson
9dc62178c9 Add VB_INIT_FLAG_SW_WP_ENABLED to VbInit() input flags.
We need to know not only whether the HW WP pin is asserted, but whether the
flash chip has configured its software protection registers to actually
protect anything. This flag can be used to indicate that.

BUG=chrome-os-partner:13265
BRANCH=link
TEST=none

This just adds the flag. Nothing actually sets the flag yet, so there's
nothing to test.

Change-Id: Icba9945fb56eb3a4681486c630cbbdc9232485ef
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/31642
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-08-28 16:39:33 -07:00
Gaurav Shah
1d053f6e23 vbutil_keyblock: Fix argument to PrivateKeyReadPem()
If the --signprivate_pem option is used to vbutil_keyblock and without
an external signer, we were passing the wrong name to PrivateKeyReadPem()
causing all such invocations to fail. This CL fixes the typo.

(This particular path isn't current being used.)

BUG=none
TEST=manually verified with --signprivatekey_pem but without --external_signer.
BRANCH=none

Change-Id: I56df76a965706f654df1de8ac6e42738c15284c7
Reviewed-on: https://gerrit.chromium.org/gerrit/31556
Commit-Ready: Gaurav Shah <gauravsh@chromium.org>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Tested-by: Gaurav Shah <gauravsh@chromium.org>
2012-08-28 09:58:50 -07:00
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
Bill Richardson
ae98bf0572 Improved pretty-print for dump_fmap, with gap detection
BUG=none
BRANCH=none
TEST=manual

Use it to dump the FMAP from a firmware image:

  dump_fmap -h /build/link/firmware/image-link.bin

Change-Id: I94fb9396ea886b072845fadef6ef1e1e2ff85a59
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/30784
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-08-17 17:30:06 -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
Randall Spangler
29e8807ea0 Add clear TPM owner request
This adds two new flags to crossystem:
   clear_tpm_owner_request
   clear_tpm_owner_done

The first one requests that the firmware clear the TPM owner on the
next boot.  When the firmware does this, it will set
clear_tpm_owner_request=0, and set clear_tpm_owner_done=1.  The OS can
use the done-flag as a hint that trusted things guarded by the TPM are
no longer trustable.

BUG=chromium-os:31974
TEST=manual

crossystem
  // both flags initially 0
crossystem clear_tpm_owner_request=1
crossystem clear_tpm_owner_done=1
  // request=1, done=0; done can be cleared but not set by crossystem
reboot
tpmc getownership
  // owned=no
crossystem
  // request=0, done=1
crossystem clear_tpm_owner_done=0
crossystem
  // both flags 0 again

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I49f83f3c39c3efc3945116c51a241d255c2e42cd
Reviewed-on: https://gerrit.chromium.org/gerrit/25646
2012-08-15 14:31:53 -07:00
Bernie Thompson
8057d1bf48 Add in Kiev FW keys to vbutil_what_keys
BUG=chrome-os-partner:12544
TEST=Manual, verify vbutil_what_keys detects properly on Kiev.

Change-Id: I4115b80e56784bbd5177e142a936ce52132fcf7f
Reviewed-on: https://gerrit.chromium.org/gerrit/29944
Reviewed-by: Dave Parker <dparker@chromium.org>
Commit-Ready: Bernie Thompson <bhthompson@chromium.org>
Tested-by: Bernie Thompson <bhthompson@chromium.org>
2012-08-10 19:45:27 -07:00
Hung-Te Lin
64a2aff962 bmplk_utility: Libraries should be in end of build command.
Libraries (-llzma, -lyaml) should be in end of dependency list, otherwise
linking in static mode (-static) would fail.

BUG=none
TEST=emerge vboot_reference

Change-Id: Idd072443d042edfb214f5a958abd064bc18573ed
Reviewed-on: https://gerrit.chromium.org/gerrit/29738
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
2012-08-09 19:18:21 -07:00
Dave Parker
3985f94fae Increase max number of bitmaps to composite to 16 per screen.
This is needed to render new-style screens that use 13 bitmaps.
bmpblk version is changed from 1.2 to 2.0, due to incompatibility.

BUG=chrome-os-partner:11078
TEST=emerge-<board> vboot-reference. Run firmware with new bmpblock.

Original-Change-Id: I750da66b020fe195896df58f31fcbb2a9e33e404
Reviewed-on: https://gerrit.chromium.org/gerrit/28945
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Dave Parker <dparker@chromium.org>
(cherry picked from commit 0b7ee46c2eeba858ff59d534e265b445895623a2)

Change-Id: I80543c46a7c0e09169e29e32077d84c57192e431
Reviewed-on: https://gerrit.chromium.org/gerrit/29602
Reviewed-by: Dave Parker <dparker@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
2012-08-09 01:56:44 -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
f9dc39023c mount-encrypted: allow stateful mount check to pass factory install
When factory install happens, mount-encrypted is running on a tmpfs,
which can be detected via a W_OK check on the root filesystem.

BUG=chrome-os-partner:12033
TEST=alex build, manual test

Change-Id: I7bf5eaa244a50dd2a0de51760c964e970fa8e3aa
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28960
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
2012-08-01 14:00:08 -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
Lucian Cojocar
2312ab6122 vbutil_kernel: gracefully exit if the config file is bad
If the config file is specified in the parameter list but we aren't able
to open (or read) the file, vbutil_kernel should return an error instead
of crashing with a Segmentation Fault.

BUG=chromium-os:33087
TEST=manual

Invoke vbutil_kernel with a bogus path for the config file (--config).

Change-Id: I32dab7c381b9094f4015a554bc59989f1bb329ef
Signed-off-by: Lucian Cojocar <cojocar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28740
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-31 12:34:11 -07:00
Bill Richardson
9429f8807a Add human-readable output option to dump_fmap
The '-h' option will display the FMAP in a heirarchical nested format.

BUG=none
TEST=manual

$ dump_fmap -h stumpy_bios.bin

SI_BIOS                00180000   00800000   680000
  RO_SECTION            0670000    0800000   190000
    BOOT_STUB            700000     800000   100000
    GBB                  680000     700000    80000
    RO_PADDING           670840     680000     f7c0
    RO_FRID              670800     670840       40
    FMAP                 670000     670800      800
  RO_UNUSED_2           0590000    0670000    e0000
  RO_VPD                0570000    0590000    20000
  RO_UNUSED_1           0400000    0570000   170000
  RW_SECTION_B          0300000    0400000   100000
    RW_FWID_B            3fffc0     400000       40
    FW_MAIN_B            310000     3fffc0    effc0
    VBLOCK_B             300000     310000    10000
  RW_SECTION_A          0200000    0300000   100000
    RW_FWID_A            2fffc0     300000       40
    FW_MAIN_A            210000     2fffc0    effc0
    VBLOCK_A             200000     210000    10000
  RW_SHARED             01e8000    0200000    18000
    DEV_CFG              1fc000     200000     4000
    RW_MRC_CACHE         1ec000     1fc000    10000
    RW_ENVIRONMENT       1e8000     1ec000     4000
  RW_UNUSED             0181000    01e8000    67000
  RW_VPD                0180000    0181000     1000
SI_ALL                 00000000   00180000   180000
  SI_ME                 0001000    0180000   17f000
  SI_DESC               0000000    0001000     1000

Change-Id: I41672b62528dac32663bc300ff013e8003d3efa8
Reviewed-on: https://gerrit.chromium.org/gerrit/28513
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-26 16:25:34 -07:00
Hung-Te Lin
6008fb4d31 utility: Change autoupdate toolkits to statically linked.
Utilities shared by auto update programs (ex, firmware updater) must be
statically linked.

BUG=chrome-os-partner:11630
TEST=emerge-link vboot_reference

Change-Id: I74f7ad9f365005624f55cc3fcfc8dc31de0d69c2
Reviewed-on: https://gerrit.chromium.org/gerrit/28365
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
2012-07-25 04:16:46 -07:00
Kees Cook
262cef37e6 mount-encrypted: improve ancient Cr48 install detection
If a Cr48 was upgraded from pre-R12, it will lack an NVRAM lockbox area
with no way to create one (TPM password has been thrown away already).
Detect this case and allow fallback to the other system key methods. If
it is a Cr48 running a modern OOBE, treat it like any other device and
require a modern NVRAM lockbox area.

BUG=chromium-os:32766
TEST=mario build, verified OOBE doesn't repeat, simulated pre-R12 uses UUID.

Change-Id: I2acf7ad8c5d16b1f314ba16c673fa3979a40f3de
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28231
Reviewed-by: Elly Jones <ellyjones@chromium.org>
2012-07-24 17:02:23 -07:00
Vic Yang
8a301be7e9 This is failing EC unit test and blocking CQ. Since I can get to Randall and Hung-Te, revert now to unblock others.
Revert "vboot_reference: Change EC signing to apply new FMAP areas."

This reverts commit ef0ab3a616acc0d8d18d45c3145852f38744b856

Change-Id: I9248b76c0896190ac6febac9d8239a709554b1ee
Reviewed-on: https://gerrit.chromium.org/gerrit/28107
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2012-07-20 18:54:46 -07:00
Hung-Te Lin
b15fc814bd vboot_reference: Change EC signing to apply new FMAP areas.
EC FMAP has changed its section names because B partition has been removed. The
signing tool should now use area names "FW_MAIN" and "VBLOCK".

BUG=chrome-os-partner:11360
TEST=emerge-link vboot_reference

Change-Id: I41ff17257b5e2c8a0f4adb11088e121f94e93923
Reviewed-on: https://gerrit.chromium.org/gerrit/27970
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Randall Spangler <rspangler@chromium.org>
2012-07-20 11:42:54 -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
0c66fee704 mount-encrypted: support static key factory mode
For factory images, we want to be able to retain /var across reboots
without interacting with the TPM, and ultimately hold the test suite
in a pre-built image so we can avoid needing to wipe the entire
filesystem when switching modes.

BUG=chrome-os-partner:11392, chrome-os-partner:9419
TEST=link build, manual testing

Change-Id: I58aab24455670697e3df494632d5105dde75ee85
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27793
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Reviewed-by: Jon Salz <jsalz@chromium.org>
2012-07-18 23:30:02 -07:00
Randall Spangler
33575a8892 Keep vbutil_ec from dying if EC firmware B isn't present
BUG=chrome-os-partner:11451
TEST=build bds firmware with ifdef CONFIG_FW_B removed from config.h

Change-Id: I74ef0258988e065f602e4564e3b49903b34013c5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27655
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-17 13:11:44 -07:00
Tom Wai-Hong Tam
d808a43d35 crossystem: Add the ddr_type field on crossystem for querying DDR RAM type
Samsung want to know what memory type on the device. So this CL adds a
new field ddr_type to crossystem utility in order to query this info.

It is only available on ARM platform so far.

BUG=chrome-os-partner:10857
TEST=Built and boot on Snow successfuly. On userspace, query the field via:
localhost ~ # crossystem ddr_type
ddr3

Change-Id: I01d1dec412fe4052e1ea6cfe2e53830da97a710b
Signed-off-by: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26411
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-07-02 06:19:39 -07:00
Bill Richardson
17b8224ea5 Add bits to request and acknowledge Option ROM loading.
For fastest boot, we don't want to load the VGA Option ROM every time, but
only when we need it. Coreboot does that loading, but it can't always know
when it's needed (with keyboard-based dev-mode, coreboot can't tell if we're
in dev-mode or not). By the time we get to U-Boot, it's too late, so we need
two extra bits - one for vboot to tell coreboot to load the Option ROM and
another for coreboot to let vboot know it's been done.

BUG=chrome-os-partner:8789
TEST=manual

The only visible change is that crossystem will now have an "oprom_needed"
flag that can be set or cleared. Nothing actually pays attention to it yet,
though.

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I521a6afdfb8ea17a8148b32eeb858844c981de9c
Reviewed-on: https://gerrit.chromium.org/gerrit/26272
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-27 17:40:40 -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
Mike Frysinger
d7f8f3574c respect LDFLAGS settings
Libraries go into $LDLIBS while linker flags go into $LDFLAGS.

Also make sure the utility subdir respects the env $LDFLAGS so that
we can do things like `make LDFLAGS=-static` and get static binaries.

BUG=None
TEST=`emerge vboot_reference` still works
TEST=`emerge-arm-generic vboot_reference` still works

Change-Id: I989a21bc559bc6d471bc33c057c708bda2eda67e
Reviewed-on: https://gerrit.chromium.org/gerrit/24728
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-06-18 18:15:38 -07:00
Mike Frysinger
121f3db2d5 respect pkg-config env settings
Rather than use the host's pkg-config, we want to use the target's.
This way we query the right .pc files.

BUG=None
TEST=`emerge vboot_reference` still works
TEST=`emerge-arm-generic vboot_reference` still works

Change-Id: I083a987ee6c23716f8d79eb14e7c38c12e18b8f8
Reviewed-on: https://gerrit.chromium.org/gerrit/24727
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-06-18 17:14:53 -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
8b6da26a6e tlcl: add GetOwner command
Since the "ownership" permament flag does not indicate if the TPM is
currently owned, the state of TPM Ownership must be read via a Capability
read of TPM_CAP_PROP_OWNER. This adds the "getownership" function.

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

Change-Id: I2fc9e933e891ba40190d008436b22496dced1c93
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24784
Reviewed-by: Will Drewry <wad@chromium.org>
2012-06-13 14:22:12 -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
Bill Richardson
35d0733626 Add DISABLE_DEV_REQUEST flag to nvram.
This just creates the bit. It doesn't actually do anything yet.

BUG=chrome-os-partner:9980
TEST=manual

  crossystem disable_dev_request=1
  crossystem
  crossystem disable_dev_request=0
  crossystem

Change-Id: I0e92a6b5ef5074ee5eae2d6d469c1c9826faecb3
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/23752
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-05-25 16:05:22 -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
Bill Richardson
7153516212 Make vbutil_ec operate on the entire image at once.
Instead of taking images apart, signing bits, and reassembling them, this
just operates on the entire image at once. The image can be built without
regard to the signing process, and then the signing can be done in one step
afterwards.

BUG=chrome-os-partner:7459
TEST=none

No test at the moment, since we don't have the rest of the vboot stuff
working yet.

Change-Id: Icbde9cbb89d0ef85c0f6b8ac0637e0a51a894199
Reviewed-on: https://gerrit.chromium.org/gerrit/22116
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
2012-05-08 15:06:24 -07:00
Bill Richardson
2448d3b3bc Create vbutil_ec tool for signing EC firmware.
This just adds the vbutil_ec tool (and a simple test of the library
functions related to it).

BUG=chrome-os-partner:7459, chromium-os:27142
TEST=manual

  make
  make runtests

Change-Id: I2a2c4e7cfb8ac6ce2229c5de4252a5cc89321fa5
Reviewed-on: https://gerrit.chromium.org/gerrit/21868
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2012-05-04 12:16:45 -07:00
Bill Richardson
f47291926a Require -Wall -Werror for everything.
BUG=none
TEST=none

Change-Id: Ib9781238274285f73d00d8fca4ecda28fc2c6678
Reviewed-on: https://gerrit.chromium.org/gerrit/21748
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2012-05-03 17:38:57 -07:00
Che-Liang Chiou
916cf1e977 Omit body load address check
Omit this check because this check is not really necessary and it is
dealing more harms than goods to ARM boards.

While body load address is configurable, it is not quite possible to fix
all the build scripts and runtime scripts to carry this address; so in
reality all scripts use the default body load address.

The problem is, this default address is not friendly to ARM boards, and
it virtually makes this check fails on ARM boards.

BUG=chromium-os:28077
TEST=emerge-{daisy,x86-alex} vboot_reference
TEST=load_kernel_test -b 1 chromiumos_image.bin
TEST=run verified boot on Daisy

Change-Id: I1a1cc0aedf254e2a2b680046812ab7154f26dea7
Reviewed-on: https://gerrit.chromium.org/gerrit/20947
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Che-Liang Chiou <clchiou@chromium.org>
2012-04-24 23:38:31 -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
Che-Liang Chiou
036922ed8a Read kernel body load address from preamble by default
The default behavior of dump_kernel_config is changed from using
CROS_32BIT_ENTRY_ADDR to reading from kernel preamble.  The main
motivation for this change is in preparation for ARM boards of which
kernel body load address cannot be CROS_32BIT_ENTRY_ADDR.  Since we do
not want that all ARM calling sides of dump_kernel_config have to carry
the kloadaddr argument, it would be better to let dump_kernel_config
read this address from the kernel preamble by default.

BUG=chromium-os:28077
TEST=Run dump_kernel_config w/ and w/o this change

Change-Id: I5eddcc35e5970dfce02cc66208438c57351f1c81
Reviewed-on: https://gerrit.chromium.org/gerrit/19660
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Che-Liang Chiou <clchiou@chromium.org>
2012-04-06 04:08:54 -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
Bill Richardson
72e344d5cd Major refactoring of vbutil_kernel
This started out as a simple fix for a minor bug and turned into a nearly
complete rewrite. Now that it's done I'm not sure it really matters. This
version is a lot cleaner about handling command-line args, but isn't
otherwise noticeably better. Sigh.

BUG=none
TEST=manual

make
make runtests

Change-Id: I9c194e9c0e6418488635989ef666bc83c6e39816
Reviewed-on: https://gerrit.chromium.org/gerrit/18268
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-03-20 10:26:44 -07:00
Bill Richardson
bde0696234 Make vbutil_kernel use correct size when verifying headers.
Added a test to demonstrate the fix.

BUG=none
TEST=manual

make
make runtests

Change-Id: I06e85b993cbe21088641a62d55a3d3ddb696ba76
Reviewed-on: https://gerrit.chromium.org/gerrit/18240
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-03-15 12:00:24 -07:00
Bill Richardson
c8b9ca6856 Rename some static struct members in vbutil_kernel.
I've found a bug in vbutil_kernel, but the names of some of the internal
variables and struct members make it hard to follow (which is probably why
the bug exists). Before I fix it, I need to rename some things so we can see
what's wrong. This does that.

BUG=none (yet)
TEST=manual

make
make runtests

Change-Id: I8646c8acd33c58ccd52668943bcee4d0664716aa
Reviewed-on: https://gerrit.chromium.org/gerrit/18146
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-03-14 17:40:06 -07:00
Bill Richardson
e7e8ecd3e2 Specify the sections you want dump_fmap to dump, if not all
BUG=none
TEST=manual

Compare

  dump_fmap -f bios.bin

with

  dump_fmap -f bios.bin FW_MAIN_A FW_MAIN_B GBB

Change-Id: Id567113ab5e7121422b89f00d9eb8c0b27942259
Reviewed-on: https://gerrit.chromium.org/gerrit/17179
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
2012-03-02 09:44:30 -08:00