From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Jason Andryuk <jandryuk@gmail.com>
Cc: xen-devel@lists.xenproject.org,
Daniel De Graaf <dgdegra@tycho.nsa.gov>,
Quan Xu <quan.xu0@gmail.com>
Subject: Re: [PATCH v2 10/13] vtpmmgr: Remove bogus cast from TPM2_GetRandom
Date: Thu, 6 May 2021 23:41:13 +0200 [thread overview]
Message-ID: <20210506214113.bhkhiif4utufxxwp@begin> (raw)
In-Reply-To: <20210506135923.161427-11-jandryuk@gmail.com>
Jason Andryuk, le jeu. 06 mai 2021 09:59:20 -0400, a ecrit:
> The UINT32 <-> UINT16 casting in TPM2_GetRandom is incorrect. Use a
> local UINT16 as needed for the TPM hardware command and assign the
> result.
>
> Suggested-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
> stubdom/vtpmmgr/tpm2.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/stubdom/vtpmmgr/tpm2.c b/stubdom/vtpmmgr/tpm2.c
> index 655e6d164c..ebd06eac74 100644
> --- a/stubdom/vtpmmgr/tpm2.c
> +++ b/stubdom/vtpmmgr/tpm2.c
> @@ -427,15 +427,22 @@ abort_egress:
>
> TPM_RC TPM2_GetRandom(UINT32 * bytesRequested, BYTE * randomBytes)
> {
> + UINT16 bytesReq;
> TPM_BEGIN(TPM_ST_NO_SESSIONS, TPM_CC_GetRandom);
>
> - ptr = pack_UINT16(ptr, (UINT16)*bytesRequested);
> + if (*bytesRequested > UINT16_MAX)
> + bytesReq = UINT16_MAX;
> + else
> + bytesReq = *bytesRequested;
> +
> + ptr = pack_UINT16(ptr, bytesReq);
>
> TPM_TRANSMIT();
> TPM_UNPACK_VERIFY();
>
> - ptr = unpack_UINT16(ptr, (UINT16 *)bytesRequested);
> - ptr = unpack_TPM_BUFFER(ptr, randomBytes, *bytesRequested);
> + ptr = unpack_UINT16(ptr, &bytesReq);
> + *bytesRequested = bytesReq;
> + ptr = unpack_TPM_BUFFER(ptr, randomBytes, bytesReq);
>
> abort_egress:
> return status;
> --
> 2.30.2
>
--
Samuel
<N> (* If you have a precise idea of the intended use of the following code, please
<N> write to Eduardo.Gimenez@inria.fr and ask for the prize :-)
<N> -- Eduardo (11/8/97) *)
-+- N sur #ens-mim - et c'était un des développeurs -+-
next prev parent reply other threads:[~2021-05-08 11:49 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-06 13:59 [PATCH v2 00/13] vtpmmgr: Some fixes - still incomplete Jason Andryuk
2021-05-06 13:59 ` [PATCH v2 01/13] docs: Warn about incomplete vtpmmgr TPM 2.0 support Jason Andryuk
2021-05-06 13:59 ` [PATCH v2 02/13] vtpmmgr: Print error code to aid debugging Jason Andryuk
2021-05-06 13:59 ` [PATCH v2 03/13] stubom: newlib: Enable C99 formats for %z Jason Andryuk
2021-05-06 13:59 ` [PATCH v2 04/13] vtpmmgr: Allow specifying srk_handle for TPM2 Jason Andryuk
2021-05-06 21:35 ` Samuel Thibault
2021-05-10 11:56 ` Daniel P. Smith
2021-05-06 13:59 ` [PATCH v2 05/13] vtpmmgr: Move vtpmmgr_shutdown Jason Andryuk
2021-05-07 15:48 ` Daniel P. Smith
2021-05-06 13:59 ` [PATCH v2 06/13] vtpmmgr: Flush transient keys on shutdown Jason Andryuk
2021-05-10 12:12 ` Daniel P. Smith
2021-05-06 13:59 ` [PATCH v2 07/13] vtpmmgr: Flush all transient keys Jason Andryuk
2021-05-10 12:19 ` Daniel P. Smith
2021-05-06 13:59 ` [PATCH v2 08/13] vtpmmgr: Shutdown more gracefully Jason Andryuk
2021-05-06 14:04 ` Jason Andryuk
2021-05-10 12:42 ` Daniel P. Smith
2021-05-06 13:59 ` [PATCH v2 09/13] vtpmmgr: Support GetRandom passthrough on TPM 2.0 Jason Andryuk
2021-05-06 21:40 ` Samuel Thibault
2021-05-10 12:51 ` Daniel P. Smith
2021-05-06 13:59 ` [PATCH v2 10/13] vtpmmgr: Remove bogus cast from TPM2_GetRandom Jason Andryuk
2021-05-06 21:41 ` Samuel Thibault [this message]
2021-05-10 13:03 ` Daniel P. Smith
2021-05-06 13:59 ` [PATCH v2 11/13] vtpmmgr: Fix owner_auth & srk_auth parsing Jason Andryuk
2021-05-06 21:41 ` Samuel Thibault
2021-05-10 13:18 ` Daniel P. Smith
2021-05-06 13:59 ` [PATCH v2 12/13] vtpmmgr: Check req_len before unpacking command Jason Andryuk
2021-05-06 21:42 ` Samuel Thibault
2021-05-10 13:32 ` Daniel P. Smith
2021-05-06 13:59 ` [PATCH v2 13/13] vtpm: Correct timeout units and command duration Jason Andryuk
2021-05-06 21:52 ` Samuel Thibault
2021-05-10 13:40 ` Daniel P. Smith
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=20210506214113.bhkhiif4utufxxwp@begin \
--to=samuel.thibault@ens-lyon.org \
--cc=dgdegra@tycho.nsa.gov \
--cc=jandryuk@gmail.com \
--cc=quan.xu0@gmail.com \
--cc=xen-devel@lists.xenproject.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).