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

Stefan Berger posted 2 patches 6 days, 7 hours ago
There is a newer version of this series
backends/tpm/tpm_emulator.c | 45 ++++++++++++++++++++++++++++++-------
backends/tpm/tpm_ioctl.h    | 13 ++++++++++-
backends/tpm/trace-events   |  2 +-
3 files changed, 50 insertions(+), 10 deletions(-)
[PATCH v2 0/2] tpm: Resolve potential blocking-forever issue
Posted by Stefan Berger 6 days, 7 hours ago
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(-)

-- 
2.47.0
Re: [PATCH v2 0/2] tpm: Resolve potential blocking-forever issue
Posted by Stefan Berger 6 days, 6 hours ago

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(-)
>