All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: linux-integrity@vger.kernel.org
Cc: Mimi Zohar <zohar@linux.ibm.com>, Petr Vorel <pvorel@suse.cz>,
	Bruno Meneguele <bmeneg@redhat.com>,
	Vitaly Chikunov <vt@altlinux.org>
Subject: [PATCH 2/6] ima-evm-utils: fix measurement violation checking
Date: Mon,  6 Jul 2020 22:26:27 -0400	[thread overview]
Message-ID: <1594088791-27370-3-git-send-email-zohar@linux.ibm.com> (raw)
In-Reply-To: <1594088791-27370-1-git-send-email-zohar@linux.ibm.com>

The template data digest for file measurement time of measure, time of
use (ToMToU) violations is zero.  Don't calculate the template data
digest for the different banks.

Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
 src/evmctl.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/evmctl.c b/src/evmctl.c
index 1a5f3545d844..71712d91703a 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1736,10 +1736,19 @@ static void extend_tpm_banks(struct template_entry *entry, int num_banks,
 			continue;
 		}
 
-		err = calculate_template_digest(pctx, md, entry, &bank[i]);
-		if (!err) {
-			bank[i].supported = 0;
-			continue;
+		/*
+		 * Measurement violations are 0x00 digests.  No need to
+		 * calculate the per TPM bank template digests.
+		 */
+		if (memcmp(entry->header.digest, zero, SHA_DIGEST_LENGTH) == 0)
+			memset(bank[i].digest, 0x00, bank[i].digest_size);
+		else {
+			err = calculate_template_digest(pctx, md, entry,
+							&bank[i]);
+			if (!err) {
+				bank[i].supported = 0;
+				continue;
+			}
 		}
 
 		/* extend TPM BANK with template digest */
-- 
2.7.5


  parent reply	other threads:[~2020-07-07  2:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07  2:26 [PATCH 0/6] ima-evm-utils: miscellanous code clean up and bug fixes Mimi Zohar
2020-07-07  2:26 ` [PATCH 1/6] ima-evm-utils: fix PCRAggr error message Mimi Zohar
2020-07-07  2:26 ` Mimi Zohar [this message]
2020-07-07  2:26 ` [PATCH 3/6] ima-evm-utils: don't hardcode validating the IMA measurement list Mimi Zohar
2020-07-07  2:26 ` [PATCH 4/6] ima-evm-utils: calculate and verify the template data digest Mimi Zohar
2020-07-07  2:26 ` [PATCH 5/6] ima-evm-utils: use uint32_t for template length Mimi Zohar
2020-07-07  2:26 ` [PATCH 6/6] ima-evm-utils: define a basic hash_info.h file Mimi Zohar
2020-07-15 17:58   ` Bruno Meneguele
2020-07-15 19:28     ` Mimi Zohar
2020-07-15 20:18       ` Bruno Meneguele

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1594088791-27370-3-git-send-email-zohar@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=bmeneg@redhat.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=pvorel@suse.cz \
    --cc=vt@altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.