linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Eric Biggers <ebiggers@kernel.org>
Cc: keyrings@vger.kernel.org, David Howells <dhowells@redhat.com>,
	Denis Kenzior <denkenz@gmail.com>,
	Marcel Holtmann <marcel@holtmann.org>,
	James Morris <james.morris@microsoft.com>,
	linux-crypto@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 1/3] KEYS: asym_tpm: fix buffer overreads in extract_key_parameters()
Date: Sat, 15 Jan 2022 23:40:48 +0200	[thread overview]
Message-ID: <YeM/YIUTEwL4jNf3@iki.fi> (raw)
In-Reply-To: <20220113235440.90439-2-ebiggers@kernel.org>

On Thu, Jan 13, 2022 at 03:54:38PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> extract_key_parameters() can read past the end of the input buffer due
> to buggy and missing bounds checks.  Fix it as follows:
> 
> - Before reading each key length field, verify that there are at least 4
>   bytes remaining.

Maybe start with a "Key length is described as an unsigned 32-bit integer
in the TPM header". Just for clarity.

> 
> - Avoid integer overflows when validating size fields; 'sz + 12' and
>   '4 + sz' overflowed if 'sz' is near U32_MAX.

So we have a struct tpm_header in include/linux/tpm.h. It would be way
more informative to use sizeof(struct tpm_header) than number 12, even
if the patch does not otherwise use the struct. It tells what it is, 12
does not.

> - Before saving the pointer to the public key, check that it doesn't run
>   past the end of the buffer.
> 
> Fixes: f8c54e1ac4b8 ("KEYS: asym_tpm: extract key size & public key [ver #2]")
> Cc: <stable@vger.kernel.org> # v4.20+
> Signed-off-by: Eric Biggers <ebiggers@google.com>

BR, Jarkko

  reply	other threads:[~2022-01-15 21:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13 23:54 [PATCH 0/3] KEYS: fixes for asym_tpm keys Eric Biggers
2022-01-13 23:54 ` [PATCH 1/3] KEYS: asym_tpm: fix buffer overreads in extract_key_parameters() Eric Biggers
2022-01-15 21:40   ` Jarkko Sakkinen [this message]
2022-01-19  0:59     ` Eric Biggers
2022-01-26 14:21       ` Jarkko Sakkinen
2022-01-26 14:22         ` Jarkko Sakkinen
2022-01-28 19:00           ` Eric Biggers
2022-02-08  9:30             ` Jarkko Sakkinen
2022-01-13 23:54 ` [PATCH 2/3] KEYS: asym_tpm: fix incorrect comment Eric Biggers
2022-01-15 19:12   ` Jarkko Sakkinen
2022-01-13 23:54 ` [PATCH 3/3] KEYS: asym_tpm: rename derive_pub_key() Eric Biggers
2022-01-15 19:09   ` Jarkko Sakkinen
2022-01-14 14:54 ` [PATCH 0/3] KEYS: fixes for asym_tpm keys Denis Kenzior
2022-01-15 21:42 ` 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=YeM/YIUTEwL4jNf3@iki.fi \
    --to=jarkko@kernel.org \
    --cc=denkenz@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=ebiggers@kernel.org \
    --cc=james.morris@microsoft.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=stable@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).