mbox series

[v3,0/2] tpm: Resolve potential blocking-forever issue

Message ID 20241016145708.1166471-1-stefanb@linux.ibm.com (mailing list archive)
Headers show
Series tpm: Resolve potential blocking-forever issue | expand

Message

Stefan Berger Oct. 16, 2024, 2:57 p.m. UTC
In case swtpm was to return a control channel message with an error code it
would often return less bytes than the full response. In some cases the
current reading of the returned bytes would get stuck since more bytes are
expected. Therefore, pass a separate parameter indicating how many bytes to
expect in case of an error and read that many bytes in a first pass. Check
for an error code in the first 4 bytes. Read the rest in a 2nd pass.

   Stefan

v3:
  - 2/2: Pass size of return response for error as parameter

v2:
  - 2/2: Added special handling of CMD_GET_STATEBLOB



Stefan Berger (2):
  tpm: Use new ptm_cap_n structure for PTM_GET_CAPABILITY
  tpm_emulator: Read control channel response in 2 passes

 backends/tpm/tpm_emulator.c | 77 +++++++++++++++++++++++++++----------
 backends/tpm/tpm_ioctl.h    | 13 ++++++-
 backends/tpm/trace-events   |  2 +-
 3 files changed, 69 insertions(+), 23 deletions(-)