coreboot-kgpe-d16/util/cbfstool
Julius Werner fdabf3fcd7 cbfs: Add verification for RO CBFS metadata hash
This patch adds the first stage of the new CONFIG_CBFS_VERIFICATION
feature. It's not useful to end-users in this stage so it cannot be
selected in menuconfig (and should not be used other than for
development) yet. With this patch coreboot can verify the metadata hash
of the RO CBFS when it starts booting, but it does not verify individual
files yet. Likewise, verifying RW CBFSes with vboot is not yet
supported.

Verification is bootstrapped from a "metadata hash anchor" structure
that is embedded in the bootblock code and marked by a unique magic
number.  This anchor contains both the CBFS metadata hash and a separate
hash for the FMAP which is required to find the primary CBFS. Both are
verified on first use in the bootblock (and halt the system on failure).

The CONFIG_TOCTOU_SAFETY option is also added for illustrative purposes
to show some paths that need to be different when full protection
against TOCTOU (time-of-check vs. time-of-use) attacks is desired. For
normal verification it is sufficient to check the FMAP and the CBFS
metadata hash only once in the bootblock -- for TOCTOU verification we
do the same, but we need to be extra careful that we do not re-read the
FMAP or any CBFS metadata in later stages. This is mostly achieved by
depending on the CBFS metadata cache and FMAP cache features, but we
allow for one edge case in case the RW CBFS metadata cache overflows
(which may happen during an RW update and could otherwise no longer be
fixed because mcache size is defined by RO code). This code is added to
demonstrate design intent but won't really matter until RW CBFS
verification can be supported.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: I8930434de55eb938b042fdada9aa90218c0b5a34
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41120
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2020-12-03 00:11:08 +00:00
..
console
flashmap
lz4
lzma
.gitignore .gitignore: Ignore .test/.dependencies globally 2020-10-31 18:21:36 +00:00
EXAMPLE
Makefile
Makefile.inc cbfstool: Use cbfs_serialized.h and standard vboot helpers 2020-12-03 00:00:33 +00:00
ProcessorBind.h
amdcompress.c util/cbfstool/amdcompress: fix argument requirement 2020-11-15 16:49:30 +00:00
cbfs-mkpayload.c cbfstool: Use cbfs_serialized.h and standard vboot helpers 2020-12-03 00:00:33 +00:00
cbfs-mkstage.c cbfstool: Use cbfs_serialized.h and standard vboot helpers 2020-12-03 00:00:33 +00:00
cbfs-payload-linux.c cbfstool: Use cbfs_serialized.h and standard vboot helpers 2020-12-03 00:00:33 +00:00
cbfs.h cbfs: Add verification for RO CBFS metadata hash 2020-12-03 00:11:08 +00:00
cbfs_image.c cbfstool: Hide hash printing behind -v and add to parseable output 2020-12-03 00:08:03 +00:00
cbfs_image.h cbfstool: Hide hash printing behind -v and add to parseable output 2020-12-03 00:08:03 +00:00
cbfs_sections.c
cbfs_sections.h
cbfscomptool.c cbfstool: Use cbfs_serialized.h and standard vboot helpers 2020-12-03 00:00:33 +00:00
cbfstool.c cbfstool: Hide hash printing behind -v and add to parseable output 2020-12-03 00:08:03 +00:00
coff.h
common.c
common.h cbfstool: Use cbfs_serialized.h and standard vboot helpers 2020-12-03 00:00:33 +00:00
compress.c cbfstool: Use cbfs_serialized.h and standard vboot helpers 2020-12-03 00:00:33 +00:00
default-x86.fmd
default.fmd
description.md
elf.h
elfheaders.c
elfparsing.h
fdt.h
fit.c
fit.h
flashmap_tests.c
fmap_from_fmd.c
fmap_from_fmd.h
fmaptool.c
fmd.c
fmd.h
fmd_parser.c_shipped
fmd_parser.h_shipped
fmd_parser.y
fmd_scanner.c_shipped
fmd_scanner.h_shipped
fmd_scanner.l
fv.h
ifittool.c
ifwitool.c
linux.h
linux_trampoline.S
linux_trampoline.c
linux_trampoline.h
option.h
partitioned_file.c
partitioned_file.h
rmodtool.c
rmodule.c
rmodule.h
swab.h
xdr.c