Skip to content

Commit

Permalink
libstb: fix failure of calling cvc verify without STB initialization.
Browse files Browse the repository at this point in the history
Currently in OPAL init time at various stages we are loading various
PNOR partition containers from the flash device. When we load a flash
resource STB calls the CVC verify and trusted measure(sha512) functions.
So when we have a flash resource gets loaded before STB initialization,
then cvc verify function fails to start the verify and enforce the boot.

Below is one of the example failure where our VERSION partition gets
loading early in the boot stage without STB initialization done.

This is with secure mode off.
STB: VERSION NOT VERIFIED, invalid param. buf=0x305ed930, len=4096 key-hash=0x0 hash-size=0

In the same code path when secure mode is on, the boot process will abort.

So this patch fixes this issue by calling cvc verify only if we have
STB init was done.

And also we need a permanent fix in init path to ensure STB init gets
done at first place and then start loading all other flash resources.

Signed-off-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
pridhiviraj authored and stewartsmith committed Feb 9, 2018
1 parent 7912f97 commit 2109b81
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libstb/secureboot.c
Expand Up @@ -28,6 +28,7 @@
static const void* hw_key_hash = NULL;
static size_t hw_key_hash_size;
static bool secure_mode = false;
static bool secure_init = false;

static struct {
enum secureboot_version version;
Expand Down Expand Up @@ -161,6 +162,8 @@ void secureboot_init(void)
}
if (cvc_init())
secureboot_enforce();

secure_init = true;
}

int secureboot_verify(enum resource_id id, void *buf, size_t len)
Expand All @@ -176,6 +179,12 @@ int secureboot_verify(enum resource_id id, void *buf, size_t len)
secureboot_enforce();
}

if (!secure_init) {
prlog(PR_WARNING, "container NOT VERIFIED, resource_id=%d "
"secureboot not yet initialized\n", id);
return -1;
}

rc = call_cvc_verify(buf, len, hw_key_hash, hw_key_hash_size, &log);

if (rc == OPAL_SUCCESS) {
Expand Down

0 comments on commit 2109b81

Please sign in to comment.