Linux Integrity Measurement development
 help / color / mirror / Atom feed
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
To: Sanket Sharma <sanketsharmacsec@gmail.com>
Cc: jarkko@kernel.org, gregkh@linuxfoundation.org,
	"James.Bottomley@hansenpartnership.com"
	<James.Bottomley@HansenPartnership.com>,
	zohar@linux.ibm.com, dhowells@redhat.com,
	linux-integrity@vger.kernel.org, keyrings@vger.kernel.org,
	linux-kernel@vger.kernel.org, security@kernel.org, w@1wt.eu
Subject: Re: [PATCH v2 2/2] keys: trusted: tpm1: reject unauthenticated response tag in TSS_checkhmac1/2
Date: Wed, 26 Aug 2026 22:17:51 +0530	[thread overview]
Message-ID: <A16F8908-4440-43FE-814C-2129C2B30478@linux.ibm.com> (raw)
In-Reply-To: <20260826080405.255083-2-sanketsharmacsec@gmail.com>



> On 26 Aug 2026, at 1:34 PM, Sanket Sharma <sanketsharmacsec@gmail.com> wrote:
> 
> TSS_checkhmac1() and TSS_checkhmac2() silently return success when the
> response tag is TPM_TAG_RSP_COMMAND (0x00c4), bypassing HMAC
> verification entirely. A forged TPM response with this unauthenticated
> tag allows an attacker to skip integrity checks on TPM responses.
> 
> Reject TPM_TAG_RSP_COMMAND with -EINVAL in both functions, requiring
> all responses to carry a proper authenticated tag.
> 
> Signed-off-by: Sanket Sharma <sanketsharmacsec@gmail.com>
> ---
> security/keys/trusted-keys/trusted_tpm1.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/security/keys/trusted-keys/trusted_tpm1.c b/security/keys/trusted-keys/trusted_tpm1.c
> index d47cb7108..c89fc6cfe 100644
> --- a/security/keys/trusted-keys/trusted_tpm1.c
> +++ b/security/keys/trusted-keys/trusted_tpm1.c
> @@ -202,7 +202,7 @@ static int TSS_checkhmac1(unsigned char *buffer,
> ordinal = command;
> result = LOAD32N(buffer, TPM_RETURN_OFFSET);
> if (tag == TPM_TAG_RSP_COMMAND)
> - return 0;
> + return -EINVAL;

Hi Sanket Sharma,

Instead of changing the return value to -EINVAL inside the TPM_TAG_RSP_COMMAND check,
we can simplify the control flow by removing that block entirely.Since TPM_TAG_RSP_COMMAND is
inherently not equal to TPM_TAG_RSP_AUTH1_COMMAND, the subsequent mismatch check will naturally
catch it and return -EINVAL. 

Thanks,
Sudhakar

> if (tag != TPM_TAG_RSP_AUTH1_COMMAND)
> return -EINVAL;
> authdata = buffer + bufsize - SHA1_DIGEST_SIZE;
> @@ -270,7 +270,7 @@ static int TSS_checkhmac2(unsigned char *buffer,
> result = LOAD32N(buffer, TPM_RETURN_OFFSET);
> 
> if (tag == TPM_TAG_RSP_COMMAND)
> - return 0;
> + return -EINVAL;
> if (tag != TPM_TAG_RSP_AUTH2_COMMAND)
> return -EINVAL;
> authdata1 = buffer + bufsize - (SHA1_DIGEST_SIZE + 1
> -- 
> 2.53.0
> 
> 


  reply	other threads:[~2026-08-26 16:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 18:29 [PATCH 1/2] keys: trusted: tpm1: add bounds check in tpm_seal() before memcpy sn0x-sharma
2026-08-25 18:29 ` [PATCH 2/2] keys: trusted: tpm1: reject unauthenticated response tag in TSS_checkhmac1/2 sn0x-sharma
2026-08-28  1:44   ` Jarkko Sakkinen
2026-08-26  6:18 ` [PATCH 1/2] keys: trusted: tpm1: add bounds check in tpm_seal() before memcpy Greg KH
2026-08-28  1:46   ` Jarkko Sakkinen
     [not found]     ` <CAEb43b2C_eyR8ncUbJ+3MsT3ap-tB3_O0Mbaqgy1ncXwZAd_Yw@mail.gmail.com>
2026-08-28  7:36       ` Greg KH
     [not found]         ` <CAEb43b0bc7rNvrpLmjF-9HPEfUcOdTKsUC68vzh+JfDf7E+OcA@mail.gmail.com>
2026-09-01 12:36           ` Jarkko Sakkinen
2026-08-26  8:04 ` [PATCH v2 " Sanket Sharma
2026-08-26  8:04   ` [PATCH v2 2/2] keys: trusted: tpm1: reject unauthenticated response tag in TSS_checkhmac1/2 Sanket Sharma
2026-08-26 16:47     ` Sudhakar Kuppusamy [this message]
2026-08-26 16:44   ` [PATCH v2 1/2] keys: trusted: tpm1: add bounds check in tpm_seal() before memcpy Sudhakar Kuppusamy
2026-08-26 17:06   ` [PATCH v3 " Sanket Sharma
2026-08-26 17:07     ` [PATCH v3 2/2] keys: trusted: tpm1: reject unauthenticated response tag in TSS_checkhmac1/2 Sanket Sharma
2026-08-28  1:48       ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A16F8908-4440-43FE-814C-2129C2B30478@linux.ibm.com \
    --to=sudhakar@linux.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=dhowells@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jarkko@kernel.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sanketsharmacsec@gmail.com \
    --cc=security@kernel.org \
    --cc=w@1wt.eu \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox