summaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
authorLuigi Semenzato <semenzato@chromium.org>2015-03-19 16:45:52 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-21 01:47:57 +0000
commitf80ceeb432b880ad8af8bcd1f4fa07f03ee4a8e6 (patch)
treecda7ab001b9481f53833663b3b3ee0d604df3e82 /host
parent4dc1575ba187c650ae486ce6572c6d535879ff9d (diff)
downloadvboot-f80ceeb432b880ad8af8bcd1f4fa07f03ee4a8e6.tar.gz
vboot_reference: crossystem: add the "tpm_attack" command
This commands reads/sets a bit in the kernel-reserved area of the vboot context nvram. The bit can also be set by the driver during execution of a TPM command, to check if the command is interrupted by a panic or power loss. Under some circumstances, this correlates with the TPM assuming it is under attack. BUG=chromium:431360 TEST=try "crossystem tpm_attack" and variations BRANCH=none Change-Id: I87215d5a0becfb5c01e0b69867a339bfe6fd0b68 Reviewed-on: https://chromium-review.googlesource.com/261339 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Luigi Semenzato <semenzato@chromium.org> Tested-by: Luigi Semenzato <semenzato@chromium.org>
Diffstat (limited to 'host')
-rw-r--r--host/lib/crossystem.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index 1eef737b..d97effa4 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -65,11 +65,12 @@ static const char *fw_results[] = {"unknown", "trying", "success", "failure"};
/* Masks for kern_nv usage by kernel. */
#define KERN_NV_FWUPDATE_TRIES_MASK 0x0000000F
#define KERN_NV_BLOCK_DEVMODE_FLAG 0x00000010
+#define KERN_NV_TPM_ATTACK_FLAG 0x00000020
/* If you want to use the remaining currently-unused bits in kern_nv
* for something kernel-y, define a new field (the way we did for
* fwupdate_tries). Don't just modify kern_nv directly, because that
* makes it too easy to accidentally corrupt other sub-fields. */
-#define KERN_NV_CURRENTLY_UNUSED 0xFFFFFFE0
+#define KERN_NV_CURRENTLY_UNUSED 0xFFFFFFC0
/* Return true if the FWID starts with the specified string. */
int FwidStartsWith(const char *start) {
@@ -482,6 +483,12 @@ int VbGetSystemPropertyInt(const char* name) {
value &= KERN_NV_BLOCK_DEVMODE_FLAG;
value = !!value;
}
+ } else if (!strcasecmp(name,"tpm_attack")) {
+ value = VbGetNvStorage(VBNV_KERNEL_FIELD);
+ if (value != -1) {
+ value &= KERN_NV_TPM_ATTACK_FLAG;
+ value = !!value;
+ }
} else if (!strcasecmp(name,"loc_idx")) {
value = VbGetNvStorage(VBNV_LOCALIZATION_INDEX);
} else if (!strcasecmp(name,"backup_nvram_request")) {
@@ -626,7 +633,18 @@ int VbSetSystemPropertyInt(const char* name, int value) {
return -1;
kern_nv &= ~KERN_NV_BLOCK_DEVMODE_FLAG;
if (value)
- kern_nv |= KERN_NV_BLOCK_DEVMODE_FLAG;
+ kern_nv |= KERN_NV_BLOCK_DEVMODE_FLAG;
+ return VbSetNvStorage_WithBackup(VBNV_KERNEL_FIELD, kern_nv);
+ } else if (!strcasecmp(name,"tpm_attack")) {
+ /* This value should only be read and cleared, but we allow setting it to 1
+ * for testing.
+ */
+ int kern_nv = VbGetNvStorage(VBNV_KERNEL_FIELD);
+ if (kern_nv == -1)
+ return -1;
+ kern_nv &= ~KERN_NV_TPM_ATTACK_FLAG;
+ if (value)
+ kern_nv |= KERN_NV_TPM_ATTACK_FLAG;
return VbSetNvStorage_WithBackup(VBNV_KERNEL_FIELD, kern_nv);
} else if (!strcasecmp(name,"loc_idx")) {
return VbSetNvStorage_WithBackup(VBNV_LOCALIZATION_INDEX, value);