All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David R. Bild" <david.bild@xaptum.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Peter Huewe <peterhuewe@gmx.de>,
	Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	linux-usb@vger.kernel.org, linux-integrity@vger.kernel.org
Subject: [v3,2/2] usb: misc: xapea00x: perform platform initialization of TPM
Date: Fri, 4 May 2018 14:56:25 -0500	[thread overview]
Message-ID: <CAAi9uDvyzk1vnQVXkJxRCATy85g4nwMLJjqu6rr1YZn9NV_TYw@mail.gmail.com> (raw)

On Fri, May 4, 2018 at 2:06 PM, Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Fri, May 04, 2018 at 08:00:22AM -0500, David R. Bild wrote:
> > Normally the system platform (i.e., BIOS/UEFI for x86) is responsible
> > for performing initialization of the TPM.  For these modules, the host
> > kernel is the platform, so we perform the initialization in the driver
> > before registering the TPM with the kernel TPM subsystem.
>
> The tpm driver already does most of this stuff automatically, why
> duplicate it there and why is it coded in a way that doesn't use the
> existing TPM services to do it?

I didn't want to have to duplicate all that functionality and was
disappointed when that became the only option (due to the two reasons
outlined below) for supporting existing kernels with an out-of-tree
module.

Bringing the module in-tree opens the option of reworking some of the
TPM subsystem to support this use case.  I'm open to concrete
suggestions on how to do so.

1) The first reason is that I don't think the necessary pieces are
currently made available for reuse. I'd love to not repeat that code,
but

- some required structs and functions are declared in private headers
(drivers/char/tpm/*.h instead of include/linux/tpm.h).
- many of the required functions are not exported.

If the TPM maintainers are open to more of the API being "public", I
can look into preparing patches that export the necessary operations.

2) The second reason is that the initialization done by the driver is
work that should be done by platform, before the kernel ever sees the
TPM.

In particular, it sets the credentials for the platform hierarchy.
The platform hierarchy is essentially the "root" account of the TPM,
so it's critical that those credentials be set before the TPM is
exposed to user-space.  (The platform credentials aren't persisted in
the TPM and must be set by the platform on every boot.)  If the driver
registers the TPM before doing initialization, there's a chance that
something else could access the TPM before the platform credentials
get set.

The TPM system doesn't appear (to me; please correct me) to be
designed to support the following start-up sequence:

a) Driver registers the device with the TPM subsystem
b) Driver uses the TPM subsystem to perform platform initialization
(what the BIOS should have done...)
c) Driver tells the TPM subsystem to now perform the kernel
initialization of the TPM
d) TPM subsystem does its initialization of the TPM
e) TPM is exposed to userspace, added as hwrng, etc.

It would only support the sequence  [a, d, e, b] and we'd just have to
hope no one accesses the TPM between steps 'e' and 'b'.

Best,
David
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: "David R. Bild" <david.bild@xaptum.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Peter Huewe <peterhuewe@gmx.de>,
	Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	linux-usb@vger.kernel.org, linux-integrity@vger.kernel.org
Subject: Re: [PATCH v3 2/2] usb: misc: xapea00x: perform platform initialization of TPM
Date: Fri, 4 May 2018 14:56:25 -0500	[thread overview]
Message-ID: <CAAi9uDvyzk1vnQVXkJxRCATy85g4nwMLJjqu6rr1YZn9NV_TYw@mail.gmail.com> (raw)
In-Reply-To: <20180504190638.ikqhdvcqccakzdjd@ziepe.ca>

On Fri, May 4, 2018 at 2:06 PM, Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Fri, May 04, 2018 at 08:00:22AM -0500, David R. Bild wrote:
> > Normally the system platform (i.e., BIOS/UEFI for x86) is responsible
> > for performing initialization of the TPM.  For these modules, the host
> > kernel is the platform, so we perform the initialization in the driver
> > before registering the TPM with the kernel TPM subsystem.
>
> The tpm driver already does most of this stuff automatically, why
> duplicate it there and why is it coded in a way that doesn't use the
> existing TPM services to do it?

I didn't want to have to duplicate all that functionality and was
disappointed when that became the only option (due to the two reasons
outlined below) for supporting existing kernels with an out-of-tree
module.

Bringing the module in-tree opens the option of reworking some of the
TPM subsystem to support this use case.  I'm open to concrete
suggestions on how to do so.

1) The first reason is that I don't think the necessary pieces are
currently made available for reuse. I'd love to not repeat that code,
but

- some required structs and functions are declared in private headers
(drivers/char/tpm/*.h instead of include/linux/tpm.h).
- many of the required functions are not exported.

If the TPM maintainers are open to more of the API being "public", I
can look into preparing patches that export the necessary operations.

2) The second reason is that the initialization done by the driver is
work that should be done by platform, before the kernel ever sees the
TPM.

In particular, it sets the credentials for the platform hierarchy.
The platform hierarchy is essentially the "root" account of the TPM,
so it's critical that those credentials be set before the TPM is
exposed to user-space.  (The platform credentials aren't persisted in
the TPM and must be set by the platform on every boot.)  If the driver
registers the TPM before doing initialization, there's a chance that
something else could access the TPM before the platform credentials
get set.

The TPM system doesn't appear (to me; please correct me) to be
designed to support the following start-up sequence:

a) Driver registers the device with the TPM subsystem
b) Driver uses the TPM subsystem to perform platform initialization
(what the BIOS should have done...)
c) Driver tells the TPM subsystem to now perform the kernel
initialization of the TPM
d) TPM subsystem does its initialization of the TPM
e) TPM is exposed to userspace, added as hwrng, etc.

It would only support the sequence  [a, d, e, b] and we'd just have to
hope no one accesses the TPM between steps 'e' and 'b'.

Best,
David

             reply	other threads:[~2018-05-04 19:56 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04 19:56 David R. Bild [this message]
2018-05-04 19:56 ` [PATCH v3 2/2] usb: misc: xapea00x: perform platform initialization of TPM David R. Bild
  -- strict thread matches above, loose matches on Subject: below --
2018-05-25 20:31 [v3,2/2] " Ken Goldman
2018-05-25 20:31 ` [PATCH v3 2/2] " Ken Goldman
2018-05-25 20:23 [v3,2/2] " Ken Goldman
2018-05-25 20:23 ` [PATCH v3 2/2] " Ken Goldman
2018-05-14 20:12 [v3,2/2] " David R. Bild
2018-05-14 20:12 ` [PATCH v3 2/2] " David R. Bild
2018-05-14 20:08 [v3,2/2] " Jason Gunthorpe
2018-05-14 20:08 ` [PATCH v3 2/2] " Jason Gunthorpe
2018-05-14 19:59 [v3,2/2] " David R. Bild
2018-05-14 19:59 ` [PATCH v3 2/2] " David R. Bild
2018-05-14 19:31 [v3,2/2] " Jason Gunthorpe
2018-05-14 19:31 ` [PATCH v3 2/2] " Jason Gunthorpe
2018-05-13  8:51 [v3,2/2] " Jarkko Sakkinen
2018-05-13  8:51 ` [PATCH v3 2/2] " Jarkko Sakkinen
2018-05-13  8:46 [v3,2/2] " Jarkko Sakkinen
2018-05-13  8:46 ` [PATCH v3 2/2] " Jarkko Sakkinen
2018-05-10 15:17 [v3,2/2] " David R. Bild
2018-05-10 15:17 ` [PATCH v3 2/2] " David R. Bild
2018-05-10 14:47 [v3,2/2] " James Bottomley
2018-05-10 14:47 ` [PATCH v3 2/2] " James Bottomley
2018-05-10 14:41 [v3,2/2] " David R. Bild
2018-05-10 14:41 ` [PATCH v3 2/2] " David R. Bild
2018-05-10 14:31 [v3,2/2] " David R. Bild
2018-05-10 14:31 ` [PATCH v3 2/2] " David R. Bild
2018-05-10 14:29 [v3,2/2] " David R. Bild
2018-05-10 14:29 ` [PATCH v3 2/2] " David R. Bild
2018-05-10 14:25 [v3,2/2] " David R. Bild
2018-05-10 14:25 ` [PATCH v3 2/2] " David R. Bild
2018-05-10 14:09 [v3,2/2] " David R. Bild
2018-05-10 14:09 ` [PATCH v3 2/2] " David R. Bild
2018-05-10  1:59 [v3,2/2] " Jarkko Sakkinen
2018-05-10  1:59 ` [PATCH v3 2/2] " Jarkko Sakkinen
2018-05-10  1:44 [v3,2/2] " Jarkko Sakkinen
2018-05-10  1:44 ` [PATCH v3 2/2] " Jarkko Sakkinen
2018-05-10  1:42 [v3,2/2] " Jarkko Sakkinen
2018-05-10  1:42 ` [PATCH v3 2/2] " Jarkko Sakkinen
2018-05-10  1:42 [v3,2/2] " Jarkko Sakkinen
2018-05-10  1:42 ` [PATCH v3 2/2] " Jarkko Sakkinen
2018-05-08 15:36 [v3,2/2] " James Bottomley
2018-05-08 15:36 ` [PATCH v3 2/2] " James Bottomley
2018-05-08 15:29 [v3,2/2] " David R. Bild
2018-05-08 15:29 ` [PATCH v3 2/2] " David R. Bild
2018-05-08 15:25 [v3,2/2] " James Bottomley
2018-05-08 15:25 ` [PATCH v3 2/2] " James Bottomley
2018-05-08 10:55 [v3,2/2] " Jarkko Sakkinen
2018-05-08 10:55 ` [PATCH v3 2/2] " Jarkko Sakkinen
2018-05-08 10:47 [v3,2/2] " Jarkko Sakkinen
2018-05-08 10:47 ` [PATCH v3 2/2] " Jarkko Sakkinen
2018-05-08  9:09 [v3,1/2] usb: misc: xapea00x: add driver for Xaptum ENF Access Card Oliver Neukum
2018-05-08  9:09 ` [PATCH v3 1/2] " Oliver Neukum
2018-05-07 14:12 EXTERNAL: [PATCH v3 2/2] usb: misc: xapea00x: perform platform initialization of TPM Jeremy Boone
2018-05-07 14:12 ` Jeremy Boone
2018-05-07 13:31 [v3,1/2] usb: misc: xapea00x: add driver for Xaptum ENF Access Card David R. Bild
2018-05-07 13:31 ` [PATCH v3 1/2] " David R. Bild
2018-05-07  9:58 [v3,1/2] " Oliver Neukum
2018-05-07  9:58 ` [PATCH v3 1/2] " Oliver Neukum
2018-05-06 15:02 [v3,2/2] usb: misc: xapea00x: perform platform initialization of TPM Jason Gunthorpe
2018-05-06 15:02 ` [PATCH v3 2/2] " Jason Gunthorpe
2018-05-04 20:19 [v3,2/2] " David R. Bild
2018-05-04 20:19 ` [PATCH v3 2/2] " David R. Bild
2018-05-04 19:06 [v3,2/2] " Jason Gunthorpe
2018-05-04 19:06 ` [PATCH v3 2/2] " Jason Gunthorpe
2018-05-04 13:00 [v3,2/2] " David R. Bild
2018-05-04 13:00 ` [PATCH v3 2/2] " David R. Bild
2018-05-04 13:00 [v3,1/2] usb: misc: xapea00x: add driver for Xaptum ENF Access Card David R. Bild
2018-05-04 13:00 ` [PATCH v3 1/2] " David R. Bild
     [not found] <20180430125418.31344-1-david.bild@xaptum.com>
2018-05-04 13:00 ` [PATCH v3 0/2] Add driver for Xaptum ENF Access card (XAP-EA-00x) David R. Bild

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=CAAi9uDvyzk1vnQVXkJxRCATy85g4nwMLJjqu6rr1YZn9NV_TYw@mail.gmail.com \
    --to=david.bild@xaptum.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    /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 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.