Commit Graph

1662 Commits

Author SHA1 Message Date
Randall Spangler
ada3fa9ee6 Misc TPM cleanup
Review URL: http://codereview.chromium.org/3010019
2010-07-20 15:35:49 -07:00
Gaurav Shah
553d00ec86 (In the right repository this time.)
Do not directly manipulate global structs. Work on the local copy instead.

In firmware-land, globals are a bad idea.

Review URL: http://codereview.chromium.org/3027011
2010-07-19 19:22:10 -07:00
Randall Spangler
ae029d9109 Fix checking boot flags in developer mode.
Should only check in recovery or normal modes.

BUG=http://code.google.com/p/chrome-os-partner/issues/detail?id=497

Review URL: http://codereview.chromium.org/2806058
2010-07-19 18:26:35 -07:00
Randall Spangler
87c13d806b Added size param to VerifyData()
Also renamed verify preamble functions, now that they do not need the
'2' at the end to differentiate them from the now-deleted original
implementation.

BUG=4501
TEST=Ran make runtests; all pass.

Review URL: http://codereview.chromium.org/3027009
2010-07-19 10:35:40 -07:00
Randall Spangler
3e1081fb71 Add lots of debugging to TPM library.
Temporarily disable TPM in developer mode.

Review URL: http://codereview.chromium.org/3041005
2010-07-19 10:04:21 -07:00
Gaurav Shah
aa92c63402 Fix SafeMemcmp by removing any potential data-dependent branches.
Credit: Nate Lawson of Root Labs

Review URL: http://codereview.chromium.org/2957014
2010-07-16 14:59:57 -07:00
vbendeb
b2b0fcc0f6 Introduce ability to change the kernel command line.
After this change vbutil_kernel allows to repack an existing
signed ChromeOS kernel such that the kernel command line is
changed on operator's request.

The new command line parameter is --verbose which causes
--verify to print out current contents of the kernel
command line.

Some refactoring and cleaning were also done:
 - provide a macro to access command line buffer inside
   a kernel blob
 - ReadConfigFile() a new wrapper to preprocess the
   config file.
 - keep the key_block and preamble in the blob when
   unpacking an existing signed kernel for --repack and
   --verify.
 - make --pack expect at least one of the two:
   --config or --keyblock, thus allowing to change the
   command line without replacing anything else in the
   signed kernel image.
 - refactor Verify() to use OldBlob() to preprocess the
   image.

The top level Makefile was changed to allow compiling for debugging.

Build with DEBUG=1 in the make command line to enable gdb debugging and debug printouts. Build with DISABLE_NDEBUG=1 in the make command line to enable cryptolib debug outputs.

BUG=http://code.google.com/p/chromium-os/issues/detail?id=4814

TEST=see below

1. Observe that all unit tests still pass by running

(vboot_reference $) RUNTESTS=1 make

2. On a working DVT system copy the running kernel into a
file using

dd if=/dev/sda2 of=/tmp/dev.kernel

and transfer the file to the host into /tmp/try/dev.kernel

Then create the new config file in /tmp/try/new.conf.txt and run the following commands:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
(vboot_reference $) ./build/utility/vbutil_kernel  --verify /tmp/try/dev.kernel  --signpubkey tests/devkeys/kernel_subkey.vbpubk --verbose
Key block:
  Size:                0x4b8
  Data key algorithm:  4 RSA2048 SHA256
  Data key version:    1
  Flags:               7
Preamble:
  Size:                0xfb48
  Header version:      2.0
  Kernel version:      1
  Body load address:   0x100000
  Body size:           0x302000
  Bootloader address:  0x3fe000
  Bootloader size:     0x4000
Body verification succeeded.
Config:
earlyprintk=serial,ttyS0,115200 console=ttyS0,115200 init=/sbin/init add_efi_memmap boot=local rootwait ro noresume noswap i915.modeset=1 loglevel=7 cros_secure root=/dev/sd%D%P dm_verity.error_behavior=2 dm_verity.max_bios=1024 dm="0 2097152 verity ROOT_DEV HASH_DEV 2097152 1 sha1 a7fbd641ba25488509987959d5756d802790ef8f" noinitrd

(vboot_reference $)   ./build/utility/vbutil_kernel  --repack /tmp/try/dev.kernel.repacked  --signprivate tests/devkeys/kernel_data_key.vbprivk  --oldblob /tmp/try/dev.kernel --config /tmp/try/new.conf.txt
(vboot_reference $)  ./build/utility/vbutil_kernel  --verify /tmp/try/dev.kernel.repacked  --signpubkey tests/devkeys/kernel_subkey.vbpubk --verbose
Key block:
  Size:                0x4b8
  Data key algorithm:  4 RSA2048 SHA256
  Data key version:    1
  Flags:               7
Preamble:
  Size:                0xfb48
  Header version:      2.0
  Kernel version:      1
  Body load address:   0x100000
  Body size:           0x302000
  Bootloader address:  0x3fe000
  Bootloader size:     0x4000
Body verification succeeded.
Config:
console=tty2 init=/sbin/init add_efi_memmap boot=local rootwait ro noresume noswap i915.modeset=1 loglevel=7 cros_secure root=/dev/sd%D%P dm_verity.error_behavior=2 dm_verity.max_bios=1024 dm="0 2097152 verity ROOT_DEV HASH_DEV 2097152 1 sha1 ff06384015a7726baff719ee68eab312b1d45570" noinitrd
(vboot_reference $)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Observe the chanegd command line printed by --verify --verbose. Then transfer the new kernel image back to the DVT system, dd it into /dev/sda2 and restart the DVT system.

Observe kernel startup messages dumped on the screen (due to the changed kernel command line).

Then examine /proc/cmdline to verify that the command line indeed matches the contents of /tmp/try/new.conf.txt on the host.

3. Build the code with

(vboot_reference$) DEBUG=1 make

 observe that debug information is visible by gdb.

  Build the code with

(vboot_reference$) DISABLE_DEBUG=1 make

and observe that  -DNDEBUG is dropped from the compiler invocation line.

Review URL: http://codereview.chromium.org/3004001
2010-07-15 15:09:47 -07:00
Gaurav Shah
536eaaaee7 Make re-signing script abort on error.
Review URL: http://codereview.chromium.org/2967011
2010-07-14 13:56:39 -07:00
Gaurav Shah
caa4789868 Add a script for standalone signing of Chrome OS images.
Also created a new directory in the vboot_reference source where all signing scripts and related miscellanea will go.

Review URL: http://codereview.chromium.org/2925011
2010-07-14 12:11:29 -07:00
Randall Spangler
39f66114c0 Add tpm lite to vboot reference
Review URL: http://codereview.chromium.org/2919010
2010-07-14 09:10:23 -07:00
Mandeep Singh Baines
64aec24de8 Make optional flag optional
Change-Id: I022a0bdf58b4884b0bc8c640b6b543e419743fd1

Review URL: http://codereview.chromium.org/2959005
2010-07-09 17:41:41 -07:00
Gaurav Shah
2abbc4b6fd Add an optional flag argument to load_kernel_test.
Review URL: http://codereview.chromium.org/2905006
2010-07-09 14:56:50 -07:00
Luigi Semenzato
18b814d9bc New targets to compile and install rollback tests only with USE=rbtest emerge ...
Review URL: http://codereview.chromium.org/2962002
2010-07-08 17:17:02 -07:00
Luigi Semenzato
8510d919f9 Replace TlclDefineSpace with SafeDefineSpace for extra paranoia.
Review URL: http://codereview.chromium.org/2937001
2010-07-08 15:40:30 -07:00
Randall Spangler
93bccfc452 Fix makefiles to work with ebuild
Review URL: http://codereview.chromium.org/2951002
2010-07-08 15:26:35 -07:00
Randall Spangler
6832511d3f Also need to disable calling make tests install.
Review URL: http://codereview.chromium.org/2913005
2010-07-08 15:15:53 -07:00
Randall Spangler
c9f917bfd0 Don't build rollback index test as part of 'all', since it depends on the real tlcl.
It'll still be built as part of 'make install'.

Review URL: http://codereview.chromium.org/2947002
2010-07-08 15:11:07 -07:00
Randall Spangler
7a786b73e7 added reboot return codes to load kernel and firmware
Review URL: http://codereview.chromium.org/2844044
2010-07-08 13:29:42 -07:00
Luigi Semenzato
416f681882 This test sets the TPM to a each of a large amount of "interesting" initial states, and runs the firmware code at user level.
This code compiles and installs using a modified ebuild (which needs to be committed after this change).

Review URL: http://codereview.chromium.org/2857030
2010-07-08 12:12:12 -07:00
Louis Yung-Chieh Lo
783e64e70e load_kernel_test tests the recovery image now (submit for Bill)
See original CL here: http://codereview.chromium.org/2803033/show

Review URL: http://codereview.chromium.org/2830038
2010-07-05 13:06:19 +08:00
Randall Spangler
ceef83f9e3 vbutil_firmware uses .vbprivk
Review URL: http://codereview.chromium.org/2812042
2010-07-02 13:14:42 -07:00
Bill Richardson
4a2093129f Add 'find' command to cgpt, to search for partitions by UUID.
Review URL: http://codereview.chromium.org/2849040
2010-07-02 11:34:38 -07:00
Luigi Semenzato
5e9c0b94b1 Never set bGlobalLock in recovery/dev mode. Don't try to fix bad kernel space.
Review URL: http://codereview.chromium.org/2804038
2010-07-02 10:36:37 -07:00
Bill Richardson
9396c1050d Adding new directory with developer signing keys.
The keys in this directory are just like the official release keys, except
that they're not secret.

Review URL: http://codereview.chromium.org/2883018
2010-07-01 15:51:05 -07:00
Bill Richardson
abf0550458 Switch to using .vbprivk for signing everything now.
This makes it much simpler to keep track of what we're doing.

vbutil_key can now wrap both .keyb and .pem keys. It figures out which is
which by trying both and just using the one that works.

vbutil_keyblock and vbutil_kernel now use .vbprivk files for signing.

replace debug() with VBDEBUG(()) in host-side sources, too.

rename PrivateKeyRead to PrivateKeyReadPem

Add real PrivateKeyRead and PrivateKeyWrite for .vbprivk files.

Review URL: http://codereview.chromium.org/2871033
2010-07-01 10:22:06 -07:00
Bill Richardson
a08b5c9d03 Adding --repack and --headeronly options to vbutil_kernel
The --repack option lets us sign a previously signed kernel blob with a new
kernel data key.

The --headeronly option is so we can emit the new verification header
separately from the kernel blob.

More work to come...

Review URL: http://codereview.chromium.org/2812034
2010-06-30 21:59:43 -07:00
Gaurav Shah
2a80e8a416 Make sure advertised signature data size is sane.
TEST=make runtests -- All the tests in the test suite pass.

Review URL: http://codereview.chromium.org/2849036
2010-06-30 18:26:21 -07:00
Gaurav Shah
bde9a64357 Fix name. Use existing directory check.
Review URL: http://codereview.chromium.org/2805051
2010-06-29 19:46:39 -07:00
Gaurav Shah
0ec7078d5b Rewrite gen_fuzz_test_cases.sh script to use new signing utilities.
TEST=Generated images verify successfully using right keys.

Review URL: http://codereview.chromium.org/2836036
2010-06-29 19:46:11 -07:00
Randall Spangler
c4a011a725 TBR: wfrichar
Fix LoadKernel() checking key block flags

BUG=none
TEST=none
2010-06-29 19:08:43 -07:00
Gaurav Shah
4d78d9a4fb Add a script to generate test vboot-format public keys.
Also add .vpubks for the existing test keys.

TEST=Ran the script.

Review URL: http://codereview.chromium.org/2873033
2010-06-29 17:29:18 -07:00
Luigi Semenzato
2b9ddae52b New rollback_index API.
Review URL: http://codereview.chromium.org/2869022
2010-06-28 13:34:31 -07:00
Will Drewry
46186faf46 utility: add a simple tool for dumping the kernel config
Adds dump_kernel_config.c which takes in a file, reads it
all in to memory, then walks the blob until it can determine
the location of the kernel command line.

This is needed to allow the kernel config to inform legacy bootloader
configuration during autoupdates without packaging up dm-verity specific
options in some additional update metadata.

TEST=manual run over build_kernel_image.sh output
BUG=chromium-os:327

Review URL: http://codereview.chromium.org/2811029
2010-06-25 13:40:43 -05:00
vbendeb
e548e85d3a Keep temp files in the output directory.
Also, make sure that the regenerated version gets
automatically added to the set of changed files.

Tested by rebuilding the tree and observing the
`git status' output.

Review URL: http://codereview.chromium.org/2809040
2010-06-24 17:24:01 -07:00
vbendeb
3ecaf776d8 Make vboot_reference build in MSVC command line environment.
This is a mostly NOOP change which modifies the source code
to compile cleanly in the MSVC command line build
environment.

A new makefile is introduced (msc/nmakefile) along with a
README.txt in the same directory explaining how to build
the code in the DOS window. As of this submission the build
is running in a 32 bit environment, the intention is to use
the same makefile for 64 bit builds in the future.

Enabling high compilation warnings level allowed to
identify a couple of bugs in the code which are being fixed.

Not all sources are being compiled in the MSVC environment,
only those in firmware/ and most of those in test/
subdirectories. The benchmark calculations require porting
of the timer facilities and are being postponed.

TEST

Built in DOS and linux environments. Ran unit tests in
linux environment.

Review URL: http://codereview.chromium.org/2809037
2010-06-24 16:19:53 -07:00
Randall Spangler
d6aad3a088 Ignore TPM return codes in recovery mode
Review URL: http://codereview.chromium.org/2844024
2010-06-24 14:01:34 -07:00
Luigi Semenzato
f6ddd64c3a Automated version generation for vboot firmware.
Review URL: http://codereview.chromium.org/2817025
2010-06-24 08:11:24 -07:00
Randall Spangler
d0d48b58a1 Add boot flags to LoadFirmware(), for TPM init
Review URL: http://codereview.chromium.org/2865015
2010-06-23 21:51:13 -07:00
Randall Spangler
e2ec98412e Add VBDEBUG macro for debug output.
Replaced in firmware/ lib; not replaced in host-side utils/tests.

Review URL: http://codereview.chromium.org/2810026
2010-06-23 21:17:07 -07:00
Randall Spangler
07f7865227 fix passing key out of LoadFirmware
Review URL: http://codereview.chromium.org/2825019
2010-06-23 19:42:09 -07:00
Randall Spangler
1078838fff Refactor rollback interface for LoadKernel(), LoadFirmware().
Review URL: http://codereview.chromium.org/2861020
2010-06-23 15:35:31 -07:00
Randall Spangler
1114b661f5 move biosincludes
Review URL: http://codereview.chromium.org/2809035
2010-06-23 13:02:43 -07:00
Randall Spangler
b9d60a52b7 Even more integration fixes.
Review URL: http://codereview.chromium.org/2849021
2010-06-23 12:43:01 -07:00
Bill Richardson
249677d0ad Add some debug output to vbutil_kernel, display values in hex.
Review URL: http://codereview.chromium.org/2859019
2010-06-23 11:16:37 -07:00
Randall Spangler
81d0996901 Assorted integration fixes.
MSVC does not like bitfields with extra bits in them, so it made the GptEntry struct too big.

Fixed a missing return value in LoadFirmware().

Added some debug output.

Fixed calls to SetupTPM().

Tested with 'make && make runtests'.  No errors.

Review URL: http://codereview.chromium.org/2865014
2010-06-23 10:15:38 -07:00
Luigi Semenzato
361049ce19 As mentioned, I discovered ForceClear doesn't really require any reboots. This change takes advantage of this fact.
Note that I am still using TPM_MUST_REBOOT because if power is lost between ForceClear and resetting the deactivated flag, the TPM will *really* be disabled at the next reboot, and it's nice to fix this problem automatically.

Review URL: http://codereview.chromium.org/2859016
2010-06-22 13:37:53 -07:00
Randall Spangler
d0dae7a438 More cleanup of MSVC errors
Review URL: http://codereview.chromium.org/2871019
2010-06-21 18:25:31 -07:00
Randall Spangler
beb5bae09f Fixes to compiler warnings in MSVC
Review URL: http://codereview.chromium.org/2851015
2010-06-21 16:33:26 -07:00
vbendeb
f7a45cc01d Reduce attributes size to comply with msc limitations.
It turned out that shared verified boot library fails to
work properly when compiled by msc in BIOS environment.

The culprit was identified as failing 64 bit logical
operations by preprocessor. It is probably possible to
come up with a certain compile flag set to fix the
operations, but it is not easy to modify and control the BIOS
compilation environment.

The alternative solution is to limit the size of the field
in question to 16 bits (especially since this is the only
part of the attributes field which is supposed to be
altered by firmware.

A union is being introduced in firmware/lib/cgptlib/include/gpt.h:GptEntry to allow
accessing the field both as a 64 bit entity and a top
16 bit field. All places where this field is used are
being modified appropriately.

tests/Makefile is being fixed to allow controlling test run
from the top level directory.

Tested by building everything and running tests.
All tests pass.

Review URL: http://codereview.chromium.org/2799019
2010-06-21 08:44:16 -07:00
vbendeb
6216f5abe9 Include BIOS specific definitions when required.
This is a noop for host/chroot environment. When compiling
in the firmware space the standard include files will not be
included, the definitions will be supplied by the BIOS,
through the new file (firmware/include/sysincludes.h).

Testing
=======

RUNTESTS=1 make

in the top level directory succeeds, confirming that the
tree compiles cleanly and the unit tests pass.

Review URL: http://codereview.chromium.org/2862019
2010-06-21 08:40:26 -07:00