summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuigi Semenzato <semenzato@chromium.org>2011-06-30 16:28:48 -0700
committerLuigi Semenzato <semenzato@chromium.org>2011-07-06 11:02:48 -0700
commitebb1eda9bb4832c380a05e98eb2a7a98535afe5b (patch)
tree03904f5d19ed2d3c44ff95d95cc75deb57b8a4f1
parentcfd841d3c2c8bb91e7024c62d0acc8668c5041b3 (diff)
downloadvboot-ebb1eda9bb4832c380a05e98eb2a7a98535afe5b.tar.gz
Reduce race conditions in TPM initialization.
With this change, the firmware creates and initializes the kernel space first, then the firmware space. Thus, if the initialization is interrupted (by cutting power) in between the two spaces, at the next boot the initialization path will be taken again, since it is triggered by a missing firmware space. A space creation succeeds when the space already exists (the space is removed and recreated), so this eliminates two races. There is still the possibility that the power is cut between creating the firmware space and initializing it, but let's assume it's not a problem until proven otherwise. (It won't be a security problem anyhow.) BUG=chromium-os:17049 TEST=none (too hard to reproduce the race) Change-Id: Iae4c1cc2b9a5056cb5d858e71b680e27a442357e Reviewed-on: http://gerrit.chromium.org/gerrit/3520 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Luigi Semenzato <semenzato@chromium.org>
-rw-r--r--firmware/lib/rollback_index.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/firmware/lib/rollback_index.c b/firmware/lib/rollback_index.c
index 27b61650..34151025 100644
--- a/firmware/lib/rollback_index.c
+++ b/firmware/lib/rollback_index.c
@@ -162,13 +162,13 @@ static uint32_t OneTimeInitializeTPM(RollbackSpaceFirmware* rsf,
Memcpy(rsk, &rsk_init, sizeof(RollbackSpaceKernel));
/* Defines and sets firmware and kernel spaces */
+ RETURN_ON_FAILURE(SafeDefineSpace(KERNEL_NV_INDEX, TPM_NV_PER_PPWRITE,
+ sizeof(RollbackSpaceKernel)));
+ RETURN_ON_FAILURE(WriteSpaceKernel(rsk));
RETURN_ON_FAILURE(SafeDefineSpace(FIRMWARE_NV_INDEX,
TPM_NV_PER_GLOBALLOCK | TPM_NV_PER_PPWRITE,
sizeof(RollbackSpaceFirmware)));
RETURN_ON_FAILURE(WriteSpaceFirmware(rsf));
- RETURN_ON_FAILURE(SafeDefineSpace(KERNEL_NV_INDEX, TPM_NV_PER_PPWRITE,
- sizeof(RollbackSpaceKernel)));
- RETURN_ON_FAILURE(WriteSpaceKernel(rsk));
return TPM_SUCCESS;
}