Commit Graph

28 Commits

Author SHA1 Message Date
Randall Spangler
b56b5f8e06 Fix more coverity warnings in utilities
Assorted minor code issues, which we should fix so any new errors stand
out more.

BUG=chromium:643769
BRANCH=none
TEST=make runtests

Change-Id: I8fcf0c51e33d5dc49f650f4069f1579091cf188d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/383713
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-15 16:16:12 -07:00
Randall Spangler
d8a9ede87c futility/host lib: Fix coverity warnings
Assorted minor code issues, which we should fix so any new errors stand
out more.

BUG=chromium:643769
BRANCH=none
TEST=make runtests

Change-Id: Ib37b45dea54bd506b519b0304300b8d192e34339
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/382319
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-14 13:05:02 -07:00
Randall Spangler
5c537e3ea8 futility: use vboot2 functions for kernel preamble
Another in a long series of refactoring changes to replace old vboot1
code with its vboot2 equivalent.  Futility changes only; no change to
firmware.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: I7be813b82820674e975db13d5e540e49bdea028d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366057
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-06 22:02:21 -07:00
Randall Spangler
f7559e4b46 futility: Use vboot 2.0 APIs for public keys
This replaces calls to the old vboot 1 APIs with their vboot 2.0
equivalents.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: Ieb1a127577c6428c47ac088c3aaa0d0dad6275a8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/356541
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-02 01:28:37 -07:00
Randall Spangler
d46461cec2 futility: Use vboot 2.0 APIs for private keys
This replaces calls to the vboot 1 host library with their vboot 2.0
equivalents.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: Id061554fd82ea3efe35d0fe1485693b47599a863
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/356540
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-08-10 15:30:35 -07:00
Randall Spangler
939cc3a5c2 futility: Use only vboot 2.0 APIs for keyblocks
This refactors futility and the host library to use only vboot 2.0 APIs
to create and verify keyblocks.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: Ia3cc1e24971b94f01bcb4890c8666a3af6f84841
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/356129
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-08-10 15:30:33 -07:00
Bill Richardson
453ecd1956 futility: add --type arg to show and sign commands
This allows the user to manually specify the type of an input
file, since not all file types can be reliably identified.

This also adds a test to ensure that futility doesn't coredump if
you give it the wrong type (although I'm sure it's not exhaustive).

BUG=chromium:231574
BRANCH=none
TEST=make runtests

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I9d909305d9989fe7299e744c585de380109cf8cd
Reviewed-on: https://chromium-review.googlesource.com/262895
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-31 06:28:14 +00:00
Bill Richardson
01466d36af futility: Let each command provide its own help
Instead of a separate help function for each command, let's just
require each command to handle a --help option. This will make it
easier to layer the commands (for example, "sign" could have
several subcommand variants, each with its own help).

BUG=none
BRANCH=none
TEST=make runtests

I also compared the result of running "futility help CMD" before
and after this change. The help still shows up correctly.

Change-Id: I5c58176f32b41b0a2c2b8f0afb17dddd80fddc70
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/260495
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-18 23:07:36 +00:00
Bill Richardson
49a422fab9 futility: change longhelp functions to take multiple args
Some of the help messages are getting pretty long. We should
allow each command to provide additional help details only when
asked.

BUG=none
BRANCH=none
TEST=make runtests

I also compared the help messages for all commands, both before
and after this change to ensure that nothing was different.

Change-Id: Ibe92ec80f99d286886fe020c9d826a5a05556471
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/260494
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-18 23:07:27 +00:00
Bill Richardson
c8054eae60 Provert "futility: Make --debug a global option"
This reverts commit d90b07bd4d,
which reverted d7e1e4f0be, which
didn't actually have anything wrong with it.

BUG=chromium:466433
BRANCH=one
TEST=None

Change-Id: I68a60c38eba1fce1c9332601a57ea8fee72139a3
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/259650
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
2015-03-12 19:27:19 +00:00
Prathmesh Prabhu
d90b07bd4d Revert "futility: Make --debug a global option"
This reverts commit d7e1e4f0be.

BUG=chromium:466433
TEST=None.

Change-Id: Ia1b300e2dbccddbbae9e831709bc49eb53a5feb8
Reviewed-on: https://chromium-review.googlesource.com/259365
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
2015-03-12 03:16:00 +00:00
Bill Richardson
d7e1e4f0be futility: Make --debug a global option
Some commands look for a --debug option, others don't. The
feature is implemented globally, so let's parse it as a global
option.

BUG=none
BRANCH=none
TEST=make runtests

Change-Id: I3b169e4a1b93443786913276651113d1c915a834
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/258500
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-11 07:50:27 +00:00
Bill Richardson
1eae873b61 futility: Add global args to specify vboot API and format
The host-side futility tool will need to support all extant vboot
implementations. Some legacy futility commands only support the
original vb1 format, but others ("show" or "sign", for example)
may need to be instructed which formats to expect or emit.

This change adds some global args to specify the preferred
formats. It also cleans up a few [unused AFAICT] one-letter args
to avoid conflicts.

BUG=chromium:231574
BRANCH=none
TEST=make runtests

Nothing makes use of this yet, except the "help" command.

Change-Id: Ib79fa12af72b8860b9494e5d9e90b9572c006107
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/246765
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-02-28 00:56:13 +00:00
Furquan Shaikh
80e779d50b kernel flags: Add flags field to kernel preamble.
1. Increase kernel preamble revision from 2.1 to 2.2.
2. Add flags field to kernel preamble.
3. Update futility to accept flags parameter for vbutil_kernel and
cmd_sign for kernel.
4. Pass in an extra flags field to SignKernelBlob and
CreateKernelPreamble.

BUG=chrome-os-partner:35861
BRANCH=None
TEST=1) "make runalltests" completes successfully. 2) vboot_reference
compiles successfully for ryu. 3) Verified flags field in header using
futility show.

Change-Id: If9f06f98778a7339194c77090cbef4807d5e34e2
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/245950
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
2015-02-12 04:40:35 +00:00
David Riley
05987b159a Changes to compile signing tools on darwin
The following works from a Mac with these changes:
make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility

Only vbutil_keyblock and vbutil_kernel have been exercised.

BUG=none
TEST='make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility'
BRANCH=none

Signed-off-by: David Riley <davidriley@chromium.org>

Change-Id: Ie69cfee0c650d4ff96be6322083a2fea1543ee39
Reviewed-on: https://chromium-review.googlesource.com/246773
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: David Riley <davidriley@chromium.org>
Commit-Queue: David Riley <davidriley@chromium.org>
2015-02-11 23:05:39 +00:00
Shelley Chen
1bdc612578 vboot_reference: fix pointer issue in vmlinuz recontruction
vmlinuz_header_address was using an offset as opposed to a pointer.

BUG=None
BRANCH=None
TEST=Take a kernel block and reconstruction the vmlinuz image:
     "vbutil_kernel --get-vmlinuz kern0 --vmlinuz-out vm.out"
     Then, try to kexec vm.out.

Change-Id: Ifb41a00fd73f3222673467eef370c7abdbd0fd9c
Reviewed-on: https://chromium-review.googlesource.com/245441
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Shelley Chen <shchen@chromium.org>
Tested-by: Shelley Chen <shchen@chromium.org>
2015-02-03 20:29:38 +00:00
Bill Richardson
2559338dbd futility: refactor file type detection into new files
This moves the what-kind-of-file-is-this logic into a separate
file, and makes it work by calling distinct recognizers until one
hits. A new "-t" option to the show command prints what it's
doing.

BUG=chromium:228932
BRANCH=ToT
TEST=make runtests

Change-Id: Id8f60bdf3fe6a9adf41b4555b3448a261fa52fea
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/245122
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-31 05:42:48 +00:00
Bill Richardson
9bfe2c9f26 futility: vbutil_kernel should check the kernel a bit more
Trying to repack an invalid kernel blob should notice and
complain that the blob is invalid instead of just segfaulting.

BUG=chromium:452353
BRANCH=ToT
TEST=manual

See the bug report for an example test case. Many more tests are
being added as futility development continues.

Change-Id: I2bbfb8ab41a0f596b25a76f76f74d7b47b7e4a17
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/243583
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-28 01:56:09 +00:00
Shelley Chen
f1f53b3732 vboot: Add flag to vbutil_kernel for reconstruction of vmlinuz image
Adding functionality to allow for rebuilding of vmlinuz after it
has been processed into vblock and header stripped.  Basically appends
the 16-bit header of a vmlinuz image onto the end of the vblock.
BUG=chromium:438302
BRANCH=none
TEST=Successfully ran "make runalltests".
     Also, ran:
     1. Repack kernel block (so that 16-bit header is included):
        "vbutil_kernel --pack kern_0 ..."
     2. Verify kernel: "vbutil_kernel --verify kern_0 ... ".  This should
        be done before booting into kernel, but not necessary for it to work.
     3. Rebuild vmlinuz image:
        "vbutil_kernel --get-vmlinuz kern_0 --vmlinuz-out vm.out"
     4. Set up kexec with vmlinuz (this should complete with no errors):
        "kexec -l vm.out (other kernel cmd line args)"
     5. Boot into kernel:
        "kexec -e"

Change-Id: Iaa1582a1aedf70b43cdb3a56cde1fb248f1793d4
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232750
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-23 21:32:12 +00:00
Bill Richardson
4dad690e08 futility: update the vbutil_kernel implementation
Now that the underlying bug is fixed (commit 64ef69c), this
replaces the old vbutil_kernel command implementation with the
new one that we rolled back in commit f1dba02.

BUG=chromium:418647
BRANCH=none
TEST=make runtests

I've also built an image with this change, installed it on a
Chromebook, ran make_dev_ssd.sh, make_dev_firmware.sh, recovered,
etc. Everything still works.

Change-Id: I8996e674a24b5d994658a6be2973ef3623cd659b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/235429
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-22 22:45:48 +00:00
Bill Richardson
f1dba02034 futility: rolled back vbutil_kernel change
When disabling verity with make_dev_ssh.sh, a bug in
vbutil_kernel caused the re-signed kernel size to be the entire
kernel partition instead of just the necessary bits. Until we can
improve the test coverage, I'm rolling back the changes that
introduced this bug.

BUG=chromium:418647
BRANCH=ToT
TEST=manual

Created a new test image with these changes. You can install it
and disable dm-verity and it works (although there seems to be an
unrelated browser startup issue on ToT).

Change-Id: I48e8427b05e191c9894c42056429a79d57bfc78d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220935
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-02 20:51:05 +00:00
Bill Richardson
f318ee205c futility: implement vbutil_kernel using buffers, not files
The original vbutil_kernel command used file read and write to
make changes. Futility prefers to use memory-mapped files. This
rewrites cmd_vbutil_kernel.c to use that scheme.

BUG=none
BRANCH=ToT
TEST=make runtests

The original cmd_vbutil_kernel.c is renamed, and a test written
to ensure that the refactored version produces identical results.

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: Ic6c3e12429a5dcb271f8136a9edac70807d66120
Reviewed-on: https://chromium-review.googlesource.com/219647
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-09-25 20:27:00 +00:00
Bill Richardson
e192e7f6ce futility: clean up a few shared functions
Move the Debug() function into a common place instead of several
copies in different files, rename shared functions to start with
"futil_"

BUG=none
BRANCH=ToT
TEST=make runtests

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I6b844553dff95c24894dae611102716a8da5312d
Reviewed-on: https://chromium-review.googlesource.com/219645
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-09-25 20:26:53 +00:00
Bill Richardson
779796f57e futility: Improve help messages
This provides help messages for the futility commands similar to
the way git does. These show the available commands:

  futility
  futility help
  futility --help

While these show help for a specific command:

  futility help COMMAND
  futility --help COMMAND
  futility COMMAND --help

BUG=none
BRANCH=ToT
TEST=manual

make runtests

And manually look at help messages for each command.

Change-Id: I1126471e242784c6ca7a2f11694fa7c505d833e8
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219528
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-09-24 00:59:02 +00:00
Bill Richardson
31d95c2386 futility: Reformat to use kernel coding style
This just reformats the futility sources to conform to the Linux kernel
coding style. No functional changes.

BUG=chromium:224734
BRANCH=ToT
TEST=make runtests

Change-Id: I82df07dd3f8be2ad2f3df24cebe00a9a378b13f4
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213915
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-25 20:52:39 +00:00
Benson Leung
e5b7a54119 futility: add --arch=aarch64
Add support for the 64bit arm architecture, which update_kernel.sh
passes in as "aarch64"

Signed-off-by: Benson Leung <bleung@chromium.org>

BUG=chrome-os-partner:31525
TEST=run vbutil_kernel --arch=aarch64
Check that it no longer complains about "Unknown architecture string: aarch64"
BRANCH=none

Change-Id: Iccd925e05baffb1953b229fc4150ca179d1d1e1c
Reviewed-on: https://chromium-review.googlesource.com/213706
Reviewed-by: David Riley <davidriley@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
Commit-Queue: Benson Leung <bleung@chromium.org>
2014-08-23 02:44:34 +00:00
Mike Frysinger
7351ed7a3c futility: add more static/const markings
BUG=chromium:404643
TEST=pre-cq passes (runs unittests)
BRANCH=None

Change-Id: I3c3a9ee7192305dfa72333c0b6a77653b7188869
Reviewed-on: https://chromium-review.googlesource.com/212877
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
2014-08-20 08:23:45 +00:00
Bill Richardson
6f3961507e futility: Add remaining vboot binary utilities
This change adds these formerly external utilities into the futility binary:

  dev_sign_file
  dump_kernel_config
  gbb_utility
  vbutil_firmware
  vbutil_kernel

These target binaries will remain independent of futility, since they are
not directly related to verified boot:

  cgpt
  crossystem
  tpm_init_temp_fix
  tpmc

Also, dumpRSAPublicKey is removed from the target, since it is only used on
the build host to create new keypairs.

This change also add several additional tests.

BUG=chromium:224734
BRANCH=ToT
CQ-DEPEND=CL:210391,CL:210568,CL:210587
TEST=manual

make runtests
make clean

Also build and test:
- normal image
- test image
- recovery image
- firmware shellball

Note that this CL depends on simultaneous changes to the chromeos-initramfs
ebuild.

Change-Id: If791b5e9b5aac218ceafa9f45fc1785f16b91a64
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210403
2014-07-31 22:46:27 +00:00