Linux Integrity Measurement development
 help / color / mirror / Atom feed
From: Ross Philipson <ross.philipson@gmail.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org,
	linux-integrity@vger.kernel.org, linux-crypto@vger.kernel.org,
	linux-efi@vger.kernel.org
Cc: ross.philipson@gmail.com, dpsmith@apertussolutions.com,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	hpa@zytor.com, dave.hansen@linux.intel.com, ardb@kernel.org,
	mjg59@srcf.ucam.org, James.Bottomley@hansenpartnership.com,
	peterhuewe@gmx.de, jarkko@kernel.org, luto@amacapital.net,
	herbert@gondor.apana.org.au, davem@davemloft.net, corbet@lwn.net,
	kanth.ghatraju@oracle.com, daniel.kiper@oracle.com,
	andrew.cooper3@citrix.com, trenchboot-devel@googlegroups.com
Subject: [PATCH v2 00/10] tpm: Reorganize public headers and extract tpm-buf for standalone reuse
Date: Sat, 11 Jul 2026 09:01:00 -0700	[thread overview]
Message-ID: <20260711160110.267780-1-ross.philipson@gmail.com> (raw)

This series reorganizes the TPM subsystem's public headers for better
modularity and maintainability while extracting the `tpm_buf`
abstraction into a new standalone header (`include/linux/tpm_buf.h`).
The goal is to allow other kernel components to construct, parse, and
manipulate TPM commands, responses, and TPM2B-sized buffers without
pulling in the full set of TPM driver headers and implementation details
from `<linux/tpm.h>`.

Key elements of the series:
- Split version-specific (TPM1/TPM2), common, and platform-specific
  (PTP) definitions out of the main headers into dedicated files
  (tpm_command.h updates and the new include/linux/tpm_ptp.h).
- Clean up include dependencies (e.g., remove the main TPM header from
  the TPM event log header).
- Refine the tpm_buf implementation for improved memory safety and a
  cleaner API suitable for standalone use.
- Introduce include/linux/tpm_buf.h (with helpers for
  init/reset/append/read operations) so the buffer logic can be reused
  more broadly (e.g., by security subsystems, measurement architectures,
  or early-boot components).

This work originated in the TrenchBoot/Secure Launch development tree
but provides general benefits to the upstream kernel by reducing header
coupling and enabling safer, more reusable TPM buffer handling. It
builds on prior refactoring efforts and incorporates improvements for
robustness.

Note on this version: This is a breakout of the TPM driver related
changes from the Secure Launch v16 series. As it includes Sashiko review
changes, it is being considered v2. Another noteworthy change is the
replacement of patch #9, "tpm-buf: Implement managed allocations", with
the recently posted variation titled "tpm-buf: Memory-safe allocations".
Additional API cleanups were made to the tpm-buf code to better support
standalone reuse.

Version note: This series extracts the TPM driver-related changes from
the Secure Launch v16 series as a standalone patchset. Because it
incorporates the Sashiko review changes, it is now designated v2. A
notable update is the replacement of patch #9 ("tpm-buf: Implement
managed allocations") with the recently posted variant titled "tpm-buf:
Memory-safe allocations." Additional API cleanups were also made to the
tpm-buf code to improve its suitability for standalone reuse.

Series based off: torvalds/master
dc59e4fea9d83f03bad6bddf3fa2e52491777482

Thanks,
Ross Philipson and Daniel P. Smith

Changelog:

- Replaced "tpm-buf: Implement managed allocations" with "tpm-buf:
  Memory-safe allocations": New implementation uses fixed-size
  kzalloc(TPM_BUFSIZE) (or stack-backed) buffers with explicit capacity
  tracking, strict __tpm_buf_size_invariant checks, improved TPM2B
  handling, and validation during init/reset/append to prevent overflows,
  size mismatches, and potential memory corruption issues associated with
  the prior __get_free_page based approach.

- Updated "tpm-buf: Merge TPM_BUF_BOUNDARY_ERROR and TPM_BUF_OVERFLOW":
  Simplifies the error flag handling in the buffer abstraction by
  combining related overflow/boundary conditions into a single, clearer
  error state.

- Updated "tpm-buf: Remove chip parameter from tpm_buf_append_handle()":
  Makes the handle-append helper more generic and independent of struct
  tpm_chip, improving its suitability for standalone reuse outside the
  core TPM driver.

- Updated "tpm-buf: Add TPM buffer support header for standalone reuse":
  Refreshed to build on top of the new memory-safe implementation, the
  merged error codes, and the chip-parameter removal for a cleaner, more
  reusable public API and header.

- Header reorganization patches ("tpm: Initial step to reorganize TPM
  public headers", moves of TPM1/TPM2/common/platform definitions to
  command/ptp headers, and removal of main TPM header from event log
  header) are retained with the same overall structure and intent; they
  benefit from the refined tpm-buf code and minor consistency adjustments.

Alec Brown (1):
  tpm: Remove main TPM header from TPM event log header

Jarkko Sakkinen (3):
  tpm-buf: Merge TPM_BUF_BOUNDARY_ERROR and TPM_BUF_OVERFLOW
  tpm-buf: Remove chip parameter from tpm_buf_append_handle()
  tpm-buf: Memory-safe allocations

Ross Philipson (6):
  tpm: Initial step to reorganize TPM public headers
  tpm: Move TPM1 specific definitions to the command header
  tpm: Move TPM2 specific definitions to the command header
  tpm: Move TPM common base definitions to the command header
  tpm: Move platform specific definitions to the new PTP header
  tpm-buf: Add TPM buffer support header for standalone reuse

 drivers/char/tpm/tpm-buf.c                | 145 +++---
 drivers/char/tpm/tpm-sysfs.c              |  26 +-
 drivers/char/tpm/tpm.h                    | 180 --------
 drivers/char/tpm/tpm1-cmd.c               | 180 ++++----
 drivers/char/tpm/tpm2-cmd.c               | 321 ++++++--------
 drivers/char/tpm/tpm2-sessions.c          | 164 ++++---
 drivers/char/tpm/tpm2-space.c             |  57 +--
 drivers/char/tpm/tpm_tis_core.h           |  64 +--
 drivers/char/tpm/tpm_vtpm_proxy.c         |  30 +-
 include/keys/trusted_tpm.h                |   1 -
 include/linux/tpm.h                       | 230 +---------
 include/linux/tpm_buf.h                   |  60 +++
 include/linux/tpm_command.h               | 518 +++++++++++++++++++++-
 include/linux/tpm_eventlog.h              |   2 +-
 include/linux/tpm_ptp.h                   | 133 ++++++
 security/keys/trusted-keys/trusted_tpm1.c |  45 +-
 security/keys/trusted-keys/trusted_tpm2.c | 166 +++----
 17 files changed, 1237 insertions(+), 1085 deletions(-)
 create mode 100644 include/linux/tpm_buf.h
 create mode 100644 include/linux/tpm_ptp.h

--
2.54.0


             reply	other threads:[~2026-07-11 16:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-11 16:01 Ross Philipson [this message]
2026-07-11 16:01 ` [PATCH v2 01/10] tpm: Initial step to reorganize TPM public headers Ross Philipson
2026-07-11 16:01 ` [PATCH v2 02/10] tpm: Move TPM1 specific definitions to the command header Ross Philipson
2026-07-11 16:01 ` [PATCH v2 03/10] tpm: Move TPM2 " Ross Philipson
2026-07-11 16:01 ` [PATCH v2 04/10] tpm: Move TPM common base " Ross Philipson
2026-07-11 16:01 ` [PATCH v2 05/10] tpm: Move platform specific definitions to the new PTP header Ross Philipson
2026-07-11 16:01 ` [PATCH v2 06/10] tpm: Remove main TPM header from TPM event log header Ross Philipson
2026-07-11 16:01 ` [PATCH v2 07/10] tpm-buf: Merge TPM_BUF_BOUNDARY_ERROR and TPM_BUF_OVERFLOW Ross Philipson
2026-07-11 16:01 ` [PATCH v2 08/10] tpm-buf: Remove chip parameter from tpm_buf_append_handle() Ross Philipson
2026-07-11 16:01 ` [PATCH v2 09/10] tpm-buf: Memory-safe allocations Ross Philipson
2026-07-11 18:15   ` Jarkko Sakkinen
2026-07-11 16:01 ` [PATCH v2 10/10] tpm-buf: Add TPM buffer support header for standalone reuse Ross Philipson
2026-07-11 18:18   ` 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=20260711160110.267780-1-ross.philipson@gmail.com \
    --to=ross.philipson@gmail.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=daniel.kiper@oracle.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=dpsmith@apertussolutions.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=jarkko@kernel.org \
    --cc=kanth.ghatraju@oracle.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=mjg59@srcf.ucam.org \
    --cc=peterhuewe@gmx.de \
    --cc=tglx@linutronix.de \
    --cc=trenchboot-devel@googlegroups.com \
    --cc=x86@kernel.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