[PATCH v9 0/8] Prepare TPM driver for Trenchboot

Jarkko Sakkinen
2025-11-28T02:54:16Z

Overview
========

Start preparing TPM driver for Trenchboot by decoupling tpm_buf from
driver and memory allocation.

Backlog (of stuff that will end up to a follow-up patch sets):

1. Static flat duration table for TPM 1.2. Such feature already landed
in v6.17 for TPM 2.0. We probably can figure out some sane roof
values for the legacy standard, right? This allows to share more
code "via data".
2. Not a blocker for sending subsequent versions of Trenchboot patch set
but we could look at slicing tpm_tis code at some point of future.
It could be even that redundant parts could be "merged" after the
feature lands but this is neither a promise (depends on how things
look overall).

This patch set does not do a lot heavy-lifting but is beefed enough that
it is better not fatten it up too much anymore. Sane buffering is a
great starting point.

v9:
- Dropped patches that went into 6.19 pull request (and that is main
reason for sending update so quickly).
- I went through the commit message and polished a bit most of them
- Simplified the patch fixing memory leak in tpm2_load_cmd.
v8:
- Fixed reported issues.
- Did some focused testing on TPM 1.2 using swtpm to make sure that
it is working correctly.
v7:
- Fixed reported issues.
v6:
- Fixed a memory leak that I found trom trusted keys.
v5:
- Order sobs correctly.
- Fixed a minor glitch in 9/9.
v4:
- PCR patch has been removed because it does not fly without Trenchboot
context.
v3:
- I think 6.19 is a better goal for this and thus expanded the series to
be a generic Trenchboot enablers series. This version also consolidates
my two separate ongoing series.
v2:
- While including fixes from v1, this patch set has a refocus in order to
do minimal changes to make code base more compatible Trenchboot.

Jarkko Sakkinen (8):
tpm2-sessions: Remove 'attributes' parameter from tpm_buf_append_auth
tpm2-sessions: Open code tpm_buf_append_hmac_session()
KEYS: trusted: Replace a redundant instance of tpm2_hash_map
KEYS: trusted: Fix a memory leak in tpm2_load_cmd
KEYS: trusted: Open code tpm2_buf_append()
tpm-buf: Merge TPM_BUF_BOUNDARY_ERROR and TPM_BUF_OVERFLOW
tpm-buf: Remove chip parameter from tpm_buf_append_handle
tpm-buf: Enable managed and stack allocations.

drivers/char/tpm/tpm-buf.c | 143 ++++++----
drivers/char/tpm/tpm-sysfs.c | 21 +-
drivers/char/tpm/tpm.h | 1 -
drivers/char/tpm/tpm1-cmd.c | 162 +++++------
drivers/char/tpm/tpm2-cmd.c | 319 +++++++++++-----------
drivers/char/tpm/tpm2-sessions.c | 129 +++++----
drivers/char/tpm/tpm2-space.c | 44 ++-
drivers/char/tpm/tpm_vtpm_proxy.c | 30 +-
include/linux/tpm.h | 56 ++--
security/keys/trusted-keys/trusted_tpm1.c | 36 +--
security/keys/trusted-keys/trusted_tpm2.c | 245 +++++++----------
11 files changed, 544 insertions(+), 642 deletions(-)

--
2.52.0