mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: Jerry Snitselaar <jsnitsel@redhat.com>,
	Jarkko Sakkinen <jarkko@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Daniil Stas <daniil.stas@posteo.net>,
	Mario Limonciello <mario.limonciello@amd.com>,
	James.Bottomley@hansenpartnership.com, Jason@zx2c4.com,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	regressions@leemhuis.info, stable@vger.kernel.org
Subject: Re: [PATCH 1/1] tpm: disable hwrng for fTPM on some AMD designs
Date: Wed, 2 Aug 2023 20:34:33 -0400	[thread overview]
Message-ID: <e21da81e-5e18-1aec-cc63-f316cdf0d2fc@linux.ibm.com> (raw)
In-Reply-To: <ejqnhdrhktfrhcb76bxx6y73hydjov34t7m4wrvzjc22gdtzts@p4g7yqxdnijn>



On 8/2/23 19:13, Jerry Snitselaar wrote:
> On Tue, Aug 01, 2023 at 10:09:58PM +0300, Jarkko Sakkinen wrote:
>> On Tue Aug 1, 2023 at 9:42 PM EEST, Linus Torvalds wrote:
>>> On Tue, 1 Aug 2023 at 11:28, Jarkko Sakkinen <jarkko@kernel.org> wrote:
>>>>
>>>> I would disable it inside tpm_crb driver, which is the driver used
>>>> for fTPM's: they are identified by MSFT0101 ACPI identifier.
>>>>
>>>> I think the right scope is still AMD because we don't have such
>>>> regressions with Intel fTPM.
>>>
>>> I'm ok with that.
>>>
>>>> I.e. I would move the helper I created inside tpm_crb driver, and
>>>> a new flag, let's say "TPM_CHIP_FLAG_HWRNG_DISABLED", which tpm_crb
>>>> sets before calling tpm_chip_register().
>>>>
>>>> Finally, tpm_add_hwrng() needs the following invariant:
>>>>
>>>>          if (chip->flags & TPM_CHIP_FLAG_HWRNG_DISABLED)
>>>>                  return 0;
>>>>
>>>> How does this sound? I can refine this quickly from my first trial.
>>>
>>> Sounds fine.
>>
>> Mario, it would be good if you could send a fix candidate but take my
>> suggestion for a new TPM chip flag into account, while doing it. Please
>> send it as a separate patch, not attachment to this thread.
>>
>> I can test and ack it, if it looks reasonable.
>>
>>> My only worry comes from my ignorance: do these fTPM devices *always*
>>> end up being enumerated through CRB, or do they potentially look
>>> "normal enough" that you can actually end up using them even without
>>> having that CRB driver loaded?
>>
>> I know that QEMU has TPM passthrough but I don't know how it behaves
>> exactly.
>>
> 
> I just created a passthrough tpm device with a guest which it is using
> the tis driver, while the host is using crb (and apparently one of the
> amd devices that has an impacted fTPM). It looks like there is a
> complete separation between the frontend and backends, with the front
> end providing either a tis or crb interface to the guest, and then the
> backend sending commands by writing to the passthrough device that was
> given, such as /dev/tpm0, or an emulator such as swtpm. Stefan can
> probably explain it much better than I.


You explained it well... The passthrough TPM is only good for one VM (if
at all), and all other VMs on the same machine should use a vTPM. Even
one VM sharing the TPM with the host creates a potential mess with the
shared resources of the TPM, such as the state of the PCRs.

When that guest VM using the passthrough device now identifies the underlying
hardware TPM's firmware version it will also take the same action to disable
the TPM as a source for randomness. But then a VM with a passthrough TPM
device should be rather rare...

> 
>>> Put another way: is the CRB driver the _only_ way they are visible, or
>>> could some people hit on this through the TPM TIS interface if they
>>> have CRB disabled?
>>
>> I'm not aware of such implementations.

CRB and TIS are two distinct MMIO type of interfaces with different registers etc.

AMD could theoretically build a fTPM with a CRB interface and then another one with the same firmware and the TIS, but why would they?

    Stefan


>>
>>> I see, for example, that qemu ends up emulating the TIS layer, and it
>>> might end up forwarding the TPM requests to something that is natively
>>> CRB?
>>>
>>> But again: I don't know enough about CRB vs TIS, so the above may be a
>>> stupid question.



>>>
>>>             Linus
>>
>> I would focus exactly what is known not to work and disable exactly
>> that.
>>
>> If someone still wants to enable TPM on such hardware, we can later
>> on add a kernel command-line flag to enforce hwrng. This ofc based
>> on user feedback, not something I would add right now.
>>
>> BR, Jarkko
> 

  reply	other threads:[~2023-08-03  0:57 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 20:19 [PATCH 0/1] Avoid triggering an fTPM bug from kernel Mario Limonciello
2023-02-14 20:19 ` [PATCH 1/1] tpm: disable hwrng for fTPM on some AMD designs Mario Limonciello
2023-02-17 15:18   ` Thorsten Leemhuis
2023-02-17 22:35     ` Jarkko Sakkinen
2023-02-18  2:25       ` Limonciello, Mario
2023-02-21 22:53         ` Jarkko Sakkinen
2023-02-21 23:10           ` Limonciello, Mario
2023-02-27 10:57             ` Thorsten Leemhuis
2023-02-27 11:14               ` Jarkko Sakkinen
2023-02-27 11:16                 ` Jarkko Sakkinen
2023-02-17 22:05   ` Jarkko Sakkinen
2023-07-27 15:38   ` Daniil Stas
2023-07-27 15:42     ` Mario Limonciello
2023-07-27 16:39       ` Daniil Stas
2023-07-27 16:41         ` Mario Limonciello
2023-07-27 16:50           ` Daniil Stas
2023-07-27 16:51             ` Mario Limonciello
2023-07-27 17:05               ` Daniil Stas
2023-07-28 20:41                 ` Linus Torvalds
2023-07-28 21:01                   ` Limonciello, Mario
2023-07-28 21:38                     ` Linus Torvalds
2023-07-28 21:47                       ` Limonciello, Mario
     [not found]                   ` <CUGAV1Y993FB.1O2Q691015Z2C@seitikki>
2023-07-31 19:05                     ` Linus Torvalds
2023-07-31 19:18                       ` Limonciello, Mario
2023-07-31 19:30                         ` Linus Torvalds
2023-07-31 21:57                           ` Limonciello, Mario
2023-07-31 23:28                             ` Linus Torvalds
2023-07-31 23:40                               ` Jason A. Donenfeld
2023-08-01  3:04                                 ` Mario Limonciello
2023-08-01 11:36                                   ` Mateusz Schyboll
2023-08-01 18:52                                   ` Jarkko Sakkinen
2023-08-01 18:55                                     ` Jarkko Sakkinen
2023-08-01 18:28                       ` Jarkko Sakkinen
2023-08-01 18:42                         ` Linus Torvalds
2023-08-01 18:51                           ` Mario Limonciello
2023-08-01 19:09                           ` Jarkko Sakkinen
2023-08-02 23:13                             ` Jerry Snitselaar
2023-08-03  0:34                               ` Stefan Berger [this message]
2023-07-31 21:44                     ` Limonciello, Mario
2023-07-28 19:30     ` Jarkko Sakkinen
2023-07-28 20:18       ` Daniil Stas
2023-07-31 10:14         ` Jarkko Sakkinen
2023-07-31 10:28           ` Daniil Stas
2023-07-31 11:07             ` 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=e21da81e-5e18-1aec-cc63-f316cdf0d2fc@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=Jason@zx2c4.com \
    --cc=daniil.stas@posteo.net \
    --cc=jarkko@kernel.org \
    --cc=jsnitsel@redhat.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=regressions@leemhuis.info \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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

Powered by JetHome