mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Srish Srinivasan <ssrish@linux.ibm.com>,
	linux-integrity@vger.kernel.org, keyrings@vger.kernel.org,
	James.Bottomley@hansenpartnership.com, zohar@linux.ibm.com,
	stefanb@linux.ibm.com, linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org, nayna@linux.ibm.com,
	rnsastry@linux.ibm.com
Subject: Re: [PATCH v2] keys/trusted_keys: reuse TPM version in option handling
Date: Tue, 6 Oct 2026 00:57:58 +0300	[thread overview]
Message-ID: <asQdZiv7uktfyRWU@kernel.org> (raw)
In-Reply-To: <asP8sl912TVaCEIE@kernel.org>

On Mon, Oct 05, 2026 at 10:38:32PM +0300, Jarkko Sakkinen wrote:
> On Mon, Oct 05, 2026 at 10:01:32AM -0500, Serge E. Hallyn wrote:
> > On Mon, Oct 05, 2026 at 11:31:46AM +0530, Srish Srinivasan wrote:
> > > Hi Jarkko,
> > > 
> > > On 10/5/26 8:54 AM, Jarkko Sakkinen wrote:
> > > > On Fri, Oct 02, 2026 at 12:40:50PM +0530, Srish Srinivasan wrote:
> > > > > Determine the TPM version once in the seal and unseal paths and reuse it
> > > > > when allocating and parsing trusted key options. This avoids redundant TPM
> > > > > version checks.
> > > > So this is a bit nitpicking perhaps but a patch that would just clean
> > > > the code up a bit would not be be worth of applying. Almost anything
> > > > that "does nothing" goes to that bin.
> > > > 
> > > > What I'm saying is that the conclusion in the last sentence goes to
> > > > wrong direction but luckily the change has also feasible effects that
> > > > we care about.
> > > > 
> > > > By caching tpm_is_tpm2() there are less fallible sites in the key
> > > > creation process, and reduced number of roundtrips with the TPM chip.
> > > > 
> > > > Or from blackbox perspective it reduces I/O traffic between kernel
> > > > and the hardware platform.
> > > 
> > > 
> > > Yes, that makes sense. Thank you for pointing this out.
> > > 
> > > I will revise the commit message to highlight the reduced failure
> > > surface and I/O between the kernel and the TPM, and
> > > send v3.
> > 
> > And I've seen chips where every round trip is a roll of the dice as
> > to whether the chip will become useless till next reboot, so that is
> > a bigger win than I was first thinking.
> 
> This is true and happens quite often. And in CPU companies in fact all
> the time with early FPGA implementations and very early ASIC based
> software development platforms.
> 
> We also have opt-in bus encryption feature where extra roundtrips have
> a horrible time cost.
> 
> Roundtrip removals are high value patches for both R&D and production,
> and they are always most welcome.

Serge, your comment reminded me of hwrng. In my opinion TPM driver
should limit itself randomness supply because it could have positive
effect on some issues that people are having [1]. hwrng can never
properly control TPM as it is behind abstraction.

I think there should be a tpm_chip associated pool of randomness. This
pool is filled with some timer triggering with a constant frequency. On
each iteration, it is filled with best effort i.e. with a single
TPM2_GetRandom invocation.

Then hwrng_fill is also filled with best effort from the pool without
any TPM interaction.

This would be an architecture that would be vastly easier to deduce
than the one which we have now, which is more unstable, which is
bad considering e.g., latency peaks and whatnot.

This basic idea can be improved with a low watermark: when going 
below it hwrng_fillfn would start the timer. I don't think high
watermark is needed as pool can be always filled just up to its
size.

I had this idea already 3-4 years ago but had forgotten about it.

[1] https://bugzilla.kernel.org/show_bug.cgi?id=217890

Br, Jarkkko

      reply	other threads:[~2026-10-05 21:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02  7:10 Srish Srinivasan
2026-10-05  3:24 ` Jarkko Sakkinen
2026-10-05  6:01   ` Srish Srinivasan
2026-10-05 15:01     ` Serge E. Hallyn
2026-10-05 19:38       ` Jarkko Sakkinen
2026-10-05 21:57         ` Jarkko Sakkinen [this message]

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=asQdZiv7uktfyRWU@kernel.org \
    --to=jarkko@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --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=nayna@linux.ibm.com \
    --cc=rnsastry@linux.ibm.com \
    --cc=serge@hallyn.com \
    --cc=ssrish@linux.ibm.com \
    --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

all inboxes | Powered by JetHome®