[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y3Fr//gNYls25Ug3@sol.localdomain>
Date: Sun, 13 Nov 2022 14:13:19 -0800
From: Eric Biggers <ebiggers@...nel.org>
To: Evan Green <evgreen@...omium.org>
Cc: linux-kernel@...r.kernel.org, corbet@....net,
linux-integrity@...r.kernel.org, gwendal@...omium.org,
dianders@...omium.org, apronin@...omium.org,
Pavel Machek <pavel@....cz>, Ben Boeckel <me@...boeckel.net>,
rjw@...ysocki.net, jejb@...ux.ibm.com,
Kees Cook <keescook@...omium.org>, dlunev@...gle.com,
zohar@...ux.ibm.com, Matthew Garrett <mgarrett@...ora.tech>,
jarkko@...nel.org, linux-pm@...r.kernel.org,
Matthew Garrett <mjg59@...gle.com>,
David Howells <dhowells@...hat.com>,
James Morris <jmorris@...ei.org>,
Paul Moore <paul@...l-moore.com>,
"Serge E. Hallyn" <serge@...lyn.com>, axelj <axelj@...s.com>,
keyrings@...r.kernel.org, linux-security-module@...r.kernel.org
Subject: Re: [PATCH v5 06/11] security: keys: trusted: Verify creation data
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
Powered by blists - more mailing lists