Skip to contentSkip to conversation

tpm: Return the actual size when receiving an unsupported command

PATCH Superseded Ricardo Schwarzmeier 2 participants 2 messages Jun 22, 2018 – Jun 25, 2018

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 tpm: Return the actual size when receiving an unsupported command

The userpace expects to read the number of bytes stated in the header. Returning the size of the buffer instead would be unexpected.

Fixes 095531f891e6 ("tpm: return a TPM_RC_COMMAND_CODE response if command is not implemented")
---
 drivers/char/tpm/tpm-interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm-interface.c +1 -1
index e32f6e85dc6d..7f2e2d54894d 100644
@@ -423,7 +423,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
 		header->tag = cpu_to_be16(TPM2_ST_NO_SESSIONS);
 		header->return_code = cpu_to_be32(TPM2_RC_COMMAND_CODE |
 						  TSS2_RESMGR_TPM_RC_LAYER);
-		return bufsiz;
+		return sizeof(*header);
 	}
 
 	if (bufsiz > TPM_BUFSIZE)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 7 lines · Ricardo Schwarzmeier

The userpace expects to read the number of bytes stated in the header. Returning the size of the buffer instead would be unexpected.

Fixes 095531f891e6 ("tpm: return a TPM_RC_COMMAND_CODE response if command is

not implemented")

---

Do you have a changelog?

/Jarkko