From 967a76bd811088b2a8bd7f008b2436e31ab4e5b3 Mon Sep 17 00:00:00 2001 From: Jakub Czapiga Date: Fri, 19 Aug 2022 12:25:27 +0200 Subject: vboot: Add VBOOT_CBFS_INTEGRATION support This patch introduces support signing and verification of firmware slots using CBFS metadata hash verification method for faster initial verification. To have complete verification, CBFS_VERIFICATION should also be enabled, as metadata hash covers only files metadata, not their contents. This patch also adapts mainboards and SoCs to new vboot reset requirements. TEST=Google Volteer/Voxel boots with VBOOT_CBFS_INTEGRATION enabled Signed-off-by: Jakub Czapiga Change-Id: I40ae01c477c4e4f7a1c90e4026a8a868ae64b5ca Reviewed-on: https://review.coreboot.org/c/coreboot/+/66909 Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) --- src/lib/cbfs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 4f2d9caea9..d2829d1d3e 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,10 @@ enum cb_err _cbfs_boot_lookup(const char *name, bool force_ro, RO CBFS would have been caught when building the mcache in cbfs_get boot_device(). (Note that TOCTOU_SAFETY implies !NO_CBFS_MCACHE.) */ assert(cbd == vboot_get_cbfs_boot_device()); - die("TODO: set metadata_hash to RW metadata hash here.\n"); + if (!CONFIG(VBOOT) + || vb2api_get_metadata_hash(vboot_get_context(), &metadata_hash) + != VB2_SUCCESS) + die("Failed to get RW metadata hash"); } err = cbfs_lookup(&cbd->rdev, name, mdata, &data_offset, metadata_hash); } @@ -160,8 +164,14 @@ static bool cbfs_file_hash_mismatch(const void *buffer, size_t size, ERROR("'%s' does not have a file hash!\n", mdata->h.filename); return true; } - if (vb2_hash_verify(vboot_hwcrypto_allowed(), buffer, size, hash)) { + + vb2_error_t rv = vb2_hash_verify(vboot_hwcrypto_allowed(), buffer, size, hash); + if (rv != VB2_SUCCESS) { ERROR("'%s' file hash mismatch!\n", mdata->h.filename); + if (CONFIG(VBOOT_CBFS_INTEGRATION) && !vboot_recovery_mode_enabled() + && vboot_logic_executed()) + vboot_fail_and_reboot(vboot_get_context(), VB2_RECOVERY_FW_BODY, + rv); return true; } } -- cgit v1.2.3