From: "Huang, Kai" <kai.huang@intel.com>
To: "linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>,
"jarkko@kernel.org" <jarkko@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Van Bulck, Jo" <jo.vanbulck@cs.kuleuven.be>
Cc: "dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Subject: Re: [PATCH 1/8] selftests/sgx: Fix uninitialized pointer dereference in error path
Date: Fri, 18 Aug 2023 11:30:21 +0000 [thread overview]
Message-ID: <f900b6ffe0e7bc7237be699eefd4db7d971060ab.camel@intel.com> (raw)
In-Reply-To: <20230808193145.8860-2-jo.vanbulck@cs.kuleuven.be>
On Tue, 2023-08-08 at 12:31 -0700, Jo Van Bulck wrote:
> Ensure ctx is zero-initialized, such that the encl_measure function will
> not call EVP_MD_CTX_destroy with an uninitialized ctx pointer in case of an
> early error during key generation.
>
> Fixes: 2adcba79e69d ("selftests/x86: Add a selftest for SGX")
> Signed-off-by: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>
> ---
> tools/testing/selftests/sgx/sigstruct.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/sgx/sigstruct.c b/tools/testing/selftests/sgx/sigstruct.c
> index a07896a46364..d73b29becf5b 100644
> --- a/tools/testing/selftests/sgx/sigstruct.c
> +++ b/tools/testing/selftests/sgx/sigstruct.c
> @@ -318,9 +318,9 @@ bool encl_measure(struct encl *encl)
> struct sgx_sigstruct *sigstruct = &encl->sigstruct;
> struct sgx_sigstruct_payload payload;
> uint8_t digest[SHA256_DIGEST_LENGTH];
> + EVP_MD_CTX *ctx = NULL;
> unsigned int siglen;
> RSA *key = NULL;
> - EVP_MD_CTX *ctx;
> int i;
>
> memset(sigstruct, 0, sizeof(*sigstruct));
> @@ -384,7 +384,8 @@ bool encl_measure(struct encl *encl)
> return true;
>
> err:
> - EVP_MD_CTX_destroy(ctx);
> + if (ctx)
> + EVP_MD_CTX_destroy(ctx);
> RSA_free(key);
> return false;
> }
Acked-by: Kai Huang <kai.huang@intel.com>
next prev parent reply other threads:[~2023-08-18 11:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 19:31 [PATCH v2 0/8] selftests/sgx: Fix compilation errors Jo Van Bulck
2023-08-08 19:31 ` [PATCH 1/8] selftests/sgx: Fix uninitialized pointer dereference in error path Jo Van Bulck
2023-08-10 19:15 ` Jarkko Sakkinen
2023-08-18 11:30 ` Huang, Kai [this message]
2023-08-08 19:31 ` [PATCH 2/8] selftests/sgx: Produce static-pie executable for test enclave Jo Van Bulck
2023-08-10 19:22 ` Jarkko Sakkinen
2023-08-08 19:31 ` [PATCH 3/8] selftests/sgx: Handle relocations in " Jo Van Bulck
2023-08-10 20:32 ` Jarkko Sakkinen
2023-08-19 0:32 ` Jo Van Bulck
2023-08-22 10:07 ` Jarkko Sakkinen
2023-08-08 19:31 ` [PATCH 4/8] selftests/sgx: Fix linker script asserts Jo Van Bulck
2023-08-08 19:31 ` [PATCH 5/8] selftests/sgx: Include memory clobber for inline asm in test enclave Jo Van Bulck
2023-08-18 11:31 ` Huang, Kai
2023-08-08 19:31 ` [PATCH 6/8] selftests/sgx: Ensure expected enclave data buffer size and placement Jo Van Bulck
2023-08-18 13:10 ` Huang, Kai
2023-08-19 1:09 ` Jo Van Bulck
2023-08-08 19:31 ` [PATCH 7/8] selftests/sgx: Separate linker options Jo Van Bulck
2023-08-08 19:31 ` [PATCH 8/8] selftests/sgx: Specify freestanding environment for enclave compilation Jo Van Bulck
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=f900b6ffe0e7bc7237be699eefd4db7d971060ab.camel@intel.com \
--to=kai.huang@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=jarkko@kernel.org \
--cc=jo.vanbulck@cs.kuleuven.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@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