All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: linux-integrity@vger.kernel.org
Cc: Roberto Sassu <roberto.sassu@huawei.com>,
	Vitaly Chikunov <vt@altlinux.org>,
	Patrick Uiterwijk <puiterwi@redhat.com>,
	Petr Vorel <pvorel@suse.cz>, Mimi Zohar <zohar@linux.ibm.com>
Subject: [RFC PATCH 2/8] ima-evm-utils: increase the size of "zero" and "fox" variables
Date: Fri, 21 Feb 2020 13:38:52 -0500	[thread overview]
Message-ID: <1582310338-1562-3-git-send-email-zohar@linux.ibm.com> (raw)
In-Reply-To: <1582310338-1562-1-git-send-email-zohar@linux.ibm.com>

Opening a file for write when it is already opened for read, results in
a time of measure, time of use (ToMToU) error.  Similarly, when opening
a file for read, when it is already opened for write, results in a file
measurement error.  These violations are flagged by including 0x00's as
the template digest in the measurement list, but extending the TPM with
0xFF's.

In preparation of extending the TPM banks with bank specific digest
values, increase the "zero" and "fox" variable sizes.

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

diff --git a/src/evmctl.c b/src/evmctl.c
index 704615694cec..9c8544a95b6a 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1477,8 +1477,8 @@ struct template_entry {
 	int template_buf_len;
 };
 
-static uint8_t zero[SHA_DIGEST_LENGTH];
-static uint8_t fox[SHA_DIGEST_LENGTH];
+static uint8_t zero[MAX_DIGEST_SIZE];
+static uint8_t fox[MAX_DIGEST_SIZE];
 
 int validate = 1;
 
@@ -1499,7 +1499,7 @@ static int ima_verify_template_hash(struct template_entry *entry)
 {
 	uint8_t digest[SHA_DIGEST_LENGTH];
 
-	if (!memcmp(zero, entry->header.digest, sizeof(zero)))
+	if (!memcmp(zero, entry->header.digest, sizeof(digest)))
 		return 0;
 
 	SHA1(entry->template, entry->template_len, digest);
@@ -1658,8 +1658,8 @@ static int ima_measurement(const char *file)
 	int i;
 
 	errno = 0;
-	memset(zero, 0, SHA_DIGEST_LENGTH);
-	memset(fox, 0xff, SHA_DIGEST_LENGTH);
+	memset(zero, 0, MAX_DIGEST_SIZE);
+	memset(fox, 0xff, MAX_DIGEST_SIZE);
 
 	log_debug("Initial PCR value: ");
 	log_debug_dump(pcr, sizeof(pcr));
-- 
2.7.5


  parent reply	other threads:[~2020-02-21 18:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21 18:38 [RFC PATCH 0/8] ima-evm-utils: calculate per TPM bank template digest Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 1/8] ima-evm-utils: treat unallocated banks as an error Mimi Zohar
2020-02-21 18:38 ` Mimi Zohar [this message]
2020-02-21 18:38 ` [RFC PATCH 3/8] ima-evm-utils: calculate the digests for multiple TPM banks Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 4/8] ima-evm-utils: add support in tpm2_read_pcrs to read different " Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 5/8] ima-evm-utils: read the PCRs for the requested " Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 6/8] ima-evm-utils: compare re-calculated PCRs with the TPM values Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 7/8] ima-evm-utils: use a common bank variable for TPM 1.2 and TPM 2.0 Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 8/8] ima-evm-utils: remove TPM 1.2 specific code Mimi Zohar
2020-02-22  0:11 ` [RFC PATCH 0/8] ima-evm-utils: calculate per TPM bank template digest Lakshmi Ramasubramanian
2020-02-23  1:12   ` Mimi Zohar
2020-02-24 16:23     ` Lakshmi Ramasubramanian

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=1582310338-1562-3-git-send-email-zohar@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=puiterwi@redhat.com \
    --cc=pvorel@suse.cz \
    --cc=roberto.sassu@huawei.com \
    --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.