diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2019-04-29 17:09:19 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-01 11:02:58 -0700 |
commit | 262ded1e01a374537e56160811bdad5763b311a5 (patch) | |
tree | 0e34360dad4771dc4559e27b6af6b84cac655219 | |
parent | dd3c5504280bbab17e647e25aad6e66e092881d6 (diff) | |
download | chrome-ec-262ded1e01a374537e56160811bdad5763b311a5.tar.gz |
nvmem: add logging and restart on app_cipher failures
Just in case there is a failure when encrypting or decrypting NVMEM
objects, add code which detects problems, reports them in the flash
log and reboots.
BRANCH=cr50, cr50-mp
BUG=b:69907320, b:129710256
TEST=none
Change-Id: I22e55941f459b5b45bf4b23781b20601a56b40d8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1590042
Reviewed-by: Andrey Pronin <apronin@chromium.org>
-rw-r--r-- | common/new_nvmem.c | 7 | ||||
-rw-r--r-- | include/flash_log.h | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/common/new_nvmem.c b/common/new_nvmem.c index 9ec6e3c885..714481c0fb 100644 --- a/common/new_nvmem.c +++ b/common/new_nvmem.c @@ -337,6 +337,7 @@ static void report_failure(struct nvmem_failure_payload *payload, offsetof(struct nvmem_failure_payload, size), payload); ccprintf("Logging failure %d\n", payload->failure_type); + cflush(); system_reset(SYSTEM_RESET_MANUALLY_TRIGGERED | SYSTEM_RESET_HARD); } @@ -710,7 +711,8 @@ enum ec_error_list get_next_object(struct access_tracker *at, salt[2] = ch->container_hash; /* Decrypt in place. */ - app_cipher(salt, ch + 1, ch + 1, ch->size); + if (!app_cipher(salt, ch + 1, ch + 1, ch->size)) + report_no_payload_failure(NVMEMF_CIPHER_ERROR); } /* And calculate hash. */ @@ -2651,7 +2653,8 @@ static enum ec_error_list save_container(struct nn_container *nc) salt[2] = nc->container_hash; salt[3] = 0; - app_cipher(salt, nc + 1, nc + 1, nc->size); + if (!app_cipher(salt, nc + 1, nc + 1, nc->size)) + report_no_payload_failure(NVMEMF_CIPHER_ERROR); } return save_object(nc); diff --git a/include/flash_log.h b/include/flash_log.h index cfdaf46ce8..bbdd8bb0b3 100644 --- a/include/flash_log.h +++ b/include/flash_log.h @@ -61,7 +61,8 @@ enum nvmem_failure_type { NVMEMF_MISSING_OBJECT = 8, NVMEMF_SECTION_VERIFY = 9, NVMEMF_PRE_ERASE_MISMATCH = 10, - NVMEMF_PAGE_LIST_OVERFLOW = 11 + NVMEMF_PAGE_LIST_OVERFLOW = 11, + NVMEMF_CIPHER_ERROR = 12 }; /* Not all nvmem failures require payload. */ |