Skip to content

Commit 7dc357d

Browse files
GeHao01994jarkkojs
authored andcommitted
tpm: Use auth only after NULL check in tpm_buf_check_hmac_response()
Dereference auth after NULL check in tpm_buf_check_hmac_response(). Otherwise, unless tpm2_sessions_init() was called, a call can cause NULL dereference, when TCG_TPM2_HMAC is enabled. [jarkko: adjusted the commit message.] Cc: [email protected] # v6.10+ Fixes: 7ca110f ("tpm: Address !chip->auth in tpm_buf_append_hmac_session*()") Signed-off-by: Hao Ge <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent d679783 commit 7dc357d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/char/tpm/tpm2-sessions.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,15 +746,16 @@ int tpm_buf_check_hmac_response(struct tpm_chip *chip, struct tpm_buf *buf,
746746
struct tpm2_auth *auth = chip->auth;
747747
off_t offset_s, offset_p;
748748
u8 rphash[SHA256_DIGEST_SIZE];
749-
u32 attrs;
749+
u32 attrs, cc;
750750
struct sha256_state sctx;
751751
u16 tag = be16_to_cpu(head->tag);
752-
u32 cc = be32_to_cpu(auth->ordinal);
753752
int parm_len, len, i, handles;
754753

755754
if (!auth)
756755
return rc;
757756

757+
cc = be32_to_cpu(auth->ordinal);
758+
758759
if (auth->session >= TPM_HEADER_SIZE) {
759760
WARN(1, "tpm session not filled correctly\n");
760761
goto out;

0 commit comments

Comments
 (0)