All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Lachlan Sneff <t-josne@linux.microsoft.com>
Cc: zohar@linux.ibm.com, ltp@lists.linux.it,
	nramas@linux.microsoft.com, balajib@linux.microsoft.com,
	linux-integrity@vger.kernel.org
Subject: Re: [PATCH v5 1/2] IMA: Add a test to verify measurment of keys
Date: Wed, 15 Jul 2020 15:00:41 +0200	[thread overview]
Message-ID: <20200715130041.GA32414@dell5510> (raw)
In-Reply-To: <20200714181703.6374-2-t-josne@linux.microsoft.com>

Hi Lachlan, Mimi,

> Add a testcase that verifies that the IMA subsystem has correctly
> measured keys added to keyrings specified in the IMA policy file.

> Additionally, add support for handling a new IMA template descriptor,
> namely ima-buf[1], in the IMA measurement tests.

To speedup things, based on Mimi's comments and review of v4 I pushed this first
commit with few changes (below diff, only ima_keys.sh part)
* simplify error handling ($fail is not needed; I used tst_res and return
  because there will be second test, otherwise I'd use tst_brk)
* added modified docs into this commit
* fix commit title

TODO
* I'll send a patch to read CONFIG_IMA_X509_PATH (I've amended the commit
already enough)

* @Lachlan: expect you send another version for test2.

* @Lachlan: would you also implement Mimi's suggestion? [1]:
An additional test might be to verify that only the keys in the
measurement list are actually on the specified keyring and nothing
else.

Kind regards,
Petr

[1] http://lists.linux.it/pipermail/ltp/2020-July/018018.html

diff --git testcases/kernel/security/integrity/ima/tests/ima_keys.sh testcases/kernel/security/integrity/ima/tests/ima_keys.sh
index 4d53cd04f..904b7515b 100755
--- testcases/kernel/security/integrity/ima/tests/ima_keys.sh
+++ testcases/kernel/security/integrity/ima/tests/ima_keys.sh
@@ -15,7 +15,7 @@ TST_NEEDS_DEVICE=1
 # (450d0fd51564 - "IMA: Call workqueue functions to measure queued keys")
 test1()
 {
-	local keyrings keycheck_lines keycheck_line templates test_file="file.txt" fail
+	local keyrings keycheck_lines keycheck_line templates test_file="file.txt"
 
 	tst_res TINFO "verifying key measurement for keyrings and templates specified in IMA policy file"
 
@@ -57,15 +57,12 @@ test1()
 			tst_brk TCONF "cannot compute digest for $algorithm"
 
 		if [ "$digest" != "$expected_digest" ]; then
-			fail=1
 			tst_res TFAIL "incorrect digest was found for the ($keyring) keyring"
-			break
+			return
 		fi
 	done
 
-	if [ "$fail" ]; then
-		tst_res TPASS "specified keyrings were measured correctly"
-	fi
+	tst_res TPASS "specified keyrings were measured correctly"
 }
 
 tst_run

WARNING: multiple messages have this Message-ID (diff)
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v5 1/2] IMA: Add a test to verify measurment of keys
Date: Wed, 15 Jul 2020 15:00:41 +0200	[thread overview]
Message-ID: <20200715130041.GA32414@dell5510> (raw)
In-Reply-To: <20200714181703.6374-2-t-josne@linux.microsoft.com>

Hi Lachlan, Mimi,

> Add a testcase that verifies that the IMA subsystem has correctly
> measured keys added to keyrings specified in the IMA policy file.

> Additionally, add support for handling a new IMA template descriptor,
> namely ima-buf[1], in the IMA measurement tests.

To speedup things, based on Mimi's comments and review of v4 I pushed this first
commit with few changes (below diff, only ima_keys.sh part)
* simplify error handling ($fail is not needed; I used tst_res and return
  because there will be second test, otherwise I'd use tst_brk)
* added modified docs into this commit
* fix commit title

TODO
* I'll send a patch to read CONFIG_IMA_X509_PATH (I've amended the commit
already enough)

* @Lachlan: expect you send another version for test2.

* @Lachlan: would you also implement Mimi's suggestion? [1]:
An additional test might be to verify that only the keys in the
measurement list are actually on the specified keyring and nothing
else.

Kind regards,
Petr

[1] http://lists.linux.it/pipermail/ltp/2020-July/018018.html

diff --git testcases/kernel/security/integrity/ima/tests/ima_keys.sh testcases/kernel/security/integrity/ima/tests/ima_keys.sh
index 4d53cd04f..904b7515b 100755
--- testcases/kernel/security/integrity/ima/tests/ima_keys.sh
+++ testcases/kernel/security/integrity/ima/tests/ima_keys.sh
@@ -15,7 +15,7 @@ TST_NEEDS_DEVICE=1
 # (450d0fd51564 - "IMA: Call workqueue functions to measure queued keys")
 test1()
 {
-	local keyrings keycheck_lines keycheck_line templates test_file="file.txt" fail
+	local keyrings keycheck_lines keycheck_line templates test_file="file.txt"
 
 	tst_res TINFO "verifying key measurement for keyrings and templates specified in IMA policy file"
 
@@ -57,15 +57,12 @@ test1()
 			tst_brk TCONF "cannot compute digest for $algorithm"
 
 		if [ "$digest" != "$expected_digest" ]; then
-			fail=1
 			tst_res TFAIL "incorrect digest was found for the ($keyring) keyring"
-			break
+			return
 		fi
 	done
 
-	if [ "$fail" ]; then
-		tst_res TPASS "specified keyrings were measured correctly"
-	fi
+	tst_res TPASS "specified keyrings were measured correctly"
 }
 
 tst_run

  reply	other threads:[~2020-07-15 13:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 18:17 [PATCH v5 0/2] IMA: Verify measurement of certificates Lachlan Sneff
2020-07-14 18:17 ` [LTP] " Lachlan Sneff
2020-07-14 18:17 ` [PATCH v5 1/2] IMA: Add a test to verify measurment of keys Lachlan Sneff
2020-07-14 18:17   ` [LTP] " Lachlan Sneff
2020-07-15 13:00   ` Petr Vorel [this message]
2020-07-15 13:00     ` Petr Vorel
2020-07-14 18:17 ` [PATCH v5 2/2] IMA: Add a test to verify importing a certificate into keyring Lachlan Sneff
2020-07-14 18:17   ` [LTP] " Lachlan Sneff

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=20200715130041.GA32414@dell5510 \
    --to=pvorel@suse.cz \
    --cc=balajib@linux.microsoft.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    --cc=nramas@linux.microsoft.com \
    --cc=t-josne@linux.microsoft.com \
    --cc=zohar@linux.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.