From aae16330695ab1a3a3ed1a9068dc25bba00997fe Mon Sep 17 00:00:00 2001 From: harshit Date: Tue, 12 May 2020 12:55:39 +0530 Subject: security/tpm/tspi: Fix handling of white space delimited list The current implementation uses strcmp() without splitting the list and therefore returns false even when the string pointed to by 'name' is a part of 'whitelist'. The patch fixes this problem. Also, update help text of CONFIG_TPM_MEASURED_BOOT_RUNTIME_DATA to space delimited list to align it with the other lists we use. Change-Id: Ifd285162ea6e562a5bb18325a1b767ac2e4276f3 Signed-off-by: Harshit Sharma Reviewed-on: https://review.coreboot.org/c/coreboot/+/41280 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber Reviewed-by: Werner Zeh --- src/security/tpm/tspi/crtm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/security/tpm/tspi/crtm.c') diff --git a/src/security/tpm/tspi/crtm.c b/src/security/tpm/tspi/crtm.c index 8bcc01bcbb..49daeb009b 100644 --- a/src/security/tpm/tspi/crtm.c +++ b/src/security/tpm/tspi/crtm.c @@ -88,17 +88,18 @@ static bool is_runtime_data(const char *name) const char *whitelist = CONFIG_TPM_MEASURED_BOOT_RUNTIME_DATA; size_t whitelist_len = sizeof(CONFIG_TPM_MEASURED_BOOT_RUNTIME_DATA) - 1; size_t name_len = strlen(name); - int i; + const char *end; if (!whitelist_len || !name_len) return false; - for (i = 0; (i + name_len) <= whitelist_len; i++) { - if (!strcmp(whitelist + i, name)) + while ((end = strchr(whitelist, ' '))) { + if (end - whitelist == name_len && !strncmp(whitelist, name, name_len)) return true; + whitelist = end + 1; } - return false; + return !strcmp(whitelist, name); } uint32_t tspi_measure_cbfs_hook(struct cbfsf *fh, const char *name) -- cgit v1.2.3