Skip to content

tpm: assorted fixes and cleanups

Pei Xiao linux-integrity lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5tpm: tpm_ppi: fix wrong error code returned to user spacedrivers/char/tpm/tpm_ppi.c+1 -13 replies
2/5tpm: tpm_nsc: fix NULL pointer dereference on init failuredrivers/char/tpm/tpm_nsc.c+6 -11 reply
3/5tpm: tpm_nsc: stop using the cleanup callback as dev.releasedrivers/char/tpm/tpm_nsc.c+0 -11 reply
4/5tpm: fix zero-length read discarding the pending responsedrivers/char/tpm/tpm-dev-common.c+3 -01 reply
5/5tpm: fix log messages in tpm_init()drivers/char/tpm/tpm-interface.c+3 -35 replies

Reviews trailers per patch

3 of 5 patches have a Reviewed-by or Acked-by.

PatchJarkko Sakkinen
1/5
2/5R-b
3/5R-b
4/5R-b
5/5

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

Read the v1 thread

Cover letter [PATCH 0/5] tpm: assorted fixes and cleanups

This series fixes several issues found during a code review of drivers/char/tpm:

1. tpm_ppi: tpm_show_ppi_response() stores its return value in an acpi_status (a u32 typedef), so error codes such as -EINVAL reach user space as huge positive values. Declare the variable as ssize_t to match the show callback's return type.

2. tpm_nsc: tpm_nsc_remove() doubles as the release callback of the hand-created platform device and dereferences the chip drvdata unconditionally; init failures before tpmm_chip_alloc() crash module load. Return early when the chip has not been created.

3. tpm_nsc: the cleanup runs twice on module exit because tpm_nsc_remove() is both the explicit cleanup and the device release callback; the second run operates on an already freed chip. Stop overriding the release callback, which also stops the platform object allocation from leaking.

4. tpm_dev: a zero-length read() discards a pending response, breaking the command/response pairing of the TPM character devices, although POSIX requires zero-count reads to have no side effects. Return early on a zero count.

5. tpm-interface: make the tpm_init() error messages consistently prefixed with "tpm: " and report the actual failure of tpm_dev_common_init().

The series was prepared with AI assistance (GLM-5.3); every change was reviewed against the code by hand.

Pei Xiao (5):
tpm: tpm_ppi: fix wrong error code returned to user space
tpm: tpm_nsc: fix NULL pointer dereference on init failure
tpm: tpm_nsc: stop using the cleanup callback as dev.release
tpm: fix zero-length read discarding the pending response
tpm: fix log messages in tpm_init()

 drivers/char/tpm/tpm-dev-common.c | 3 +++
 drivers/char/tpm/tpm-interface.c  | 6 +++---
 drivers/char/tpm/tpm_nsc.c        | 8 ++++++--
 drivers/char/tpm/tpm_ppi.c        | 2 +-
 4 files changed, 13 insertions(+), 6 deletions(-)
Signature · 1 line
2.25.1