From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Jarkko Sakkinen" <jarkko@kernel.org>,
"James Bottomley" <James.Bottomley@HansenPartnership.com>,
<linux-integrity@vger.kernel.org>,
"Peter Huewe" <peterhuewe@gmx.de>,
"Jason Gunthorpe" <jgg@ziepe.ca>
Cc: <linux-kernel@vger.kernel.org>,
"David Howells" <dhowells@redhat.com>,
"Mimi Zohar" <zohar@linux.ibm.com>,
"Roberto Sassu" <roberto.sassu@huawei.com>,
"Stefan Berger" <stefanb@linux.ibm.com>,
"Paul Moore" <paul@paul-moore.com>,
"James Morris" <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
"Dmitry Kasatkin" <dmitry.kasatkin@gmail.com>,
"Eric Snowberg" <eric.snowberg@oracle.com>,
"open list:KEYS-TRUSTED" <keyrings@vger.kernel.org>,
"open list:SECURITY SUBSYSTEM"
<linux-security-module@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH v8 2/3] tpm: Rollback tpm2_load_null()
Date: Thu, 31 Oct 2024 01:50:57 +0200 [thread overview]
Message-ID: <D59JLDCHCZPD.3CA4121HVVJXL@kernel.org> (raw)
In-Reply-To: <D59JG45GJC5V.1HT5KJQ0K4CKI@kernel.org>
On Thu Oct 31, 2024 at 1:44 AM EET, Jarkko Sakkinen wrote:
> On Wed Oct 30, 2024 at 5:47 PM EET, James Bottomley wrote:
> > On Mon, 2024-10-28 at 07:50 +0200, Jarkko Sakkinen wrote:
> > [...]
> > > --- a/drivers/char/tpm/tpm2-sessions.c
> > > +++ b/drivers/char/tpm/tpm2-sessions.c
> > > @@ -915,33 +915,37 @@ static int tpm2_parse_start_auth_session(struct
> > > tpm2_auth *auth,
> > >
> > > static int tpm2_load_null(struct tpm_chip *chip, u32 *null_key)
> > > {
> > > - int rc;
> > > unsigned int offset = 0; /* dummy offset for null seed
> > > context */
> > > u8 name[SHA256_DIGEST_SIZE + 2];
> > > + u32 tmp_null_key;
> > > + int rc;
> > >
> > > rc = tpm2_load_context(chip, chip->null_key_context, &offset,
> > > - null_key);
> > > - if (rc != -EINVAL)
> > > - return rc;
> > > + &tmp_null_key);
> > > + if (rc != -EINVAL) {
> > > + if (!rc)
> > > + *null_key = tmp_null_key;
> > > + goto err;
> > > + }
> > >
> > > - /* an integrity failure may mean the TPM has been reset */
> > > - dev_err(&chip->dev, "NULL key integrity failure!\n");
> > > - /* check the null name against what we know */
> > > - tpm2_create_primary(chip, TPM2_RH_NULL, NULL, name);
> > > - if (memcmp(name, chip->null_key_name, sizeof(name)) == 0)
> > > - /* name unchanged, assume transient integrity failure
> > > */
> > > - return rc;
> > > - /*
> > > - * Fatal TPM failure: the NULL seed has actually changed, so
> > > - * the TPM must have been illegally reset. All in-kernel TPM
> > > - * operations will fail because the NULL primary can't be
> > > - * loaded to salt the sessions, but disable the TPM anyway so
> > > - * userspace programmes can't be compromised by it.
> > > - */
> > > - dev_err(&chip->dev, "NULL name has changed, disabling TPM due
> > > to interference\n");
> > > + /* Try to re-create null key, given the integrity failure: */
> > > + rc = tpm2_create_primary(chip, TPM2_RH_NULL, &tmp_null_key,
> > > name);
> > > + if (rc)
> > > + goto err;
> >
> > From a security point of view, this probably isn't such a good idea:
> > the reason the context load failed above is likely the security
> > condition we're checking for: the null seed changed because an
> > interposer did a reset. That means that if the interposer knows about
> > this error leg, it would simply error out the create primary here and
> > the TPM wouldn't be disabled.
>
> If you think there is something that should be still addressed, or there
> is overlooked issue please do send a patch, and we will review that.
> There's been plenty of time to comment on patches.
>
> Neither in previous TPM_CHIP_FLAG_DISABLED was set tpm2_load_context()
> failed. It went like this:
>
> rc = tpm2_load_context(chip, chip->null_key_context, &offset,
> null_key);
> if (rc != -EINVAL)
> return rc;
>
> If you think that this should be addressed, do send a patch but point
> out the fixes-tag to your original patch then.
Also want to denotat that I specifically did not set flag because I
thought you had good reasons not to disable TPM. So it was left like
that knowingly, definitely not by ignorance. Good that it became now
apparent and I'm happy to take a fix in (with correct fixes tag).
BR, Jarkko
next prev parent reply other threads:[~2024-10-30 23:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 5:49 [PATCH v8 0/3] Lazy flush for the auth session Jarkko Sakkinen
2024-10-28 5:49 ` [PATCH v8 1/3] tpm: Return tpm2_sessions_init() when null key creation fails Jarkko Sakkinen
2024-10-28 13:00 ` Stefan Berger
2024-10-28 15:27 ` Jarkko Sakkinen
2024-10-28 5:50 ` [PATCH v8 2/3] tpm: Rollback tpm2_load_null() Jarkko Sakkinen
2024-10-28 6:13 ` Paul Menzel
2024-10-28 12:10 ` Jarkko Sakkinen
2024-10-28 12:38 ` Paul Menzel
2024-10-28 12:42 ` Jarkko Sakkinen
2024-10-30 15:47 ` James Bottomley
2024-10-30 23:44 ` Jarkko Sakkinen
2024-10-30 23:50 ` Jarkko Sakkinen [this message]
2024-10-28 5:50 ` [PATCH v8 3/3] tpm: Lazily flush the auth session Jarkko Sakkinen
2024-10-28 17:52 ` Stefan Berger
2024-10-28 20:56 ` Jarkko Sakkinen
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=D59JLDCHCZPD.3CA4121HVVJXL@kernel.org \
--to=jarkko@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=dhowells@redhat.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=eric.snowberg@oracle.com \
--cc=jgg@ziepe.ca \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=peterhuewe@gmx.de \
--cc=roberto.sassu@huawei.com \
--cc=serge@hallyn.com \
--cc=stable@vger.kernel.org \
--cc=stefanb@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).