Commit Graph

1662 Commits

Author SHA1 Message Date
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
Darin Petkov
d9072f169f Add a customize_image script.
For now, it just updates the root password.

BUG=5080
TEST=ran the script,tried the image

Review URL: http://codereview.chromium.org/3061045
2010-08-03 10:02:08 -07:00
Gaurav Shah
9b16a66b9b Modify the key generation script and add an installer keyblock to the dev keys.
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/3018024
2010-07-28 16:24:26 -07:00
Gaurav Shah
b69a6bbfe7 Don't use hardcoded offsets for parsing.
Forgot to propagate the use of area_offset= pattern for ouput parsing to the unpacking script.

BUG=none
TEST=Tested by running on a firmware image with flashmap enabled. Correctly parsed the section offsets and sizes and output them to files.

Review URL: http://codereview.chromium.org/3050019
2010-07-27 11:45:07 -07:00
Gaurav Shah
89a663a6e6 Rename image re-signing utility (for compactness and consistency sake).
Review URL: http://codereview.chromium.org/3027027
2010-07-27 10:52:45 -07:00
Gaurav Shah
aa22a5dea5 Add script for re-signing final firmware images with the correct keys.
Also add a script for splitting a firmware image into component firmware data, vblocks and the GBB.

Note: The script uses fmap_decode, a utility to parse flashmap of a firmware image, and a part of the flashmap project:
http://code.google.com/p/flashmap/

BUG=3496
TEST=Tested with newer builds of firmware images with flashmaps enabled. Steps to verify:

1) Use script to re-sign an existing image with a new set of keys.
2) Use unpack_firmwarefd.sh to get individual firmware data and vblocks.
3) Use vbutil_firmware with the new keys. Verification should succeed with
   the newer keys but fail with the older ones.

Review URL: http://codereview.chromium.org/3026018
2010-07-27 10:52:07 -07:00
Gaurav Shah
58a7540397 Add a script that will generate a new vblock given a kernel partition.
For use on our signing servers. May merge this with other scripts once we drill down the right workflow.

BUG=3496
TEST=Just a wrapper around vbutil_kernel and works as intended.

Review URL: http://codereview.chromium.org/3020023
2010-07-26 17:56:33 -07:00
Bill Richardson
5deb67f225 Make LoadKernel() pass back the kernel partition's UniqueGuid.
LoadKernel already returns the partition number for the selected kernel.
This change makes it also return the GPT Entry's UniqueGuid, which will
eventually be passed to the kernel itself, so the kernel can determine which
of several possible devices it has booted from. It doesn't know for certain
because the BIOS and the kernel may enumerate the devices in a different
order.

BUG=chromium-os:4984

Review URL: http://codereview.chromium.org/3056014
2010-07-23 17:22:25 -07:00
Bill Richardson
e272940ec5 Fix load_kernel_test, add check to LoadKernel to detect bad args.
load_kernel_test was failing because it wasn't setting
params->kernel_buffer_size before calling LoadKernel(). This fixes that,
plus adds some checks to LoadKernel so that it will notice bad params if it
happens again.

Review URL: http://codereview.chromium.org/3060004
2010-07-22 12:23:47 -07:00