All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] security/keys/trusted: Allow operation without hardware TPM
@ 2019-03-18 23:45 ` Dan Williams
  0 siblings, 0 replies; 50+ messages in thread
From: Dan Williams @ 2019-03-18 23:45 UTC (permalink / raw)
  To: jarkko.sakkinen
  Cc: linux-nvdimm, James Bottomley, Roberto Sassu, linux-kernel,
	Mimi Zohar, David Howells, keyrings

Rather than fail initialization of the trusted.ko module, arrange for
the module to load, but rely on trusted_instantiate() to fail
trusted-key operations.

Fixes: 240730437deb ("KEYS: trusted: explicitly use tpm_chip structure...")
Cc: Roberto Sassu <roberto.sassu@huawei.com>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Mimi Zohar <zohar@linux.ibm.com>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 security/keys/trusted.c |   21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/security/keys/trusted.c b/security/keys/trusted.c
index bcc9c6ead7fd..d959597a688e 100644
--- a/security/keys/trusted.c
+++ b/security/keys/trusted.c
@@ -45,6 +45,13 @@ struct sdesc {
 static struct crypto_shash *hashalg;
 static struct crypto_shash *hmacalg;
 
+static struct device *chip_dev(struct tpm_chip *chip)
+{
+	if (chip)
+		return &chip->dev;
+	return NULL;
+}
+
 static struct sdesc *init_sdesc(struct crypto_shash *alg)
 {
 	struct sdesc *sdesc;
@@ -1224,6 +1231,14 @@ static int __init init_digests(void)
 	int ret;
 	int i;
 
+	/*
+	 * Hardware tpm operations are disabled, but allow the software
+	 * module to initialize, and depend on trusted_instantiate() to
+	 * fail any attempts to access the missing hardware.
+	 */
+	if (!chip)
+		return 0;
+
 	ret = tpm_get_random(chip, digest, TPM_MAX_DIGEST_SIZE);
 	if (ret < 0)
 		return ret;
@@ -1246,8 +1261,6 @@ static int __init init_trusted(void)
 	int ret;
 
 	chip = tpm_default_chip();
-	if (!chip)
-		return -ENOENT;
 	ret = init_digests();
 	if (ret < 0)
 		goto err_put;
@@ -1263,13 +1276,13 @@ static int __init init_trusted(void)
 err_free:
 	kfree(digests);
 err_put:
-	put_device(&chip->dev);
+	put_device(chip_dev(chip));
 	return ret;
 }
 
 static void __exit cleanup_trusted(void)
 {
-	put_device(&chip->dev);
+	put_device(chip_dev(chip));
 	kfree(digests);
 	trusted_shash_release();
 	unregister_key_type(&key_type_trusted);

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2019-03-25 14:50 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 23:45 [PATCH] security/keys/trusted: Allow operation without hardware TPM Dan Williams
2019-03-18 23:45 ` Dan Williams
2019-03-18 23:45 ` Dan Williams
     [not found] ` <155295271345.1945351.6465460744078693578.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2019-03-19  0:24   ` James Bottomley
2019-03-19  0:24     ` James Bottomley
2019-03-19  0:24     ` James Bottomley
2019-03-19  0:30     ` Dan Williams
2019-03-19  0:30       ` Dan Williams
2019-03-19  0:30       ` Dan Williams
     [not found]       ` <CAA9_cmcOD2zPaaNbkYAaH5DRDRAebPkW+hwPA0zPKY4kU8R-rg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-03-19  0:56         ` James Bottomley
2019-03-19  0:56           ` James Bottomley
2019-03-19  0:56           ` James Bottomley
2019-03-19  1:34           ` Dan Williams
2019-03-19  1:34             ` Dan Williams
2019-03-19  1:34             ` Dan Williams
2019-03-20  1:55           ` Dan Williams
2019-03-20  1:55             ` Dan Williams
2019-03-20  1:55             ` Dan Williams
     [not found]             ` <CAPcyv4hXKQcdLnKG6rPNOJr2wjq31uCCr+16S5Yu6S5A_5UGrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-03-20  2:19               ` James Bottomley
2019-03-20  2:19                 ` James Bottomley
2019-03-20  2:19                 ` James Bottomley
2019-03-19 22:56         ` Mimi Zohar
2019-03-19 22:56           ` Mimi Zohar
2019-03-19 22:56           ` Mimi Zohar
2019-03-19 23:01           ` Dan Williams
2019-03-19 23:01             ` Dan Williams
2019-03-19 23:01             ` Dan Williams
2019-03-21 13:54 ` Jarkko Sakkinen
2019-03-21 13:54   ` Jarkko Sakkinen
2019-03-21 13:54   ` Jarkko Sakkinen
2019-03-21 14:26   ` Roberto Sassu
2019-03-21 14:26     ` Roberto Sassu
2019-03-21 14:26     ` Roberto Sassu
2019-03-21 16:30     ` Dan Williams
2019-03-21 16:30       ` Dan Williams
2019-03-21 16:30       ` Dan Williams
     [not found]       ` <CAPcyv4gc_KWedC12bTcX24KwjKiBCF=yvouRNzCbJKaLrgJdDg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-03-21 17:45         ` Roberto Sassu
2019-03-21 17:45           ` Roberto Sassu
2019-03-21 17:45           ` Roberto Sassu
2019-03-22 10:12           ` Jarkko Sakkinen
2019-03-22 10:12             ` Jarkko Sakkinen
2019-03-22 15:24             ` Dan Williams
2019-03-22 15:24               ` Dan Williams
2019-03-22 15:24               ` Dan Williams
2019-03-25 14:12               ` Jarkko Sakkinen
2019-03-25 14:12                 ` Jarkko Sakkinen
2019-03-25 14:12                 ` Jarkko Sakkinen
2019-03-25 14:50                 ` Jarkko Sakkinen
2019-03-25 14:50                   ` Jarkko Sakkinen
2019-03-25 14:50                   ` Jarkko Sakkinen

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.