Skip to content

Extend struct tpm_buf to support sized buffers (TPM2B)

Jarkko Sakkinen linux-integrity lkml 8 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest8 patches 10 repliesIn review
  2. v5 posting 2/28 patches 7 repliesSuperseded
  3. v5 posting 1/22 of 8 patches 0 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v48 patches0 repliesSuperseded
v36 patches26 repliesSuperseded
v2 posting 2/20 of 6 patches0 repliesSuperseded
v2 posting 1/26 patches0 repliesSuperseded
v15 patches0 repliesSuperseded

Changes in v6 from the cover letter

- 7/8: fixed off-by-one error in the boundary check

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8tpm: Remove unused tpm_buf_tag()include/linux/tpm.h+0 -71 reply
2/8tpm: Remove tpm_send()drivers/char/tpm/tpm-interface.c include/linux/tpm.h security/keys/trusted-keys/trusted_tpm1.c+12 -321 reply
3/8tpm: Move buffer handling from static inlines to real functionsdrivers/char/tpm/Makefile drivers/char/tpm/tpm-buf.c include/linux/tpm.h+97 -711 reply
4/8tpm: Update struct tpm_buf documentation commentsinclude/linux/tpm.h+4 -52 replies
5/8tpm: Store the length of the tpm_buf data separately.drivers/char/tpm/tpm-buf.c drivers/char/tpm/tpm-interface.c include/keys/trusted_tpm.h +2 more+46 -201 reply
6/8tpm: TPM2B formatted buffersdrivers/char/tpm/tpm-buf.c include/linux/tpm.h+39 -31 reply
7/8tpm: Add tpm_buf_read_{u8,u16,u32}drivers/char/tpm/tpm-buf.c include/linux/tpm.h+83 -12 replies
8/8KEYS: trusted: tpm2: Use struct tpm_buf for sized bufferssecurity/keys/trusted-keys/trusted_tpm2.c+31 -231 reply

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchStefan Berger
1/8R-b
2/8R-b
3/8R-b
4/8R-b
5/8R-b
6/8R-b
7/8R-b
8/8R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH v6 0/8] Extend struct tpm_buf to support sized buffers (TPM2B)

This patch set extends struct tpm_buf to support TPM2 sized buffers, and adds reader functions for parsing more complex response data. It is implemented to support smooth landing of [2]. Sealing of the TPM2 trusted keys is updated to utilize the new functionality, and thus provides a legit test case for it.

TPM2 sized buffer, i.e. the buffers in TPM2 format, are defined in the section 10.4 of the TPM2 Structures [1] specification.

Here's the smoke test that I've run for TPM2:

/usr/lib/kselftests/run_kselftest.sh
tpm2_createprimary --hierarchy o -G rsa2048 -c key.ctxt tpm2_evictcontrol -c key.ctxt 0x81000001
keyctl add trusted kmk "new 32 keyhandle=0x81000001" @u keyctl add encrypted 1000100010001000 "new ecryptfs trusted:kmk 64" @u

[1] https://trustedcomputinggroup.org/resource/tpm-library-specification/
[2] https://lore.kernel.org/linux-integrity/[email protected]/

v6:
- 7/8: fixed off-by-one error in the boundary check
v5:
- Fixed glitch in tpm_buf_read() reported by James Bottomley to the v4. Was forgotten from v4.
- Remove a spurious memset() call introduced in v4.
- Allow command buffer tag to be initially set to zero (caused spurious warnings).
v4:
- Cleaned up the bit too spread code changes based on the v3 review.
- For testing instructions see the previous cover letter, and use linux-v6.6.y branch:
https://lore.kernel.org/linux-integrity/[email protected]/
v3:
- Resend with rebase to the latest upstream.

Cc James Bottomley <[email protected]>
Cc William Roberts <[email protected]>
Cc Stefan Berger <[email protected]>
Cc David Howells <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Mimi Zohar <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Jerry Snitselaar <[email protected]>

James Bottomley (1):
tpm: Move buffer handling from static inlines to real functions

Jarkko Sakkinen (7):
tpm: Remove unused tpm_buf_tag()
tpm: Remove tpm_send()
tpm: Update struct tpm_buf documentation comments
tpm: Store the length of the tpm_buf data separately.
tpm: TPM2B formatted buffers
tpm: Add tpm_buf_read_{u8,u16,u32}
KEYS: trusted: tpm2: Use struct tpm_buf for sized buffers

 drivers/char/tpm/Makefile                 |   1 +
 drivers/char/tpm/tpm-buf.c                | 222 ++++++++++++++++++++++
 drivers/char/tpm/tpm-interface.c          |  26 +--
 include/keys/trusted_tpm.h                |   2 -
 include/linux/tpm.h                       | 112 +++--------
 security/keys/trusted-keys/trusted_tpm1.c |  23 ++-
 security/keys/trusted-keys/trusted_tpm2.c |  54 +++---
 7 files changed, 295 insertions(+), 145 deletions(-)
 create mode 100644 drivers/char/tpm/tpm-buf.c
Signature · 1 line
2.43.0