MCPcopy Create free account
hub / github.com/coreboot/coreboot / verify_fmap

Function verify_fmap

src/lib/fmap.c:32–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32static int verify_fmap(const struct fmap *fmap)
33{
34 if (memcmp(fmap->signature, FMAP_SIGNATURE, sizeof(fmap->signature))) {
35 if (ENV_INITIAL_STAGE)
36 printk(BIOS_ERR, "Invalid FMAP at %#x\n", FMAP_OFFSET);
37 return -1;
38 }
39
40 static bool done = false;
41 if (!CONFIG(CBFS_VERIFICATION) || !ENV_INITIAL_STAGE || done)
42 return 0; /* Only need to check hash in first stage. */
43
44 /* On error we need to die right here, lest we risk a TOCTOU attack where the cache is
45 filled with a tampered FMAP but the later fallback path is fed a valid one. */
46 if (metadata_hash_verify_fmap(fmap, FMAP_SIZE) != VB2_SUCCESS)
47 die("FMAP verification failure");
48
49 done = true;
50 return 0;
51}
52
53static void report(const struct fmap *fmap)
54{

Callers 2

setup_preram_cacheFunction · 0.85
find_fmap_directoryFunction · 0.85

Calls 4

memcmpFunction · 0.70
printkFunction · 0.50
dieFunction · 0.50

Tested by

no test coverage detected