* [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data
2022-11-11 23:16 [PATCH v5 00/11] Encrypted Hibernation Evan Green
@ 2022-11-11 23:16 ` Evan Green
2022-11-13 21:20 ` Eric Biggers
2022-11-11 23:16 ` [PATCH v5 05/11] security: keys: trusted: Allow storage of PCR values in " Evan Green
` (2 subsequent siblings)
3 siblings, 1 reply; 15+ messages in thread
From: Evan Green @ 2022-11-11 23:16 UTC (permalink / raw)
To: linux-kernel
Cc: corbet, linux-integrity, Eric Biggers, gwendal, dianders, apronin,
Pavel Machek, Ben Boeckel, rjw, jejb, Kees Cook, dlunev, zohar,
Matthew Garrett, jarkko, linux-pm, Evan Green, David Howells,
James Morris, Paul Moore, Serge E. Hallyn, keyrings,
linux-security-module
In addition to the private key and public key, the TPM2_Create
command may also return creation data, a creation hash, and a creation
ticket. These fields allow the TPM to attest to the contents of a
specified set of PCRs at the time the trusted key was created. Encrypted
hibernation will use this to ensure that PCRs settable only by the
kernel were set properly at the time of creation, indicating this is an
authentic hibernate key.
Encode these additional parameters into the ASN.1 created to represent
the key blob. The new fields are made optional so that they don't bloat
key blobs which don't need them, and to ensure interoperability with
old blobs.
Signed-off-by: Evan Green <evgreen@chromium.org>
---
Changes in v5:
- Factored some math out to a helper function (Kees)
- Constified src in tpm2_key_encode().
Changes in v3:
- Fix SoB and -- note ordering (Kees)
- Add comments describing the TPM2 spec type names for the new fields
in tpm2key.asn1 (Kees)
- Add len buffer checks in tpm2_key_encode() (Kees)
This is a replacement for Matthew's original patch here:
https://patchwork.kernel.org/patch/12096489/
That patch was written before the exported key format was switched to
ASN.1. This patch accomplishes the same thing (saving, loading, and
getting pointers to the creation data) while utilizing the new ASN.1
format.
---
include/keys/trusted-type.h | 8 +
security/keys/trusted-keys/tpm2key.asn1 | 15 +-
security/keys/trusted-keys/trusted_tpm2.c | 253 +++++++++++++++++++---
3 files changed, 245 insertions(+), 31 deletions(-)
diff --git a/include/keys/trusted-type.h b/include/keys/trusted-type.h
index 4eb64548a74f1a..209086fed240a5 100644
--- a/include/keys/trusted-type.h
+++ b/include/keys/trusted-type.h
@@ -22,15 +22,23 @@
#define MAX_BLOB_SIZE 512
#define MAX_PCRINFO_SIZE 64
#define MAX_DIGEST_SIZE 64
+#define MAX_CREATION_DATA 412
+#define MAX_TK 76
struct trusted_key_payload {
struct rcu_head rcu;
unsigned int key_len;
unsigned int blob_len;
+ unsigned int creation_len;
+ unsigned int creation_hash_len;
+ unsigned int tk_len;
unsigned char migratable;
unsigned char old_format;
unsigned char key[MAX_KEY_SIZE + 1];
unsigned char blob[MAX_BLOB_SIZE];
+ unsigned char *creation;
+ unsigned char *creation_hash;
+ unsigned char *tk;
};
struct trusted_key_options {
diff --git a/security/keys/trusted-keys/tpm2key.asn1 b/security/keys/trusted-keys/tpm2key.asn1
index f57f869ad60068..608f8d9ca95fa8 100644
--- a/security/keys/trusted-keys/tpm2key.asn1
+++ b/security/keys/trusted-keys/tpm2key.asn1
@@ -7,5 +7,18 @@ TPMKey ::= SEQUENCE {
emptyAuth [0] EXPLICIT BOOLEAN OPTIONAL,
parent INTEGER ({tpm2_key_parent}),
pubkey OCTET STRING ({tpm2_key_pub}),
- privkey OCTET STRING ({tpm2_key_priv})
+ privkey OCTET STRING ({tpm2_key_priv}),
+ ---
+ --- A TPM2B_CREATION_DATA struct as returned from the TPM2_Create command.
+ ---
+ creationData [1] EXPLICIT OCTET STRING OPTIONAL ({tpm2_key_creation_data}),
+ ---
+ --- A TPM2B_DIGEST of the creationHash as returned from the TPM2_Create
+ --- command.
+ ---
+ creationHash [2] EXPLICIT OCTET STRING OPTIONAL ({tpm2_key_creation_hash}),
+ ---
+ --- A TPMT_TK_CREATION ticket as returned from the TPM2_Create command.
+ ---
+ creationTk [3] EXPLICIT OCTET STRING OPTIONAL ({tpm2_key_creation_tk})
}
diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
index 2b2c8eb258d5bd..ff2aede8986236 100644
--- a/security/keys/trusted-keys/trusted_tpm2.c
+++ b/security/keys/trusted-keys/trusted_tpm2.c
@@ -28,24 +28,86 @@ static struct tpm2_hash tpm2_hash_map[] = {
static u32 tpm2key_oid[] = { 2, 23, 133, 10, 1, 5 };
+/* Helper function to advance past a __be16 length + buffer safely */
+static const u8 *get_sized_section(const u8 *src, const u8 *end, u16 *len)
+{
+ u32 length;
+
+ if (src + sizeof(u16) > end)
+ return NULL;
+
+ /* Include the size field in the returned section length. */
+ length = get_unaligned_be16(src) + sizeof(u16);
+ *len = length;
+ if (*len != length)
+ return NULL;
+
+ src += *len;
+ if (src > end)
+ return NULL;
+
+ return src;
+}
+
static int tpm2_key_encode(struct trusted_key_payload *payload,
struct trusted_key_options *options,
- u8 *src, u32 len)
+ const u8 *src, u32 len)
{
const int SCRATCH_SIZE = PAGE_SIZE;
+ const u8 *end = src + len;
u8 *scratch = kmalloc(SCRATCH_SIZE, GFP_KERNEL);
u8 *work = scratch, *work1;
u8 *end_work = scratch + SCRATCH_SIZE;
- u8 *priv, *pub;
+ const u8 *priv, *pub;
+ const u8 *creation_data = NULL, *creation_hash = NULL, *creation_tk = NULL;
+ u16 creation_data_len, creation_hash_len = 0, creation_tk_len = 0;
u16 priv_len, pub_len;
+ int rc;
- priv_len = get_unaligned_be16(src) + 2;
priv = src;
+ src = get_sized_section(src, end, &priv_len);
+ if (!src)
+ return -EINVAL;
- src += priv_len;
-
- pub_len = get_unaligned_be16(src) + 2;
pub = src;
+ src = get_sized_section(src, end, &pub_len);
+ if (!src)
+ return -EINVAL;
+
+ creation_data = src;
+ src = get_sized_section(src, end, &creation_data_len);
+ if (!src)
+ return -EINVAL;
+
+ /*
+ * If the creation data has content, pull out the creation hash and
+ * ticket as well. Otherwise pretend it doesn't exist.
+ */
+ if (creation_data_len > sizeof(u16)) {
+ creation_hash = src;
+ src = get_sized_section(src, end, &creation_hash_len);
+ if (!src)
+ return -EINVAL;
+
+ /*
+ * The creation ticket (TPMT_TK_CREATION) consists of a 2 byte
+ * tag, 4 byte handle, and then a TPM2B_DIGEST, which is a 2
+ * byte length followed by data.
+ */
+ if (src + 8 > end)
+ return -EINVAL;
+
+ creation_tk = src;
+ src = get_sized_section(src + 6, end, &creation_tk_len);
+ if (!src)
+ return -EINVAL;
+
+ creation_tk_len += 6;
+
+ } else {
+ creation_data_len = 0;
+ creation_data = NULL;
+ }
if (!scratch)
return -ENOMEM;
@@ -63,26 +125,81 @@ static int tpm2_key_encode(struct trusted_key_payload *payload,
}
/*
- * Assume both octet strings will encode to a 2 byte definite length
+ * Assume each octet string will encode to a 2 byte definite length.
+ * Each optional octet string consumes one extra byte.
*
- * Note: For a well behaved TPM, this warning should never
- * trigger, so if it does there's something nefarious going on
+ * Note: For a well behaved TPM, this warning should never trigger, so
+ * if it does there's something nefarious going on
*/
- if (WARN(work - scratch + pub_len + priv_len + 14 > SCRATCH_SIZE,
- "BUG: scratch buffer is too small"))
- return -EINVAL;
+ if (WARN(work - scratch + pub_len + priv_len + creation_data_len +
+ creation_hash_len + creation_tk_len + (7 * 5) + 3 >
+ SCRATCH_SIZE,
+ "BUG: scratch buffer is too small")) {
+ rc = -EINVAL;
+ goto err;
+ }
work = asn1_encode_integer(work, end_work, options->keyhandle);
work = asn1_encode_octet_string(work, end_work, pub, pub_len);
work = asn1_encode_octet_string(work, end_work, priv, priv_len);
+ if (creation_data_len) {
+ u8 *scratch2 = kmalloc(SCRATCH_SIZE, GFP_KERNEL);
+ u8 *work2;
+ u8 *end_work2 = scratch2 + SCRATCH_SIZE;
+
+ if (!scratch2) {
+ rc = -ENOMEM;
+ goto err;
+ }
+
+ work2 = asn1_encode_octet_string(scratch2,
+ end_work2,
+ creation_data,
+ creation_data_len);
+
+ work = asn1_encode_tag(work,
+ end_work,
+ 1,
+ scratch2,
+ work2 - scratch2);
+
+ work2 = asn1_encode_octet_string(scratch2,
+ end_work2,
+ creation_hash,
+ creation_hash_len);
+
+ work = asn1_encode_tag(work,
+ end_work,
+ 2,
+ scratch2,
+ work2 - scratch2);
+
+ work2 = asn1_encode_octet_string(scratch2,
+ end_work2,
+ creation_tk,
+ creation_tk_len);
+
+ work = asn1_encode_tag(work,
+ end_work,
+ 3,
+ scratch2,
+ work2 - scratch2);
+
+ kfree(scratch2);
+ }
work1 = payload->blob;
work1 = asn1_encode_sequence(work1, work1 + sizeof(payload->blob),
scratch, work - scratch);
- if (WARN(IS_ERR(work1), "BUG: ASN.1 encoder failed"))
- return PTR_ERR(work1);
+ if (WARN(IS_ERR(work1), "BUG: ASN.1 encoder failed")) {
+ rc = PTR_ERR(work1);
+ goto err;
+ }
return work1 - payload->blob;
+err:
+ kfree(scratch);
+ return rc;
}
struct tpm2_key_context {
@@ -91,15 +208,21 @@ struct tpm2_key_context {
u32 pub_len;
const u8 *priv;
u32 priv_len;
+ const u8 *creation_data;
+ u32 creation_data_len;
+ const u8 *creation_hash;
+ u32 creation_hash_len;
+ const u8 *creation_tk;
+ u32 creation_tk_len;
};
static int tpm2_key_decode(struct trusted_key_payload *payload,
- struct trusted_key_options *options,
- u8 **buf)
+ struct trusted_key_options *options)
{
+ u64 data_len;
int ret;
struct tpm2_key_context ctx;
- u8 *blob;
+ u8 *blob, *buf;
memset(&ctx, 0, sizeof(ctx));
@@ -108,21 +231,57 @@ static int tpm2_key_decode(struct trusted_key_payload *payload,
if (ret < 0)
return ret;
- if (ctx.priv_len + ctx.pub_len > MAX_BLOB_SIZE)
+ data_len = ctx.priv_len + ctx.pub_len + ctx.creation_data_len +
+ ctx.creation_hash_len + ctx.creation_tk_len;
+
+ if (data_len > MAX_BLOB_SIZE)
return -EINVAL;
- blob = kmalloc(ctx.priv_len + ctx.pub_len + 4, GFP_KERNEL);
- if (!blob)
+ buf = kmalloc(data_len + 4, GFP_KERNEL);
+ if (!buf)
return -ENOMEM;
- *buf = blob;
+ blob = buf;
options->keyhandle = ctx.parent;
memcpy(blob, ctx.priv, ctx.priv_len);
blob += ctx.priv_len;
memcpy(blob, ctx.pub, ctx.pub_len);
+ blob += ctx.pub_len;
+ if (ctx.creation_data_len) {
+ memcpy(blob, ctx.creation_data, ctx.creation_data_len);
+ blob += ctx.creation_data_len;
+ }
+ if (ctx.creation_hash_len) {
+ memcpy(blob, ctx.creation_hash, ctx.creation_hash_len);
+ blob += ctx.creation_hash_len;
+ }
+
+ if (ctx.creation_tk_len) {
+ memcpy(blob, ctx.creation_tk, ctx.creation_tk_len);
+ blob += ctx.creation_tk_len;
+ }
+
+ /*
+ * Copy the buffer back into the payload blob since the creation
+ * info will be used after loading.
+ */
+ payload->blob_len = blob - buf;
+ memcpy(payload->blob, buf, payload->blob_len);
+ if (ctx.creation_data_len) {
+ payload->creation = payload->blob + ctx.priv_len + ctx.pub_len;
+ payload->creation_len = ctx.creation_data_len;
+ payload->creation_hash = payload->creation + ctx.creation_data_len;
+ payload->creation_hash_len = ctx.creation_hash_len;
+ payload->tk = payload->creation_hash +
+ payload->creation_hash_len;
+
+ payload->tk_len = ctx.creation_tk_len;
+ }
+
+ kfree(buf);
return 0;
}
@@ -185,6 +344,42 @@ int tpm2_key_priv(void *context, size_t hdrlen,
return 0;
}
+int tpm2_key_creation_data(void *context, size_t hdrlen,
+ unsigned char tag,
+ const void *value, size_t vlen)
+{
+ struct tpm2_key_context *ctx = context;
+
+ ctx->creation_data = value;
+ ctx->creation_data_len = vlen;
+
+ return 0;
+}
+
+int tpm2_key_creation_hash(void *context, size_t hdrlen,
+ unsigned char tag,
+ const void *value, size_t vlen)
+{
+ struct tpm2_key_context *ctx = context;
+
+ ctx->creation_hash = value;
+ ctx->creation_hash_len = vlen;
+
+ return 0;
+}
+
+int tpm2_key_creation_tk(void *context, size_t hdrlen,
+ unsigned char tag,
+ const void *value, size_t vlen)
+{
+ struct tpm2_key_context *ctx = context;
+
+ ctx->creation_tk = value;
+ ctx->creation_tk_len = vlen;
+
+ return 0;
+}
+
/**
* tpm_buf_append_auth() - append TPMS_AUTH_COMMAND to the buffer.
*
@@ -229,6 +424,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
struct trusted_key_options *options)
{
int blob_len = 0;
+ unsigned int offset;
struct tpm_buf buf;
u32 hash;
u32 flags;
@@ -317,13 +513,14 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
rc = -E2BIG;
goto out;
}
- if (tpm_buf_length(&buf) < TPM_HEADER_SIZE + 4 + blob_len) {
+ offset = TPM_HEADER_SIZE + 4;
+ if (tpm_buf_length(&buf) < offset + blob_len) {
rc = -EFAULT;
goto out;
}
blob_len = tpm2_key_encode(payload, options,
- &buf.data[TPM_HEADER_SIZE + 4],
+ &buf.data[offset],
blob_len);
out:
@@ -370,13 +567,11 @@ static int tpm2_load_cmd(struct tpm_chip *chip,
int rc;
u32 attrs;
- rc = tpm2_key_decode(payload, options, &blob);
- if (rc) {
- /* old form */
- blob = payload->blob;
+ rc = tpm2_key_decode(payload, options);
+ if (rc)
payload->old_format = 1;
- }
+ blob = payload->blob;
/* new format carries keyhandle but old format doesn't */
if (!options->keyhandle)
return -EINVAL;
@@ -433,8 +628,6 @@ static int tpm2_load_cmd(struct tpm_chip *chip,
(__be32 *) &buf.data[TPM_HEADER_SIZE]);
out:
- if (blob != payload->blob)
- kfree(blob);
tpm_buf_destroy(&buf);
if (rc > 0)
--
2.38.1.431.g37b22c650d-goog
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data
2022-11-11 23:16 ` [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data Evan Green
@ 2022-11-13 21:20 ` Eric Biggers
2022-11-14 3:32 ` James Bottomley
0 siblings, 1 reply; 15+ messages in thread
From: Eric Biggers @ 2022-11-13 21:20 UTC (permalink / raw)
To: Evan Green
Cc: linux-kernel, corbet, linux-integrity, gwendal, dianders, apronin,
Pavel Machek, Ben Boeckel, rjw, jejb, Kees Cook, dlunev, zohar,
Matthew Garrett, jarkko, linux-pm, David Howells, James Morris,
Paul Moore, Serge E. Hallyn, keyrings, linux-security-module
On Fri, Nov 11, 2022 at 03:16:29PM -0800, Evan Green wrote:
> diff --git a/security/keys/trusted-keys/tpm2key.asn1 b/security/keys/trusted-keys/tpm2key.asn1
> index f57f869ad60068..608f8d9ca95fa8 100644
> --- a/security/keys/trusted-keys/tpm2key.asn1
> +++ b/security/keys/trusted-keys/tpm2key.asn1
> @@ -7,5 +7,18 @@ TPMKey ::= SEQUENCE {
> emptyAuth [0] EXPLICIT BOOLEAN OPTIONAL,
> parent INTEGER ({tpm2_key_parent}),
> pubkey OCTET STRING ({tpm2_key_pub}),
> - privkey OCTET STRING ({tpm2_key_priv})
> + privkey OCTET STRING ({tpm2_key_priv}),
> + ---
> + --- A TPM2B_CREATION_DATA struct as returned from the TPM2_Create command.
> + ---
> + creationData [1] EXPLICIT OCTET STRING OPTIONAL ({tpm2_key_creation_data}),
> + ---
> + --- A TPM2B_DIGEST of the creationHash as returned from the TPM2_Create
> + --- command.
> + ---
> + creationHash [2] EXPLICIT OCTET STRING OPTIONAL ({tpm2_key_creation_hash}),
> + ---
> + --- A TPMT_TK_CREATION ticket as returned from the TPM2_Create command.
> + ---
> + creationTk [3] EXPLICIT OCTET STRING OPTIONAL ({tpm2_key_creation_tk})
> }
The commit that added this file claimed:
"The benefit of the ASN.1 format is that it's a standard and thus the
exported key can be used by userspace tools (openssl_tpm2_engine,
openconnect and tpm2-tss-engine"
Are these new fields in compliance with whatever standard that was referring to?
Or was that just referring to ASN.1 itself?
> +/* Helper function to advance past a __be16 length + buffer safely */
> +static const u8 *get_sized_section(const u8 *src, const u8 *end, u16 *len)
> +{
> + u32 length;
> +
> + if (src + sizeof(u16) > end)
> + return NULL;
'end - src < sizeof(u16)', so the pointer isn't advanced past the end.
> +
> + /* Include the size field in the returned section length. */
> + length = get_unaligned_be16(src) + sizeof(u16);
> + *len = length;
> + if (*len != length)
> + return NULL;
> +
> + src += *len;
> + if (src > end)
> + return NULL;
> +
> + return src;
Similarly:
if (end - src < *len)
return NULL;
return src + *len;
> + /*
> + * The creation ticket (TPMT_TK_CREATION) consists of a 2 byte
> + * tag, 4 byte handle, and then a TPM2B_DIGEST, which is a 2
> + * byte length followed by data.
> + */
> + if (src + 8 > end)
end - src < 8
And actually it really should be 6 instead of 8, to match the code below.
get_sized_section() already validates that there are at least 2 more bytes.
> + return -EINVAL;
> +
> + creation_tk = src;
> + src = get_sized_section(src + 6, end, &creation_tk_len);
> + if (!src)
> + return -EINVAL;
> +
> + creation_tk_len += 6;
> +
> + } else {
> + creation_data_len = 0;
> + creation_data = NULL;
> + }
>
> if (!scratch)
> return -ENOMEM;
> @@ -63,26 +125,81 @@ static int tpm2_key_encode(struct trusted_key_payload *payload,
> }
>
> /*
> - * Assume both octet strings will encode to a 2 byte definite length
> + * Assume each octet string will encode to a 2 byte definite length.
> + * Each optional octet string consumes one extra byte.
> *
> - * Note: For a well behaved TPM, this warning should never
> - * trigger, so if it does there's something nefarious going on
> + * Note: For a well behaved TPM, this warning should never trigger, so
> + * if it does there's something nefarious going on
> */
> - if (WARN(work - scratch + pub_len + priv_len + 14 > SCRATCH_SIZE,
> - "BUG: scratch buffer is too small"))
> - return -EINVAL;
> + if (WARN(work - scratch + pub_len + priv_len + creation_data_len +
> + creation_hash_len + creation_tk_len + (7 * 5) + 3 >
> + SCRATCH_SIZE,
> + "BUG: scratch buffer is too small")) {
> + rc = -EINVAL;
> + goto err;
> + }
This appears to be fixing a memory leak in the error case.
The same memory leak also still appears above in:
if (WARN(IS_ERR(w), "BUG: Boolean failed to encode"))
return PTR_ERR(w);
Maybe both should be fixed in a separate patch.
> + work2 = asn1_encode_octet_string(scratch2,
> + end_work2,
> + creation_data,
> + creation_data_len);
> +
> + work = asn1_encode_tag(work,
> + end_work,
> + 1,
> + scratch2,
> + work2 - scratch2);
There's no helper function to do these two steps together?
> +
> - if (WARN(IS_ERR(work1), "BUG: ASN.1 encoder failed"))
> - return PTR_ERR(work1);
> + if (WARN(IS_ERR(work1), "BUG: ASN.1 encoder failed")) {
> + rc = PTR_ERR(work1);
> + goto err;
> + }
>
> return work1 - payload->blob;
> +err:
> + kfree(scratch);
> + return rc;
Is this another memory leak fix that is unrelated to the functionality added by
this patch?
Also, isn't 'scratch' still being leaked in the success case?
> static int tpm2_key_decode(struct trusted_key_payload *payload,
> - struct trusted_key_options *options,
> - u8 **buf)
> + struct trusted_key_options *options)
> {
> + u64 data_len;
> int ret;
> struct tpm2_key_context ctx;
> - u8 *blob;
> + u8 *blob, *buf;
>
> memset(&ctx, 0, sizeof(ctx));
>
> @@ -108,21 +231,57 @@ static int tpm2_key_decode(struct trusted_key_payload *payload,
> if (ret < 0)
> return ret;
>
> - if (ctx.priv_len + ctx.pub_len > MAX_BLOB_SIZE)
> + data_len = ctx.priv_len + ctx.pub_len + ctx.creation_data_len +
> + ctx.creation_hash_len + ctx.creation_tk_len;
It's unclear why 'data_len' is a u64, given that the value assigned to it always
fits in a u32. Perhaps you intended to do the additions with 64-bit numbers so
that they can't overflow.
But shouldn't the lengths already be bounded by size of the ASN.1 blob before
even reaching here, anyway?
> +
> + if (data_len > MAX_BLOB_SIZE)
> return -EINVAL;
>
> - blob = kmalloc(ctx.priv_len + ctx.pub_len + 4, GFP_KERNEL);
> - if (!blob)
> + buf = kmalloc(data_len + 4, GFP_KERNEL);
> + if (!buf)
> return -ENOMEM;
It's unclear what the '+ 4' is for.
> @@ -229,6 +424,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
> struct trusted_key_options *options)
> {
> int blob_len = 0;
> + unsigned int offset;
> struct tpm_buf buf;
> u32 hash;
> u32 flags;
> @@ -317,13 +513,14 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
> rc = -E2BIG;
> goto out;
> }
> - if (tpm_buf_length(&buf) < TPM_HEADER_SIZE + 4 + blob_len) {
> + offset = TPM_HEADER_SIZE + 4;
> + if (tpm_buf_length(&buf) < offset + blob_len) {
> rc = -EFAULT;
> goto out;
> }
>
> blob_len = tpm2_key_encode(payload, options,
> - &buf.data[TPM_HEADER_SIZE + 4],
> + &buf.data[offset],
> blob_len);
This hunk of the patch doesn't seem to serve any purpose.
- Eric
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data
2022-11-13 21:20 ` Eric Biggers
@ 2022-11-14 3:32 ` James Bottomley
2022-11-14 16:32 ` Evan Green
0 siblings, 1 reply; 15+ messages in thread
From: James Bottomley @ 2022-11-14 3:32 UTC (permalink / raw)
To: Eric Biggers, Evan Green
Cc: linux-kernel, corbet, linux-integrity, gwendal, dianders, apronin,
Pavel Machek, Ben Boeckel, rjw, Kees Cook, dlunev, zohar,
Matthew Garrett, jarkko, linux-pm, David Howells, James Morris,
Paul Moore, Serge E. Hallyn, keyrings, linux-security-module
On Sun, 2022-11-13 at 13:20 -0800, Eric Biggers wrote:
> On Fri, Nov 11, 2022 at 03:16:29PM -0800, Evan Green wrote:
> > diff --git a/security/keys/trusted-keys/tpm2key.asn1
> > b/security/keys/trusted-keys/tpm2key.asn1
> > index f57f869ad60068..608f8d9ca95fa8 100644
> > --- a/security/keys/trusted-keys/tpm2key.asn1
> > +++ b/security/keys/trusted-keys/tpm2key.asn1
> > @@ -7,5 +7,18 @@ TPMKey ::= SEQUENCE {
> > emptyAuth [0] EXPLICIT BOOLEAN OPTIONAL,
> > parent INTEGER ({tpm2_key_parent}),
> > pubkey OCTET STRING ({tpm2_key_pub}),
> > - privkey OCTET STRING ({tpm2_key_priv})
> > + privkey OCTET STRING ({tpm2_key_priv}),
> > + ---
> > + --- A TPM2B_CREATION_DATA struct as returned from the
> > TPM2_Create command.
> > + ---
> > + creationData [1] EXPLICIT OCTET STRING OPTIONAL
> > ({tpm2_key_creation_data}),
> > + ---
> > + --- A TPM2B_DIGEST of the creationHash as returned from the
> > TPM2_Create
> > + --- command.
> > + ---
> > + creationHash [2] EXPLICIT OCTET STRING OPTIONAL
> > ({tpm2_key_creation_hash}),
> > + ---
> > + --- A TPMT_TK_CREATION ticket as returned from the
> > TPM2_Create command.
> > + ---
> > + creationTk [3] EXPLICIT OCTET STRING OPTIONAL
> > ({tpm2_key_creation_tk})
> > }
>
> The commit that added this file claimed:
>
> "The benefit of the ASN.1 format is that it's a standard and
> thus the
> exported key can be used by userspace tools
> (openssl_tpm2_engine,
> openconnect and tpm2-tss-engine"
>
> Are these new fields in compliance with whatever standard that was
> referring to?
Not really, no. The current use case (and draft standard) is already
using [1] for policies and [2] for importable keys:
https://git.kernel.org/pub/scm/linux/kernel/git/jejb/openssl_tpm2_engine.git/tree/doc/draft-bottomley-tpm2-keys.xml
I'm actually planning to use [3] for signed policies. There's no
reason why you can't use [4] though. Since the creation data, hash and
ticket are likely used as a job lot, it strikes me they should be a
single numbered optional sequence instead of individually numbered,
since you're unlikely to have one without the others.
James
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data
2022-11-14 3:32 ` James Bottomley
@ 2022-11-14 16:32 ` Evan Green
2022-11-14 16:56 ` James Bottomley
0 siblings, 1 reply; 15+ messages in thread
From: Evan Green @ 2022-11-14 16:32 UTC (permalink / raw)
To: jejb
Cc: Eric Biggers, linux-kernel, corbet, linux-integrity, gwendal,
dianders, apronin, Pavel Machek, Ben Boeckel, rjw, Kees Cook,
dlunev, zohar, Matthew Garrett, jarkko, linux-pm, David Howells,
James Morris, Paul Moore, Serge E. Hallyn, keyrings,
linux-security-module
On Sun, Nov 13, 2022 at 7:32 PM James Bottomley <jejb@linux.ibm.com> wrote:
>
> On Sun, 2022-11-13 at 13:20 -0800, Eric Biggers wrote:
> > On Fri, Nov 11, 2022 at 03:16:29PM -0800, Evan Green wrote:
> > > diff --git a/security/keys/trusted-keys/tpm2key.asn1
> > > b/security/keys/trusted-keys/tpm2key.asn1
> > > index f57f869ad60068..608f8d9ca95fa8 100644
> > > --- a/security/keys/trusted-keys/tpm2key.asn1
> > > +++ b/security/keys/trusted-keys/tpm2key.asn1
> > > @@ -7,5 +7,18 @@ TPMKey ::= SEQUENCE {
> > > emptyAuth [0] EXPLICIT BOOLEAN OPTIONAL,
> > > parent INTEGER ({tpm2_key_parent}),
> > > pubkey OCTET STRING ({tpm2_key_pub}),
> > > - privkey OCTET STRING ({tpm2_key_priv})
> > > + privkey OCTET STRING ({tpm2_key_priv}),
> > > + ---
> > > + --- A TPM2B_CREATION_DATA struct as returned from the
> > > TPM2_Create command.
> > > + ---
> > > + creationData [1] EXPLICIT OCTET STRING OPTIONAL
> > > ({tpm2_key_creation_data}),
> > > + ---
> > > + --- A TPM2B_DIGEST of the creationHash as returned from the
> > > TPM2_Create
> > > + --- command.
> > > + ---
> > > + creationHash [2] EXPLICIT OCTET STRING OPTIONAL
> > > ({tpm2_key_creation_hash}),
> > > + ---
> > > + --- A TPMT_TK_CREATION ticket as returned from the
> > > TPM2_Create command.
> > > + ---
> > > + creationTk [3] EXPLICIT OCTET STRING OPTIONAL
> > > ({tpm2_key_creation_tk})
> > > }
> >
> > The commit that added this file claimed:
> >
> > "The benefit of the ASN.1 format is that it's a standard and
> > thus the
> > exported key can be used by userspace tools
> > (openssl_tpm2_engine,
> > openconnect and tpm2-tss-engine"
> >
> > Are these new fields in compliance with whatever standard that was
> > referring to?
>
> Not really, no. The current use case (and draft standard) is already
> using [1] for policies and [2] for importable keys:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/jejb/openssl_tpm2_engine.git/tree/doc/draft-bottomley-tpm2-keys.xml
>
> I'm actually planning to use [3] for signed policies. There's no
> reason why you can't use [4] though. Since the creation data, hash and
> ticket are likely used as a job lot, it strikes me they should be a
> single numbered optional sequence instead of individually numbered,
> since you're unlikely to have one without the others.
Thanks, I was hoping James might pipe up and tell me what to do.
Grouping them as a single numbered optional sequence sounds reasonable
to me. Is your draft too far along to squeeze this in? If it is and
I'm on my own to draft up and submit this, I would definitely
appreciate any pointers on getting started you might have.
I notice the draft and the code seem to be out of alignment. I'm
unfamiliar with this process, is the idea to get through all the
iterations and land the standard, then fix up the code? What happens
to existing data handed out in the old format?
-Evan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data
2022-11-14 16:32 ` Evan Green
@ 2022-11-14 16:56 ` James Bottomley
2022-11-14 17:43 ` Evan Green
0 siblings, 1 reply; 15+ messages in thread
From: James Bottomley @ 2022-11-14 16:56 UTC (permalink / raw)
To: Evan Green
Cc: Eric Biggers, linux-kernel, corbet, linux-integrity, gwendal,
dianders, apronin, Pavel Machek, Ben Boeckel, rjw, Kees Cook,
dlunev, zohar, Matthew Garrett, jarkko, linux-pm, David Howells,
James Morris, Paul Moore, Serge E. Hallyn, keyrings,
linux-security-module
On Mon, 2022-11-14 at 08:32 -0800, Evan Green wrote:
> On Sun, Nov 13, 2022 at 7:32 PM James Bottomley <jejb@linux.ibm.com>
> wrote:
> >
> > On Sun, 2022-11-13 at 13:20 -0800, Eric Biggers wrote:
> > > On Fri, Nov 11, 2022 at 03:16:29PM -0800, Evan Green wrote:
> > > > diff --git a/security/keys/trusted-keys/tpm2key.asn1
> > > > b/security/keys/trusted-keys/tpm2key.asn1
> > > > index f57f869ad60068..608f8d9ca95fa8 100644
> > > > --- a/security/keys/trusted-keys/tpm2key.asn1
> > > > +++ b/security/keys/trusted-keys/tpm2key.asn1
> > > > @@ -7,5 +7,18 @@ TPMKey ::= SEQUENCE {
> > > > emptyAuth [0] EXPLICIT BOOLEAN OPTIONAL,
> > > > parent INTEGER ({tpm2_key_parent}),
> > > > pubkey OCTET STRING ({tpm2_key_pub}),
> > > > - privkey OCTET STRING ({tpm2_key_priv})
> > > > + privkey OCTET STRING ({tpm2_key_priv}),
> > > > + ---
> > > > + --- A TPM2B_CREATION_DATA struct as returned from the
> > > > TPM2_Create command.
> > > > + ---
> > > > + creationData [1] EXPLICIT OCTET STRING OPTIONAL
> > > > ({tpm2_key_creation_data}),
> > > > + ---
> > > > + --- A TPM2B_DIGEST of the creationHash as returned from
> > > > the
> > > > TPM2_Create
> > > > + --- command.
> > > > + ---
> > > > + creationHash [2] EXPLICIT OCTET STRING OPTIONAL
> > > > ({tpm2_key_creation_hash}),
> > > > + ---
> > > > + --- A TPMT_TK_CREATION ticket as returned from the
> > > > TPM2_Create command.
> > > > + ---
> > > > + creationTk [3] EXPLICIT OCTET STRING OPTIONAL
> > > > ({tpm2_key_creation_tk})
> > > > }
> > >
> > > The commit that added this file claimed:
> > >
> > > "The benefit of the ASN.1 format is that it's a standard
> > > and thus the
> > > exported key can be used by userspace tools
> > > (openssl_tpm2_engine,
> > > openconnect and tpm2-tss-engine"
> > >
> > > Are these new fields in compliance with whatever standard that
> > > was referring to?
> >
> > Not really, no. The current use case (and draft standard) is
> > already using [1] for policies and [2] for importable keys:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/jejb/openssl_tpm2_engine.git/tree/doc/draft-bottomley-tpm2-keys.xml
> >
> > I'm actually planning to use [3] for signed policies. There's no
> > reason why you can't use [4] though. Since the creation data, hash
> > and ticket are likely used as a job lot, it strikes me they should
> > be a single numbered optional sequence instead of individually
> > numbered, since you're unlikely to have one without the others.
>
> Thanks, I was hoping James might pipe up and tell me what to do.
> Grouping them as a single numbered optional sequence sounds
> reasonable to me. Is your draft too far along to squeeze this in?
Not at all. The draft only becomes frozen once I submit it to the IETF
which, so far thanks to lack of any reviewers I haven't done (That's
why I was also thinking of adding signed policies).
> If it is and I'm on my own to draft up and submit this, I would
> definitely appreciate any pointers on getting started you might have.
>
> I notice the draft and the code seem to be out of alignment.
The kernel code is out of alignment just because development moves a
bit slowly. Policy based keys were submitted a long time ago as part
of the original move to interoperable sealed keys based on ASN.1:
https://lore.kernel.org/all/20200616160229.8018-7-James.Bottomley@HansenPartnership.com/
But eventually the policy part was split out and forgotten about. I
think the only complete implementation of the draft standard is the
openssl_tpm2_engine.
> I'm unfamiliar with this process, is the idea to get through all the
> iterations and land the standard, then fix up the code? What happens
> to existing data handed out in the old format?
No, it doesn't matter at all. That's the whole point of using ASN.1
explicit optionals: the ASN.1 is always backwards compatible. If I
ever submit the draft, there'll have to be a new RFC to add new
explicit optionals, but keys conforming to the old RFC will still be
valid under the new one.
Of course, since openssl_tpm2_engine is the complete reference
implementation that means I'll have to add the creation PCRs
implementation to it ... unless you'd like to do it?
Regards,
James
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data
2022-11-14 16:56 ` James Bottomley
@ 2022-11-14 17:43 ` Evan Green
2022-11-14 18:00 ` James Bottomley
0 siblings, 1 reply; 15+ messages in thread
From: Evan Green @ 2022-11-14 17:43 UTC (permalink / raw)
To: jejb
Cc: Eric Biggers, linux-kernel, corbet, linux-integrity, gwendal,
dianders, apronin, Pavel Machek, Ben Boeckel, rjw, Kees Cook,
dlunev, zohar, Matthew Garrett, jarkko, linux-pm, David Howells,
James Morris, Paul Moore, Serge E. Hallyn, keyrings,
linux-security-module
On Mon, Nov 14, 2022 at 8:56 AM James Bottomley <jejb@linux.ibm.com> wrote:
>
> On Mon, 2022-11-14 at 08:32 -0800, Evan Green wrote:
> > On Sun, Nov 13, 2022 at 7:32 PM James Bottomley <jejb@linux.ibm.com>
> > wrote:
> > >
> > > On Sun, 2022-11-13 at 13:20 -0800, Eric Biggers wrote:
> > > > On Fri, Nov 11, 2022 at 03:16:29PM -0800, Evan Green wrote:
> > > > > diff --git a/security/keys/trusted-keys/tpm2key.asn1
> > > > > b/security/keys/trusted-keys/tpm2key.asn1
> > > > > index f57f869ad60068..608f8d9ca95fa8 100644
> > > > > --- a/security/keys/trusted-keys/tpm2key.asn1
> > > > > +++ b/security/keys/trusted-keys/tpm2key.asn1
> > > > > @@ -7,5 +7,18 @@ TPMKey ::= SEQUENCE {
> > > > > emptyAuth [0] EXPLICIT BOOLEAN OPTIONAL,
> > > > > parent INTEGER ({tpm2_key_parent}),
> > > > > pubkey OCTET STRING ({tpm2_key_pub}),
> > > > > - privkey OCTET STRING ({tpm2_key_priv})
> > > > > + privkey OCTET STRING ({tpm2_key_priv}),
> > > > > + ---
> > > > > + --- A TPM2B_CREATION_DATA struct as returned from the
> > > > > TPM2_Create command.
> > > > > + ---
> > > > > + creationData [1] EXPLICIT OCTET STRING OPTIONAL
> > > > > ({tpm2_key_creation_data}),
> > > > > + ---
> > > > > + --- A TPM2B_DIGEST of the creationHash as returned from
> > > > > the
> > > > > TPM2_Create
> > > > > + --- command.
> > > > > + ---
> > > > > + creationHash [2] EXPLICIT OCTET STRING OPTIONAL
> > > > > ({tpm2_key_creation_hash}),
> > > > > + ---
> > > > > + --- A TPMT_TK_CREATION ticket as returned from the
> > > > > TPM2_Create command.
> > > > > + ---
> > > > > + creationTk [3] EXPLICIT OCTET STRING OPTIONAL
> > > > > ({tpm2_key_creation_tk})
> > > > > }
> > > >
> > > > The commit that added this file claimed:
> > > >
> > > > "The benefit of the ASN.1 format is that it's a standard
> > > > and thus the
> > > > exported key can be used by userspace tools
> > > > (openssl_tpm2_engine,
> > > > openconnect and tpm2-tss-engine"
> > > >
> > > > Are these new fields in compliance with whatever standard that
> > > > was referring to?
> > >
> > > Not really, no. The current use case (and draft standard) is
> > > already using [1] for policies and [2] for importable keys:
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/jejb/openssl_tpm2_engine.git/tree/doc/draft-bottomley-tpm2-keys.xml
> > >
> > > I'm actually planning to use [3] for signed policies. There's no
> > > reason why you can't use [4] though. Since the creation data, hash
> > > and ticket are likely used as a job lot, it strikes me they should
> > > be a single numbered optional sequence instead of individually
> > > numbered, since you're unlikely to have one without the others.
> >
> > Thanks, I was hoping James might pipe up and tell me what to do.
> > Grouping them as a single numbered optional sequence sounds
> > reasonable to me. Is your draft too far along to squeeze this in?
>
> Not at all. The draft only becomes frozen once I submit it to the IETF
> which, so far thanks to lack of any reviewers I haven't done (That's
> why I was also thinking of adding signed policies).
>
> > If it is and I'm on my own to draft up and submit this, I would
> > definitely appreciate any pointers on getting started you might have.
> >
> > I notice the draft and the code seem to be out of alignment.
>
> The kernel code is out of alignment just because development moves a
> bit slowly. Policy based keys were submitted a long time ago as part
> of the original move to interoperable sealed keys based on ASN.1:
>
> https://lore.kernel.org/all/20200616160229.8018-7-James.Bottomley@HansenPartnership.com/
>
> But eventually the policy part was split out and forgotten about. I
> think the only complete implementation of the draft standard is the
> openssl_tpm2_engine.
>
> > I'm unfamiliar with this process, is the idea to get through all the
> > iterations and land the standard, then fix up the code? What happens
> > to existing data handed out in the old format?
>
> No, it doesn't matter at all. That's the whole point of using ASN.1
> explicit optionals: the ASN.1 is always backwards compatible. If I
> ever submit the draft, there'll have to be a new RFC to add new
> explicit optionals, but keys conforming to the old RFC will still be
> valid under the new one.
Ah I see, with the optionals in mind things do line up again.
>
> Of course, since openssl_tpm2_engine is the complete reference
> implementation that means I'll have to add the creation PCRs
> implementation to it ... unless you'd like to do it?
I am willing to help as I'm the one making the mess. How does it
sequence along with your draft submission (before, after,
simultaneous)?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data
2022-11-14 17:43 ` Evan Green
@ 2022-11-14 18:00 ` James Bottomley
2022-12-02 21:03 ` James Bottomley
0 siblings, 1 reply; 15+ messages in thread
From: James Bottomley @ 2022-11-14 18:00 UTC (permalink / raw)
To: Evan Green
Cc: Eric Biggers, linux-kernel, corbet, linux-integrity, gwendal,
dianders, apronin, Pavel Machek, Ben Boeckel, rjw, Kees Cook,
dlunev, zohar, Matthew Garrett, jarkko, linux-pm, David Howells,
James Morris, Paul Moore, Serge E. Hallyn, keyrings,
linux-security-module
On Mon, 2022-11-14 at 09:43 -0800, Evan Green wrote:
> On Mon, Nov 14, 2022 at 8:56 AM James Bottomley <jejb@linux.ibm.com>
> wrote:
[...]
> > Of course, since openssl_tpm2_engine is the complete reference
> > implementation that means I'll have to add the creation PCRs
> > implementation to it ... unless you'd like to do it?
>
> I am willing to help as I'm the one making the mess. How does it
> sequence along with your draft submission (before, after,
> simultaneous)?
At the moment, just send patches. The openssl_tpm2_engine is developed
on a groups.io mailing list:
https://groups.io/g/openssl-tpm2-engine/
You need an IETF specific tool (xml2rfc) to build the rfc from the xml,
but it's available in most distros as python3-xml2rfc. If you don't
want to learn the IETF XML I can help you code up the patch to add that
to the draft spec.
Regards,
James
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data
2022-11-14 18:00 ` James Bottomley
@ 2022-12-02 21:03 ` James Bottomley
2022-12-05 18:43 ` Evan Green
0 siblings, 1 reply; 15+ messages in thread
From: James Bottomley @ 2022-12-02 21:03 UTC (permalink / raw)
To: Evan Green
Cc: Eric Biggers, linux-kernel, corbet, linux-integrity, gwendal,
dianders, apronin, Pavel Machek, Ben Boeckel, rjw, Kees Cook,
dlunev, zohar, Matthew Garrett, jarkko, linux-pm, David Howells,
James Morris, Paul Moore, Serge E. Hallyn, keyrings,
linux-security-module
On Mon, 2022-11-14 at 13:00 -0500, James Bottomley wrote:
> On Mon, 2022-11-14 at 09:43 -0800, Evan Green wrote:
> > On Mon, Nov 14, 2022 at 8:56 AM James Bottomley
> > <jejb@linux.ibm.com>
> > wrote:
> [...]
> > > Of course, since openssl_tpm2_engine is the complete reference
> > > implementation that means I'll have to add the creation PCRs
> > > implementation to it ... unless you'd like to do it?
> >
> > I am willing to help as I'm the one making the mess. How does it
> > sequence along with your draft submission (before, after,
> > simultaneous)?
>
> At the moment, just send patches. The openssl_tpm2_engine is
> developed on a groups.io mailing list:
>
> https://groups.io/g/openssl-tpm2-engine/
>
> You need an IETF specific tool (xml2rfc) to build the rfc from the
> xml, but it's available in most distros as python3-xml2rfc. If you
> don't want to learn the IETF XML I can help you code up the patch to
> add that to the draft spec.
Just as a heads up, the patch series implementing signed policy (and
thus taking option [3]) is on the mailing list for review:
https://groups.io/g/openssl-tpm2-engine/message/296
With apologies for the awful lack of threading in the groups.io
interface.
So you don't have to build the RFC yourself, I published the proposed
update on my website:
https://www.hansenpartnership.com/draft-bottomley-tpm2-keys.html
https://www.hansenpartnership.com/draft-bottomley-tpm2-keys.txt
If you want to use option [4] for the creation data, it's available.
Regards,
James
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data
2022-12-02 21:03 ` James Bottomley
@ 2022-12-05 18:43 ` Evan Green
0 siblings, 0 replies; 15+ messages in thread
From: Evan Green @ 2022-12-05 18:43 UTC (permalink / raw)
To: jejb
Cc: Eric Biggers, linux-kernel, corbet, linux-integrity, gwendal,
dianders, apronin, Pavel Machek, Ben Boeckel, rjw, Kees Cook,
dlunev, zohar, Matthew Garrett, jarkko, linux-pm, David Howells,
James Morris, Paul Moore, Serge E. Hallyn, keyrings,
linux-security-module
On Fri, Dec 2, 2022 at 1:03 PM James Bottomley <jejb@linux.ibm.com> wrote:
>
> On Mon, 2022-11-14 at 13:00 -0500, James Bottomley wrote:
> > On Mon, 2022-11-14 at 09:43 -0800, Evan Green wrote:
> > > On Mon, Nov 14, 2022 at 8:56 AM James Bottomley
> > > <jejb@linux.ibm.com>
> > > wrote:
> > [...]
> > > > Of course, since openssl_tpm2_engine is the complete reference
> > > > implementation that means I'll have to add the creation PCRs
> > > > implementation to it ... unless you'd like to do it?
> > >
> > > I am willing to help as I'm the one making the mess. How does it
> > > sequence along with your draft submission (before, after,
> > > simultaneous)?
> >
> > At the moment, just send patches. The openssl_tpm2_engine is
> > developed on a groups.io mailing list:
> >
> > https://groups.io/g/openssl-tpm2-engine/
> >
> > You need an IETF specific tool (xml2rfc) to build the rfc from the
> > xml, but it's available in most distros as python3-xml2rfc. If you
> > don't want to learn the IETF XML I can help you code up the patch to
> > add that to the draft spec.
>
> Just as a heads up, the patch series implementing signed policy (and
> thus taking option [3]) is on the mailing list for review:
>
> https://groups.io/g/openssl-tpm2-engine/message/296
>
> With apologies for the awful lack of threading in the groups.io
> interface.
>
> So you don't have to build the RFC yourself, I published the proposed
> update on my website:
>
> https://www.hansenpartnership.com/draft-bottomley-tpm2-keys.html
> https://www.hansenpartnership.com/draft-bottomley-tpm2-keys.txt
>
> If you want to use option [4] for the creation data, it's available.
Perfect, thanks James!
-Evan
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v5 05/11] security: keys: trusted: Allow storage of PCR values in creation data
2022-11-11 23:16 [PATCH v5 00/11] Encrypted Hibernation Evan Green
2022-11-11 23:16 ` [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data Evan Green
@ 2022-11-11 23:16 ` Evan Green
2022-11-13 22:01 ` Eric Biggers
2022-11-11 23:16 ` [PATCH v5 06/11] security: keys: trusted: Verify " Evan Green
2022-12-07 23:54 ` [PATCH v5 00/11] Encrypted Hibernation Evan Green
3 siblings, 1 reply; 15+ messages in thread
From: Evan Green @ 2022-11-11 23:16 UTC (permalink / raw)
To: linux-kernel
Cc: corbet, linux-integrity, Eric Biggers, gwendal, dianders, apronin,
Pavel Machek, Ben Boeckel, rjw, jejb, Kees Cook, dlunev, zohar,
Matthew Garrett, jarkko, linux-pm, Matthew Garrett, Evan Green,
Ben Boeckel, David Howells, James Morris, Paul Moore,
Serge E. Hallyn, keyrings, linux-doc, linux-security-module
From: Matthew Garrett <matthewgarrett@google.com>
When TPMs generate keys, they can also generate some information
describing the state of the PCRs at creation time. This data can then
later be certified by the TPM, allowing verification of the PCR values.
This allows us to determine the state of the system at the time a key
was generated. Add an additional argument to the trusted key creation
options, allowing the user to provide the set of PCRs that should have
their values incorporated into the creation data.
Link: https://lore.kernel.org/lkml/20210220013255.1083202-6-matthewgarrett@google.com/
Signed-off-by: Matthew Garrett <matthewgarrett@google.com>
Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Ben Boeckel <linux@me.benboeckel.net>
Reviewed-by: Kees Cook <keescook@chromium.org>
---
Changes in v5:
- Make Matthew's tag match author
Changes in v3:
- Clarified creationpcrs documentation (Ben)
.../security/keys/trusted-encrypted.rst | 6 +++++
include/keys/trusted-type.h | 1 +
security/keys/trusted-keys/trusted_tpm1.c | 9 +++++++
security/keys/trusted-keys/trusted_tpm2.c | 25 +++++++++++++++++--
4 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/Documentation/security/keys/trusted-encrypted.rst b/Documentation/security/keys/trusted-encrypted.rst
index 9bc9db8ec6517c..a1872964fe862f 100644
--- a/Documentation/security/keys/trusted-encrypted.rst
+++ b/Documentation/security/keys/trusted-encrypted.rst
@@ -199,6 +199,12 @@ Usage::
policyhandle= handle to an authorization policy session that defines the
same policy and with the same hash algorithm as was used to
seal the key.
+ creationpcrs= hex integer representing the set of PCRs to be
+ included in the creation data. For each bit set, the
+ corresponding PCR will be included in the key creation
+ data. Bit 0 corresponds to PCR0. Currently only the first
+ PC standard 24 PCRs are supported on the currently active
+ bank. Leading zeroes are optional. TPM2 only.
"keyctl print" returns an ascii hex copy of the sealed key, which is in standard
TPM_STORED_DATA format. The key length for new keys are always in bytes.
diff --git a/include/keys/trusted-type.h b/include/keys/trusted-type.h
index 209086fed240a5..8523d41507b2a4 100644
--- a/include/keys/trusted-type.h
+++ b/include/keys/trusted-type.h
@@ -54,6 +54,7 @@ struct trusted_key_options {
uint32_t policydigest_len;
unsigned char policydigest[MAX_DIGEST_SIZE];
uint32_t policyhandle;
+ uint32_t creation_pcrs;
};
struct trusted_key_ops {
diff --git a/security/keys/trusted-keys/trusted_tpm1.c b/security/keys/trusted-keys/trusted_tpm1.c
index aa108bea6739b3..2975827c01bec0 100644
--- a/security/keys/trusted-keys/trusted_tpm1.c
+++ b/security/keys/trusted-keys/trusted_tpm1.c
@@ -713,6 +713,7 @@ enum {
Opt_hash,
Opt_policydigest,
Opt_policyhandle,
+ Opt_creationpcrs,
};
static const match_table_t key_tokens = {
@@ -725,6 +726,7 @@ static const match_table_t key_tokens = {
{Opt_hash, "hash=%s"},
{Opt_policydigest, "policydigest=%s"},
{Opt_policyhandle, "policyhandle=%s"},
+ {Opt_creationpcrs, "creationpcrs=%s"},
{Opt_err, NULL}
};
@@ -858,6 +860,13 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
return -EINVAL;
opt->policyhandle = handle;
break;
+ case Opt_creationpcrs:
+ if (!tpm2)
+ return -EINVAL;
+ res = kstrtoint(args[0].from, 16, &opt->creation_pcrs);
+ if (res < 0)
+ return -EINVAL;
+ break;
default:
return -EINVAL;
}
diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
index ff2aede8986236..3d84c3d41bdee1 100644
--- a/security/keys/trusted-keys/trusted_tpm2.c
+++ b/security/keys/trusted-keys/trusted_tpm2.c
@@ -428,7 +428,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
struct tpm_buf buf;
u32 hash;
u32 flags;
- int i;
+ int i, j;
int rc;
for (i = 0; i < ARRAY_SIZE(tpm2_hash_map); i++) {
@@ -497,7 +497,28 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
tpm_buf_append_u16(&buf, 0);
/* creation PCR */
- tpm_buf_append_u32(&buf, 0);
+ if (options->creation_pcrs) {
+ /* One bank */
+ tpm_buf_append_u32(&buf, 1);
+ /* Which bank to use */
+ tpm_buf_append_u16(&buf, hash);
+ /* Length of the PCR bitmask */
+ tpm_buf_append_u8(&buf, 3);
+ /* PCR bitmask */
+ for (i = 0; i < 3; i++) {
+ char tmp = 0;
+
+ for (j = 0; j < 8; j++) {
+ char bit = (i * 8) + j;
+
+ if (options->creation_pcrs & (1 << bit))
+ tmp |= (1 << j);
+ }
+ tpm_buf_append_u8(&buf, tmp);
+ }
+ } else {
+ tpm_buf_append_u32(&buf, 0);
+ }
if (buf.flags & TPM_BUF_OVERFLOW) {
rc = -E2BIG;
--
2.38.1.431.g37b22c650d-goog
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v5 05/11] security: keys: trusted: Allow storage of PCR values in creation data
2022-11-11 23:16 ` [PATCH v5 05/11] security: keys: trusted: Allow storage of PCR values in " Evan Green
@ 2022-11-13 22:01 ` Eric Biggers
0 siblings, 0 replies; 15+ messages in thread
From: Eric Biggers @ 2022-11-13 22:01 UTC (permalink / raw)
To: Evan Green
Cc: linux-kernel, corbet, linux-integrity, gwendal, dianders, apronin,
Pavel Machek, Ben Boeckel, rjw, jejb, Kees Cook, dlunev, zohar,
Matthew Garrett, jarkko, linux-pm, Matthew Garrett, Ben Boeckel,
David Howells, James Morris, Paul Moore, Serge E. Hallyn,
keyrings, linux-doc, linux-security-module
On Fri, Nov 11, 2022 at 03:16:30PM -0800, Evan Green wrote:
> + creationpcrs= hex integer representing the set of PCRs to be
> + included in the creation data. For each bit set, the
> + corresponding PCR will be included in the key creation
> + data. Bit 0 corresponds to PCR0. Currently only the first
> + PC standard 24 PCRs are supported on the currently active
> + bank. Leading zeroes are optional. TPM2 only.
What does "currently active bank" mean?
> + /* PCR bitmask */
> + for (i = 0; i < 3; i++) {
> + char tmp = 0;
> +
> + for (j = 0; j < 8; j++) {
> + char bit = (i * 8) + j;
> +
> + if (options->creation_pcrs & (1 << bit))
> + tmp |= (1 << j);
> + }
> + tpm_buf_append_u8(&buf, tmp);
> + }
Why not just:
tpm_buf_append_u8(&buf, options->creation_pcrs);
tpm_buf_append_u8(&buf, options->creation_pcrs >> 8);
tpm_buf_append_u8(&buf, options->creation_pcrs >> 16);
Also what if bit 24 or above is set? Should an error be returned?
- Eric
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v5 06/11] security: keys: trusted: Verify creation data
2022-11-11 23:16 [PATCH v5 00/11] Encrypted Hibernation Evan Green
2022-11-11 23:16 ` [PATCH v5 04/11] security: keys: trusted: Include TPM2 creation data Evan Green
2022-11-11 23:16 ` [PATCH v5 05/11] security: keys: trusted: Allow storage of PCR values in " Evan Green
@ 2022-11-11 23:16 ` Evan Green
2022-11-13 22:13 ` Eric Biggers
2022-12-07 23:54 ` [PATCH v5 00/11] Encrypted Hibernation Evan Green
3 siblings, 1 reply; 15+ messages in thread
From: Evan Green @ 2022-11-11 23:16 UTC (permalink / raw)
To: linux-kernel
Cc: corbet, linux-integrity, Eric Biggers, gwendal, dianders, apronin,
Pavel Machek, Ben Boeckel, rjw, jejb, Kees Cook, dlunev, zohar,
Matthew Garrett, jarkko, linux-pm, Evan Green, Matthew Garrett,
David Howells, James Morris, Paul Moore, Serge E. Hallyn, axelj,
keyrings, linux-security-module
If a loaded key contains creation data, ask the TPM to verify that
creation data. This allows users like encrypted hibernate to know that
the loaded and parsed creation data has not been tampered with.
Suggested-by: Matthew Garrett <mjg59@google.com>
Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
---
Source material for this change is at:
https://patchwork.kernel.org/project/linux-pm/patch/20210220013255.1083202-9-matthewgarrett@google.com/
(no changes since v3)
Changes in v3:
- Changed funky tag to suggested-by (Kees). Matthew, holler if you want
something different.
Changes in v2:
- Adjust hash len by 2 due to new ASN.1 storage, and add underflow
check.
include/linux/tpm.h | 1 +
security/keys/trusted-keys/trusted_tpm2.c | 77 ++++++++++++++++++++++-
2 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index 70134e6551745f..9c2ee3e30ffa5d 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -224,6 +224,7 @@ enum tpm2_command_codes {
TPM2_CC_SELF_TEST = 0x0143,
TPM2_CC_STARTUP = 0x0144,
TPM2_CC_SHUTDOWN = 0x0145,
+ TPM2_CC_CERTIFYCREATION = 0x014A,
TPM2_CC_NV_READ = 0x014E,
TPM2_CC_CREATE = 0x0153,
TPM2_CC_LOAD = 0x0157,
diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
index 3d84c3d41bdee1..402933f8c99ede 100644
--- a/security/keys/trusted-keys/trusted_tpm2.c
+++ b/security/keys/trusted-keys/trusted_tpm2.c
@@ -730,6 +730,74 @@ static int tpm2_unseal_cmd(struct tpm_chip *chip,
return rc;
}
+/**
+ * tpm2_certify_creation() - execute a TPM2_CertifyCreation command
+ *
+ * @chip: TPM chip to use
+ * @payload: the key data in clear and encrypted form
+ * @blob_handle: the loaded TPM handle of the key
+ *
+ * Return: 0 on success
+ * -EINVAL on tpm error status
+ * < 0 error from tpm_send or tpm_buf_init
+ */
+static int tpm2_certify_creation(struct tpm_chip *chip,
+ struct trusted_key_payload *payload,
+ u32 blob_handle)
+{
+ struct tpm_header *head;
+ struct tpm_buf buf;
+ int rc;
+
+ rc = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_CERTIFYCREATION);
+ if (rc)
+ return rc;
+
+ /* Use TPM_RH_NULL for signHandle */
+ tpm_buf_append_u32(&buf, 0x40000007);
+
+ /* Object handle */
+ tpm_buf_append_u32(&buf, blob_handle);
+
+ /* Auth */
+ tpm_buf_append_u32(&buf, 9);
+ tpm_buf_append_u32(&buf, TPM2_RS_PW);
+ tpm_buf_append_u16(&buf, 0);
+ tpm_buf_append_u8(&buf, 0);
+ tpm_buf_append_u16(&buf, 0);
+
+ /* Qualifying data */
+ tpm_buf_append_u16(&buf, 0);
+
+ /* Creation data hash */
+ if (payload->creation_hash_len < 2) {
+ rc = -EINVAL;
+ goto out;
+ }
+
+ tpm_buf_append_u16(&buf, payload->creation_hash_len - 2);
+ tpm_buf_append(&buf, payload->creation_hash + 2,
+ payload->creation_hash_len - 2);
+
+ /* signature scheme */
+ tpm_buf_append_u16(&buf, TPM_ALG_NULL);
+
+ /* creation ticket */
+ tpm_buf_append(&buf, payload->tk, payload->tk_len);
+
+ rc = tpm_transmit_cmd(chip, &buf, 6, "certifying creation data");
+ if (rc)
+ goto out;
+
+ head = (struct tpm_header *)buf.data;
+
+ if (be32_to_cpu(head->return_code) != TPM2_RC_SUCCESS)
+ rc = -EINVAL;
+out:
+ tpm_buf_destroy(&buf);
+ return rc;
+}
+
/**
* tpm2_unseal_trusted() - unseal the payload of a trusted key
*
@@ -755,8 +823,15 @@ int tpm2_unseal_trusted(struct tpm_chip *chip,
goto out;
rc = tpm2_unseal_cmd(chip, payload, options, blob_handle);
- tpm2_flush_context(chip, blob_handle);
+ if (rc)
+ goto flush;
+
+ if (payload->creation_len)
+ rc = tpm2_certify_creation(chip, payload, blob_handle);
+
+flush:
+ tpm2_flush_context(chip, blob_handle);
out:
tpm_put_ops(chip);
--
2.38.1.431.g37b22c650d-goog
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v5 06/11] security: keys: trusted: Verify creation data
2022-11-11 23:16 ` [PATCH v5 06/11] security: keys: trusted: Verify " Evan Green
@ 2022-11-13 22:13 ` Eric Biggers
0 siblings, 0 replies; 15+ messages in thread
From: Eric Biggers @ 2022-11-13 22:13 UTC (permalink / raw)
To: Evan Green
Cc: linux-kernel, corbet, linux-integrity, gwendal, dianders, apronin,
Pavel Machek, Ben Boeckel, rjw, jejb, Kees Cook, dlunev, zohar,
Matthew Garrett, jarkko, linux-pm, Matthew Garrett, David Howells,
James Morris, Paul Moore, Serge E. Hallyn, axelj, keyrings,
linux-security-module
On Fri, Nov 11, 2022 at 03:16:31PM -0800, Evan Green wrote:
> security: keys: trusted: Verify creation data
>
> If a loaded key contains creation data, ask the TPM to verify that
> creation data. This allows users like encrypted hibernate to know that
> the loaded and parsed creation data has not been tampered with.
I don't understand what the purpose of this is.
I thought that the way to "seal" a key to a TPM PCR is to include the PCR in the
"policy".
Are you doing that too? What is the purpose of using the "creation data"?
> + /* Auth */
> + tpm_buf_append_u32(&buf, 9);
> + tpm_buf_append_u32(&buf, TPM2_RS_PW);
> + tpm_buf_append_u16(&buf, 0);
> + tpm_buf_append_u8(&buf, 0);
> + tpm_buf_append_u16(&buf, 0);
This is struct tpm2_null_auth_area, so this is another place that could take
advantage of a new helper function to append it.
> + /* Creation data hash */
> + if (payload->creation_hash_len < 2) {
> + rc = -EINVAL;
> + goto out;
> + }
> +
> + tpm_buf_append_u16(&buf, payload->creation_hash_len - 2);
> + tpm_buf_append(&buf, payload->creation_hash + 2,
> + payload->creation_hash_len - 2);
So the first two bytes of creation_hash are a redundant length field that needs
to be ignored here? Perhaps tpm2_key_encode() shouldn't include that redundant
length field?
> +
> + /* signature scheme */
> + tpm_buf_append_u16(&buf, TPM_ALG_NULL);
> +
> + /* creation ticket */
> + tpm_buf_append(&buf, payload->tk, payload->tk_len);
> +
> + rc = tpm_transmit_cmd(chip, &buf, 6, "certifying creation data");
> + if (rc)
> + goto out;
This is another instance of the bug where a positive TPM2_RC_* code is being
returned from a function that is supposed to return a negative errno value.
- Eric
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v5 00/11] Encrypted Hibernation
2022-11-11 23:16 [PATCH v5 00/11] Encrypted Hibernation Evan Green
` (2 preceding siblings ...)
2022-11-11 23:16 ` [PATCH v5 06/11] security: keys: trusted: Verify " Evan Green
@ 2022-12-07 23:54 ` Evan Green
3 siblings, 0 replies; 15+ messages in thread
From: Evan Green @ 2022-12-07 23:54 UTC (permalink / raw)
To: linux-kernel
Cc: corbet, linux-integrity, Eric Biggers, gwendal, dianders, apronin,
Pavel Machek, Ben Boeckel, rjw, jejb, Kees Cook, dlunev, zohar,
Matthew Garrett, jarkko, linux-pm, David Howells, James Morris,
Jason Gunthorpe, Len Brown, Matthew Garrett, Paul Moore,
Peter Huewe, Rafael J. Wysocki, Serge E. Hallyn, axelj, keyrings,
linux-doc, linux-security-module, greg, casey
Hello, it's me again!
On Fri, Nov 11, 2022 at 3:19 PM Evan Green <evgreen@chromium.org> wrote:
>
> We are exploring enabling hibernation in some new scenarios. However,
> our security team has a few requirements, listed below:
> 1. The hibernate image must be encrypted with protection derived from
> both the platform (eg TPM) and user authentication data (eg
> password).
> 2. Hibernation must not be a vector by which a malicious userspace can
> escalate to the kernel.
>
> Requirement #1 can be achieved solely with uswsusp, however requirement
> 2 necessitates mechanisms in the kernel to guarantee integrity of the
> hibernate image. The kernel needs a way to authenticate that it generated
> the hibernate image being loaded, and that the image has not been tampered
> with. Adding support for in-kernel AEAD encryption with a TPM-sealed key
> allows us to achieve both requirements with a single computation pass.
>
> Matthew Garrett published a series [1] that aligns closely with this
> goal. His series utilized the fact that PCR23 is a resettable PCR that
> can be blocked from access by usermode. The TPM can create a sealed key
> tied to PCR23 in two ways. First, the TPM can attest to the value of
> PCR23 when the key was created, which the kernel can use on resume to
> verify that the kernel must have created the key (since it is the only
> one capable of modifying PCR23). It can also create a policy that enforces
> PCR23 be set to a specific value as a condition of unsealing the key,
> preventing usermode from unsealing the key by talking directly to the
> TPM.
>
> This series adopts that primitive as a foundation, tweaking and building
> on it a bit. Where Matthew's series used the TPM-backed key to encrypt a
> hash of the image, this series uses the key directly as a gcm(aes)
> encryption key, which the kernel uses to encrypt and decrypt the
> hibernate image in chunks of 16 pages. This provides both encryption and
> integrity, which turns out to be a noticeable performance improvement over
> separate passes for encryption and hashing.
>
> The series also introduces the concept of mixing user key material into
> the encryption key. This allows usermode to introduce key material
> based on unspecified external authentication data (in our case derived
> from something like the user password or PIN), without requiring
> usermode to do a separate encryption pass.
>
> Matthew also documented issues his series had [2] related to generating
> fake images by booting alternate kernels without the PCR23 limiting.
> With access to PCR23 on the same machine, usermode can create fake
> hibernate images that are indistinguishable to the new kernel from
> genuine ones. His post outlines a solution that involves adding more
> PCRs into the creation data and policy, with some gyrations to make this
> work well on a standard PC.
>
> Our approach would be similar: on our machines PCR 0 indicates whether
> the system is booted in secure/verified mode or developer mode. By
> adding PCR0 to the policy, we can reject hibernate images made in
> developer mode while in verified mode (or vice versa).
>
> Additionally, mixing in the user authentication data limits both
> data exfiltration attacks (eg a stolen laptop) and forged hibernation
> image attacks to attackers that already know the authentication data (eg
> user's password). This, combined with our relatively sealed userspace
> (dm-verity on the rootfs), and some judicious clearing of the hibernate
> image (such as across an OS update) further reduce the risk of an online
> attack. The remaining attack space of a forgery from someone with
> physical access to the device and knowledge of the authentication data
> is out of scope for us, given that flipping to developer mode or
> reflashing RO firmware trivially achieves the same thing.
>
> A couple of patches still need to be written on top of this series. The
> generalized functionality to OR in additional PCRs via Kconfig (like PCR
> 0 or 5) still needs to be added. We'll also need a patch that disallows
> unencrypted forms of resume from hibernation, to fully close the door
> to malicious userspace. However, I wanted to get this series out first
> and get reactions from upstream before continuing to add to it.
>
> [1] https://patchwork.kernel.org/project/linux-pm/cover/20210220013255.1083202-1-matthewgarrett@google.com/
> [2] https://mjg59.dreamwidth.org/58077.html
>
Doug found a practical problem with this design. The security of this
mechanism depends on the kernel being able to prevent usermode from
manipulating PCR23. While this series has managed to add that gating
to the standard /dev/tpm interface, at least on ChromeOS, there are
still many "dangerous toys" lying around that might allow a malicious
root to communicate directly with the TPM. This raw access could allow
usermode to extend PCR23 manually and forge malicious hibernate images
that appear genuine. Examples of raw access include 1) i2cget -F, 2)
unbinding the driver and binding i2c-dev instead, 3) using /dev/mem to
manipulate the i2c controller registers directly, and 4) my favorite,
remuxing the i2c pins to GPIO and bitbanging.
We did some brainstorming and came up with a pivot that has the
benefits of 1) reusing a decent chunk of this series, 2) not taking
PCR23 away from usermode (which based on other comments seemed like it
might not fly anyway), and 3) pushing the TPM interaction back down
into usermode. The new element we take advantage of is that our early
userspace is still considered trusted, as we sign the rootfs and
protect it with dm-verity.
The idea is to have early userspace ask the TPM to create a sealed key
bound to a (non-resettable) PCR. We then save the blob to disk, extend
the PCR (to prevent future unsealings in this boot), and push the key
material up to the kernel for use as a "hibernate seed". The kernel
will hold this seed in memory, and at hibernate time will use it to
encrypt a randomly generated "bulk key". The bulk key is then used to
encrypt the main hibernate image. So on disk at hibernate, we have 1)
the encrypted hibernate image, protected by the bulk key, 2) the bulk
key, protected by the seed, and finally 3) the seed, a TPM-protected
key blob that can only be unsealed when a PCR is set to its boot
value. In our own userspace implementation we'd seal this against a
firmware PCR as well, to differentiate between Verified mode and
Developer mode.
At resume time, early userspace would find the blob, successfully
unseal it (because the PCRs had reset back to the value that matches
the policy), and push the recovered seed to the kernel. It can then
push the encrypted bulk key and encrypted hibernate image. On our
systems, this works fine as the PCRs seem to always reset across
hibernate. Is that true generally as well?
So my plan for the next spin of this series looks something like:
* Drop the tpm: and security: subsystem patches
* Keep the gist of the PM: patches as is, but instead of the TPM stuff...
* Introduce two new sysfs files, one to allow usermode to save the
seed into kernel memory, and another to lock out future changes to the
hibernate seed (until the next reboot).
* Use the hibernate seed to encrypt a randomly generated bulk key,
which is then used to encrypt the main hibernate image.
* Keep the "PM: mix user key in" patch, as we still need the image to
be encrypted with a key based on user authentication data, which this
new mechanism alone doesn't provide.
Anyone have any big objections to that plan, or see new gaping holes
in the idea? In the end I think it's actually a little nicer, as it
decouples all of the TPM-specific machinery from the concept of secure
hibernate, as well as not trying to police PCR access. Casey and Greg,
I'm going to guess you don't want to be CCed on the next spin, given
that I'm dropping the notion of taking PCR23 away from userspace.
Please holler if you would like to be CCed.
-Evan
^ permalink raw reply [flat|nested] 15+ messages in thread