Commit Graph

370 Commits

Author SHA1 Message Date
Bill Richardson
60563ee0af Always treat invalid images as nonexistant now.
This makes the sequence of pictures shown to the user slightly less
confusing, but the whole process needs a bit more cleanup. Some of the work
has to be done in the BIOS code, not just here. This is better, but it's not
complete.

Change-Id: If0b3ecc92716020a06031866849d83411d7f0db8

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

Review URL: http://codereview.chromium.org/3249009
2010-08-30 15:15:38 -07:00
Gaurav Shah
2447dd256f Add a PCR extend call for measuring the dev mode boot flag.
BUG=2083
TEST=manual

Compiled with DISABLE_ROLLBACK unset. I need help testing this change - in particular, if the PCR 0 value is actually different in dev mode off vs. dev mode on. This can be done by invoking 'tpm_pcrread -p 0' at the shell. tpm_pcrread is part of the tpm_tools package.

Change-Id: I0728fb776a0c9cb90d885e7a1c76ff6a1a41a17b

Review URL: http://codereview.chromium.org/3195018
2010-08-30 11:43:57 -07:00
Gaurav Shah
9379a7d759 Use SafeMemcmp() in RSAVerify() just to be safe.
BUG=chrome-os-partner:832
TEST=make && make runtests

Change-Id: I370021071b2b219c0db89cfaa015f4ff315c9204

Review URL: http://codereview.chromium.org/3216010
2010-08-30 11:41:01 -07:00
Luigi Semenzato
1d83dd1ba5 Add a command to enable the physical presence command.
Change-Id: Id8b6ac3c75d1ee34237cde8adde55cea33b25889

Review URL: http://codereview.chromium.org/3163045
2010-08-30 10:23:43 -07:00
Bill Richardson
09021d0d6c Remove finger from RecoveryBmp image, change text accordingly
Change-Id: I9ce9dd679fb55a733f5c852ff9275089a633fe7f

Review URL: http://codereview.chromium.org/3272001
2010-08-27 09:47:37 -07:00
Bill Richardson
aa8eda4f97 More cgptlib tests
Add some extra cases to SanityCheckTest() to test both header and entries
being garbled at either end of the disk.

Add DuplicateUniqueGuidTest() to check that GPTs having duplicate
UniqueGuids in the entries are rejected. We can only check this per-disk, of
course.

Made some changes to the library to enforce the UniqueGuid requirement that
I just started testing for.

BUG=chromium-os:4854

Review URL: http://codereview.chromium.org/3135044

Change-Id: I86458faf9cc99aa3f29aac0d5b144dbd05067181
2010-08-27 09:31:26 -07:00
Luigi Semenzato
5896b9664d Added new commands and reactivated full rebuild after fixing for ARM ebuild.
Review URL: http://codereview.chromium.org/3116025

Change-Id: Ideb82562f6b1c3ce5cd9e0b79de250d0a7bd976e
2010-08-25 07:16:03 -07:00
Randall Spangler
41656c082d Fix utility.c to compile on MSVC.
BUG=none
TEST=make && make runtests

Review URL: http://codereview.chromium.org/3186024
2010-08-23 13:20:07 -07:00
Che-Liang Chiou
475bf447cc Add fake e820 memory map entries to zeropage
BUG=chromium-os:4521
TEST=manual

This patch set adds two e820 memory map entries to kernel's zeropage to
trick kernel into booting; otherwise kernel will choke on missing e820
memory map.

The added e820 memory map entries should let kernel boot and should not
make the memory map differ from that without the added entries.

Test Procedure:
1. Boot your test machine and save dmesg output, referred to as LOG1.
2. Apply the following one-line patch and then compile and install
   kernel.
3. Apply this patch set and re-build zeropage on kernel partition.
4. Boot the test machine and save dmesg output, referred to as LOG2.

LOG1 would contain the following messages (the exactly addresses of
memory map should differ slightly).
...
[    0.000000] BIOS-provided physical RAM map:
[    0.000000] bootconsole [earlyser0] enabled
...
[    0.000000] modified physical RAM map:
[    0.000000]  modified: 0000000000000000 - 0000000000002000 (usable)
[    0.000000]  modified: 0000000000002000 - 0000000000006000 (reserved)
[    0.000000]  modified: 0000000000006000 - 000000000008f000 (usable)
[    0.000000]  modified: 000000000008f000 - 0000000000090000 (ACPI NVS)
[    0.000000]  modified: 0000000000090000 - 00000000000a0000 (usable)
[    0.000000]  modified: 0000000000100000 - 0000000000f00000 (usable)
[    0.000000]  modified: 0000000001000000 - 000000003f33f000 (usable)
[    0.000000]  modified: 000000003f33f000 - 000000003f4bf000 (reserved)
[    0.000000]  modified: 000000003f4bf000 - 000000003f5bf000 (ACPI NVS)
[    0.000000]  modified: 000000003f5bf000 - 000000003f5f7000 (ACPI data)
[    0.000000]  modified: 000000003f5f7000 - 000000003f600000 (usable)
[    0.000000]  modified: 00000000fed1c000 - 00000000fed20000 (reserved)
[    0.000000]  modified: 00000000ffc00000 - 0000000100000000 (reserved)

LOG2 would contain the following messages (the exactly addresses of
memory map should differ slightly).
...
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 0000000000001000 (usable)
[    0.000000]  BIOS-e820: 00000000fffff000 - 0000000100000000 (reserved)
[    0.000000] bootconsole [earlyser0] enabled
...
[    0.000000] modified physical RAM map:
[    0.000000]  modified: 0000000000000000 - 0000000000002000 (usable)
[    0.000000]  modified: 0000000000002000 - 0000000000006000 (reserved)
[    0.000000]  modified: 0000000000006000 - 000000000008f000 (usable)
[    0.000000]  modified: 000000000008f000 - 0000000000090000 (ACPI NVS)
[    0.000000]  modified: 0000000000090000 - 00000000000a0000 (usable)
[    0.000000]  modified: 0000000000100000 - 0000000000f00000 (usable)
[    0.000000]  modified: 0000000001000000 - 000000003f33f000 (usable)
[    0.000000]  modified: 000000003f33f000 - 000000003f4bf000 (reserved)
[    0.000000]  modified: 000000003f4bf000 - 000000003f5bf000 (ACPI NVS)
[    0.000000]  modified: 000000003f5bf000 - 000000003f5f7000 (ACPI data)
[    0.000000]  modified: 000000003f5f7000 - 000000003f600000 (usable)
[    0.000000]  modified: 00000000fed1c000 - 00000000fed20000 (reserved)
[    0.000000]  modified: 00000000ffc00000 - 0000000100000000 (reserved)

Test result:
1. Compare the first paragraph of excerpts from LOG1 and LOG2:
   This shows that the fake e820 memory map entries are successfully
   added.
2. Compare the second paragraphs of excerpts from LOG1 and LOG2:
   This shows that the added entries do not modify the memory map.

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 49706d0..c9075ee 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -425,7 +425,7 @@ static int __init append_e820_map(struct e820entry
*biosmap, int nr_map)
 {
        /* Only one memory region (or negative)? Ignore it */
        if (nr_map < 2)
-               return no_e820_map_return();
+               return -1;

        return __append_e820_map(biosmap, nr_map);
 }

Review URL: http://codereview.chromium.org/3176019
2010-08-23 11:20:44 +08:00
Randall Spangler
741d2b2f8d Fix LoadKernel() failing to update GPT flags.
BUG=5654

TEST=manual

Case 1: Trying a new kernel which works
  sudo cgpt add -P10 -T10 -S0 -i4 /dev/sda
Then reboot and
  sudo cgpt show /dev/sda
See that tries is now 9 for /dev/sda4 (since the current ChromeOS
doesn't set the successful bit)

Case 2: Trying a new kernel which is bad
  sudo dd if=/dev/zero of=/dev/sda4 count=1 conv=notrunc
Then reboot and
  sudo cgpt show /dev/sda4
See that success=prio=tries=0 for /dev/sda4.

Review URL: http://codereview.chromium.org/3130040
2010-08-20 16:37:12 -07:00
Gaurav Shah
37dff84dbb Make sure that our version of certain utility function implementations gets used in the firmware.
Reference code drop-in to firmware should make our implementations of Memset() and SafeMemcmp() get used now.

BUG=chrome-os-partner:820
TEST=make && make runtests

Change-Id: If0c06dfad85b67398a118985cdb751d20b2b65a4

Review URL: http://codereview.chromium.org/3173035
2010-08-20 14:30:03 -07:00
Gaurav Shah
33c44fc14f Fix signing script: Add missing quotes around string test.
Change-Id: I01c5da48b6fdb48ae45cdb21a6ca7484ad6b09dc

Review URL: http://codereview.chromium.org/3106027
2010-08-20 12:28:51 -07:00
Gaurav Shah
8c762cb2cf set_chronos_password.sh: Add missing sudo while grepping the contents of shadow on root fs.
BUG=none
TEST=manual

Change-Id: Ie0d237c0dc6a2c45ffc33b2fcc22279127854ed9

Review URL: http://codereview.chromium.org/3146025
2010-08-20 12:28:14 -07:00
Bill Richardson
793e1b4156 Run the cgpt tests in a separate directory.
I'm getting ready to add a bunch more cgpt tests. This is just to clear the
way.

Change-Id: I5cb781e85938b94da9c59528872ddfd386712726

Review URL: http://codereview.chromium.org/3162023
2010-08-20 07:58:43 -07:00
Hung-Te Lin
07c81177ef touch source to test new ebuild system
Change-Id: I48b3e1d6b6f139d422e6eac80d9774b488192838

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/3167030
2010-08-20 17:20:41 +08:00
Gaurav Shah
0500524edd Hide packaged firmware AU signing behind a flag for now.
The exact firmware packaging is still very much in flux, not to mention current images don't have the firmware autoupdate package.

BUG=none
TEST=none

Change-Id: Idc60c2c9a8fbc83e0c786b4d4f96f371cdb4a49f

Review URL: http://codereview.chromium.org/3151027
2010-08-19 13:38:27 -07:00
Randall Spangler
dfeb025750 Add explicit typecasts so it compiles using MSVC.
BUG=none
TEST=make && make runtests

Review URL: http://codereview.chromium.org/3184014
2010-08-19 13:17:48 -07:00
Randall Spangler
4bb5e4bad4 Security fixes for LoadKernel()
1) kernel_subkey is one of the input parameters; not read off disk.  KeyBlockVerify() now verifies it's not NULL unless we're only using the hash.

2) Added a check for kernel size vs. buffer size.

3) Added a check to make sure kbuf_sectors is nonzero.

BUG=chrome-os-partner:704
TEST=make && make runtests

Review URL: http://codereview.chromium.org/3186013
2010-08-19 09:05:22 -07:00
Bill Richardson
4be36c4974 Oops. Pass the correct args to Verify* functions.
Change-Id: I08c7d702d97de0fecb8c0db8d63f479dd40f7723

Review URL: http://codereview.chromium.org/3155030
2010-08-19 08:27:31 -07:00
Bill Richardson
0697e3f0cf Enhance 'cgpt find' command to match keyblocks if desired.
This is part of the proposed developer-mode installation process, where we
want to detect that whoever is fiddling with the hard drive has already
fiddled with it before. Otherwise, we'll make them wait a bit to prevent
drive-by updates.

BUG=chromium-os:5306

Change-Id: Ifd6dce69180fa818fe14dbc3b1ac3485fb15d1c9

Review URL: http://codereview.chromium.org/3122023
2010-08-17 16:58:46 -07:00
Gaurav Shah
47b593d849 Add additional sanity checks to RSA verification code.
Also, make algorithm unsigned int in most places.

BUG=chrome-os-partner:701
TEST=existing RSA verification tests still pass

Review URL: http://codereview.chromium.org/3136017
2010-08-17 15:48:22 -07:00
Randall Spangler
138acfe1ba Fix KeyBlockVerify() to take an explicit param for whether to use hash only.
Fix VerifyMemberInside().

BUG=chrome-os-partner:703
TEST=make && make runtests

Review URL: http://codereview.chromium.org/3126013
2010-08-17 15:45:21 -07:00
Luigi Semenzato
c91e2390cb Add some commands to tpmc.
Review URL: http://codereview.chromium.org/3165023
2010-08-17 14:31:52 -07:00
Randall Spangler
bb5d9f1286 Remove kernel backup space
BUG=chrome-os-partner:304
TEST=make && make runtests; all pass.  Manual testing on CRB.

Review URL: http://codereview.chromium.org/3132014
2010-08-16 15:36:07 -07:00
Gaurav Shah
0c4c9bac3c Make signing script re-sign Firmware AU payload, and update rootfs hash.
The build signing script will now re-sign the chrome os AU payload in the image rootfs using the new keys. In addition, it will recalculate and update the RootFS hash (in the kernel partition) before re-signing the whole image using the new "official" keys.

BUG=3496, 5264
TEST=manual

>>>>>For testing rootfs hash updates

1) Ensure that image was build with the --enable_rootfs_verification flag
2) Mount the root file fs on the input image, and make a minor change to the root fs (e.g. adding a file)
3) Now boot from this image, drop into the shell and look for logs related to dm-bht in the dmesg output.
4) You should see dm-bht complaining about block hash mismatches
    $ dmesg | grep dm
      ..... <dm-bht errors>.......
      <errors of the form "dm-bht: Block hash match failed">

4) Now re-sign the modified image using the sign_official_build script. This will re-calculate and update the rootfs hash.
5) Boot from the re-signed image. Look at dmesg output.
6) You should see NO dm-bht errors.

>>>>>For testing re-signing of firmware payload

Grab the firmware autoupdate shellball from /usr/sbin/chromeos-firmwareupdate in the output image's rootfs partition (number 3). Extract the shellball (--sb_extract flag), and grab the firmware bios.bin from the temporary directory.
   $ unpack_firmwarefd.sh bios.bin
   $ vbutil_firmware --verify firmwareA.vblock --signpubkey KEY_DIR/firmware.vbpubk --fv firmwareA.data
    [Verification should succeed]
   $ gbb_utility -g bios.bin --rootkey=rootkey --recoverykey=recoverykey
   "rootkey" should be the same as KEY_DIR/root_key.vbpubk
   "recoverykey" should be the same as KEY_DIR/recovery_key.vbpubk

KEY_DIR: Directory containing the keys used to generate the output image.

Review URL: http://codereview.chromium.org/3083025
2010-08-16 13:29:00 -07:00
Randall Spangler
666802822b Change rollback interface so kernel/firmware version numbers are
packed in the calling code rather than in rollback_index.

Review URL: http://codereview.chromium.org/3114013
2010-08-16 12:33:44 -07:00
Gaurav Shah
45a628251f RSAVerify() - fail on malloc() failure.
BUG=chrome-os-partner:702
TEST=exists RSA verification tests still pass

Review URL: http://codereview.chromium.org/3127013
2010-08-16 11:37:59 -07:00
Bill Richardson
36ab7cd55b Adding a tool to embed a URL into the BIOS bitmaps.
BUG=chrome-os-partner:726

Review URL: http://codereview.chromium.org/3152020

Change-Id: I9739466c1c19e41ada8c716feedfc1b118551aac
2010-08-16 11:29:45 -07:00
Randall Spangler
4abede35af Add structs for TPM NV simplification. Now uses only 2 NV spaces, one for firmware and one for kernel.
Changed TlclRead / TlclWrite to take void* / const void* to reduce typecasts.

Much restructuring of rollback_index.c.

Fixed a version-packing bug in rollback_index.c (& --> |)

BUG:chrome-os-partner:304
TEST:manual testing of all code flows on CRB

Review URL: http://codereview.chromium.org/3084030
2010-08-12 16:40:32 -07:00
Darin Petkov
dfa5a5b8c8 Fix set_lsb_release.sh issues with handling spaces in arguments.
Also, update the usage with examples.

BUG=5581
TEST=tested with "quoted arguments with spaces"

Change-Id: I4d3db4f9d4bf254069f08e8154d650d6ce4551f0

Review URL: http://codereview.chromium.org/3164010
2010-08-12 10:41:06 -07:00
Luigi Semenzato
d7bff87a74 Run self test unconditionally.
Review URL: http://codereview.chromium.org/3131007
2010-08-12 09:26:50 -07:00
Bill Richardson
83ba6d36b8 Clean up some style violations.
Addressing comments from http://codereview.chromium.org/3151005/show, which
has already been closed.

Change-Id: Ibe314831ac0d757b29f4bc0f0aae1a8f700e169c

Review URL: http://codereview.chromium.org/3108010
2010-08-11 13:23:35 -07:00
Darin Petkov
11701c7bb2 Cleanup set_chronos_passowrd script. Also, use $PROG.
BUG=5580
TEST=changed password, reimaged device

Review URL: http://codereview.chromium.org/3164006
2010-08-11 11:08:47 -07:00
Darin Petkov
b7ddcb1caf A utility for updating /etc/lsb-release values.
BUG=5581
TEST=updated an image, updated a device, verified /etc/lsb-release

Review URL: http://codereview.chromium.org/3145008
2010-08-11 11:02:38 -07:00
Darin Petkov
5584d5bc5a Change chronos password rather than root.
Also, rename the script to reflect its specific purpose.

BUG=5580
TEST=ran on an image, installed and tested with new password

Review URL: http://codereview.chromium.org/3175003
2010-08-11 09:55:08 -07:00
Luigi Semenzato
56cec581bb Add clear command.
Review URL: http://codereview.chromium.org/3167004
2010-08-10 15:09:37 -07:00
Bill Richardson
5aa673cacd Add dev_sign_file utility for developers to sign their install scripts.
BUG=chromium-os:5306

Review URL: http://codereview.chromium.org/3151005
2010-08-10 12:20:34 -07:00
Luigi Semenzato
e72291c636 Command-line utility to execute TPM commands bypassing the TSS stack.
Review URL: http://codereview.chromium.org/3149001
2010-08-10 09:46:09 -07:00
Bill Richardson
4f36ef3360 Changes to allow user-signed kernels to be generated.
Make vbutil_keyblock handle unsigned blocks. Also enable --unpack option and
add tests for it.

Modify vbutil_kernel to allow unsigned keyblocks, correct usage message,
and fix the --debug option which was somehow disabled.

Update load_kernel_test to accept /dev/null for the public key, to test
non-signed kernel keyblocks.

Review URL: http://codereview.chromium.org/3124004
2010-08-09 17:50:14 -07:00
Randall Spangler
cbaf696581 Add license headers
Review URL: http://codereview.chromium.org/3094003
2010-08-05 16:42:43 -07:00
Randall Spangler
205190d4ae Pay attention to TPM communication errors
BUG=none
TEST=make && make runtests

Review URL: http://codereview.chromium.org/3078028
2010-08-05 15:55:06 -07:00
Randall Spangler
63dffcb52b Enable TPM in developer mode again.
Also fix a few comments, and make extra debugging work when compiled
in firmware.

BUG=none
TEST=make && make runtests; all pass

Review URL: http://codereview.chromium.org/3007036
2010-08-05 15:13:14 -07:00
J. Richard Barnette
97a122817d Add LICENSE file 2010-08-05 14:18:38 -07:00
Luigi Semenzato
f37fdf56fd Allow passing TPM device path in the environment.
Review URL: http://codereview.chromium.org/3032055
2010-08-04 17:13:08 -07:00
Gaurav Shah
8dd20941cd Zero-out allocated buffer while creating kernel preamble header.
Since the kernel vblocks are always padded out to a fixed size, the unused (padded) memory was ending up containing random bytes, leading to vbutil_kernel generating vblocks that are not bit-identical when run with the same inputs.

BUG=none
TEST=see below
1) Use vbutil_kernel with the same set of inputs to generate two alternative vblocks.
2) Compare the 2 files - they must be bitwise identical space. The padding bytes must all be set to 0.
3) Generate a new signed image using the resign_image.sh script under scripts/image_signing. This signed image should be boot and install successfully on a maching running our custom firmware using the same set of root, firmware, and kernel keys.

Review URL: http://codereview.chromium.org/3076033
2010-08-04 16:45:42 -07:00
Gaurav Shah
37522c9c0c Add a script to generate builds signed using the official keys.
The script sign_official_build.sh does the appropriate signing depending on whether an ssd, recovery or factory-install image is desired.

Also re-factors some common functionality into common.sh.

BUG=3496
TEST=manual

I haven't had a chance to test this on an actual machine running our firmware but will do that before I actually check-in. Thoughts I'd atleast get this out to get the review going.

Review URL: http://codereview.chromium.org/3066034
2010-08-04 15:20:52 -07:00
Luigi Semenzato
3fafad3bb6 Fix GetPermissions bug.
Review URL: http://codereview.chromium.org/3046046
2010-08-04 12:46:08 -07:00
Luigi Semenzato
fda9488f97 Utility to run the self test before we can run tcsd.
Also test of the effects of the self test.

Review URL: http://codereview.chromium.org/3077016
2010-08-04 11:51:13 -07:00
David Rochberg
dd4cfdffab Temporarily remove problematic line while semenzato generates a real fix.
TBR: semenzato

BUG=None
TEST=emerge-arm-generic vboot_reference

Review URL: http://codereview.chromium.org/3069027
2010-08-04 13:38:48 -04:00
Luigi Semenzato
50d48feb9e Various bug fixes to tpm_lite. Some changes to the test suite.
Review URL: http://codereview.chromium.org/3091004
2010-08-04 08:35:12 -07:00