All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <petr.vorel@gmail.com>
To: linux-integrity@vger.kernel.org
Cc: Petr Vorel <petr.vorel@gmail.com>, Mimi Zohar <zohar@linux.vnet.ibm.com>
Subject: [PATCH ima-evm-utils] boot_aggregate.test: Skip if CONFIG_IMA not enabled
Date: Mon, 19 Oct 2020 22:08:03 +0200	[thread overview]
Message-ID: <20201019200803.35255-1-petr.vorel@gmail.com> (raw)

This is required, because when TPM HW available (i.e. -c /dev/tpm0),
evmctl ima_boot_aggregate returns sha1:xxxx.

skip requires to move cleanup().

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Hi Mimi,

this Fixes problems on current Debian, which has still disabled CONFIG_IMA
(FYI [1]). I was not able to figure out how to get it working with
sample-* files, but maybe there is a way.

Although it sound strange, people may want to build and check evmctl
even on a system with disabled CONFIG_IMA (both Debian and Ubuntu have
outdated ima-evm-utils (1.1)).

Kind regards,
Petr

[1] https://bugs.debian.org/972459 linux: Reenable CONFIG_IMA

 tests/boot_aggregate.test | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/tests/boot_aggregate.test b/tests/boot_aggregate.test
index 42ed7b4..5fd4204 100755
--- a/tests/boot_aggregate.test
+++ b/tests/boot_aggregate.test
@@ -26,21 +26,6 @@ TSSDIR="$(dirname -- "$(which tssstartup)")"
 PCRFILE="/sys/class/tpm/tpm0/device/pcrs"
 MISC_PCRFILE="/sys/class/misc/tpm0/device/pcrs"
 
-if [ "$(id -u)" = 0 ] && [ -c "/dev/tpm0" ]; then
-	ASCII_RUNTIME_MEASUREMENTS="/sys/kernel/security/ima/ascii_runtime_measurements"
-else
-	BINARY_BIOS_MEASUREMENTS="./sample-binary_bios_measurements-pcrs-8-9"
-	ASCII_RUNTIME_MEASUREMENTS="./sample-ascii_runtime_measurements-pcrs-8-9"
-	export TPM_INTERFACE_TYPE="socsim"
-	export TPM_COMMAND_PORT=2321
-	export TPM_PLATFORM_PORT=2322
-	export TPM_SERVER_NAME="localhost"
-
-	# swtpm uses the raw, unencapsulated packet format
-	export TPM_SERVER_TYPE="raw"
-
-fi
-
 # Only stop this test's software TPM
 cleanup() {
 	if [ -n "${SWTPM_PID}" ]; then
@@ -165,6 +150,26 @@ check() {
 	return "$FAIL"
 }
 
+if [ ! -d "/sys/kernel/security/ima" ]; then
+	echo "${CYAN}SKIP: CONFIG_IMA not enabled${NORM}"
+	exit "$SKIP"
+fi
+
+if [ "$(id -u)" = 0 ] && [ -c "/dev/tpm0" ]; then
+	ASCII_RUNTIME_MEASUREMENTS="/sys/kernel/security/ima/ascii_runtime_measurements"
+else
+	BINARY_BIOS_MEASUREMENTS="./sample-binary_bios_measurements-pcrs-8-9"
+	ASCII_RUNTIME_MEASUREMENTS="./sample-ascii_runtime_measurements-pcrs-8-9"
+	export TPM_INTERFACE_TYPE="socsim"
+	export TPM_COMMAND_PORT=2321
+	export TPM_PLATFORM_PORT=2322
+	export TPM_SERVER_NAME="localhost"
+
+	# swtpm uses the raw, unencapsulated packet format
+	export TPM_SERVER_TYPE="raw"
+
+fi
+
 # Start and initialize a software TPM as needed
 if [ "$(id -u)" != 0 ] || [ ! -c "/dev/tpm0" ]; then
 	if [ -f "$PCRFILE" ] || [ -f "$MISC_PCRFILE" ]; then
-- 
2.27.0.rc0


             reply	other threads:[~2020-10-19 20:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 20:08 Petr Vorel [this message]
2020-10-19 23:10 ` [PATCH ima-evm-utils] boot_aggregate.test: Skip if CONFIG_IMA not enabled Mimi Zohar
2020-10-20 18:02   ` Petr Vorel
2020-10-27 16:06     ` Mimi Zohar
2020-10-27 18:51       ` Mikhail Novosyolov
2020-10-27 19:06         ` Mimi Zohar
2020-10-27 19:29           ` Mikhail Novosyolov
2020-10-27 20:01             ` Petr Vorel
2020-10-27 18:49     ` Tyler Hicks
2020-10-27 18:57       ` Mikhail Novosyolov
2020-10-23 12:46   ` Mimi Zohar

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=20201019200803.35255-1-petr.vorel@gmail.com \
    --to=petr.vorel@gmail.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=zohar@linux.vnet.ibm.com \
    /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.