mbox series

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

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

Message

Stefan Berger Oct. 16, 2024, 1:34 p.m. UTC
In case swtpm was to return a control channel message with an error code it
would only return 4 bytes. However, some of the commands expect a response
with more bytes and QEMU would get stuck in qemu_chr_fe_read_all() waiting
for bytes following the error code. Therefore, read the response in 2
passes stopping if an error code is received in the first 4 bytes to avoid
getting stuck. Implement an exception for CMD_GET_STATEBLOB that has always
been sending the header in case of error.

   Stefan

v2:
  - 


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 | 45 ++++++++++++++++++++++++++++++-------
 backends/tpm/tpm_ioctl.h    | 13 ++++++++++-
 backends/tpm/trace-events   |  2 +-
 3 files changed, 50 insertions(+), 10 deletions(-)

Comments

Stefan Berger Oct. 16, 2024, 2:31 p.m. UTC | #1
On 10/16/24 9:34 AM, Stefan Berger wrote:
> In case swtpm was to return a control channel message with an error code it
> would only return 4 bytes. However, some of the commands expect a response
> with more bytes and QEMU would get stuck in qemu_chr_fe_read_all() waiting
> for bytes following the error code. Therefore, read the response in 2
> passes stopping if an error code is received in the first 4 bytes to avoid
> getting stuck. Implement an exception for CMD_GET_STATEBLOB that has always
> been sending the header in case of error.
> 
>     Stefan
> 
> v2:
>    -

Please disregard v2. v3 coming shortly.
> 
> 
> 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 | 45 ++++++++++++++++++++++++++++++-------
>   backends/tpm/tpm_ioctl.h    | 13 ++++++++++-
>   backends/tpm/trace-events   |  2 +-
>   3 files changed, 50 insertions(+), 10 deletions(-)
>