From: "Huang, Kai" <kai.huang@intel.com>
To: "jarkko@kernel.org" <jarkko@kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"bp@alien8.de" <bp@alien8.de>,
"thorsten.blum@linux.dev" <thorsten.blum@linux.dev>,
"hpa@zytor.com" <hpa@zytor.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"x86@kernel.org" <x86@kernel.org>,
"tglx@kernel.org" <tglx@kernel.org>
Cc: "linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] x86/sgx: Use SGX_LAUNCH_TOKEN_SIZE in __sgx_virt_einit()
Date: Tue, 14 Jul 2026 00:21:59 +0000 [thread overview]
Message-ID: <917f1afc4e625b63a3387672b567cacfa1ec5503.camel@intel.com> (raw)
In-Reply-To: <20260711100053.739588-8-thorsten.blum@linux.dev>
On Sat, 2026-07-11 at 12:00 +0200, Thorsten Blum wrote:
> Both sgx_ioc_enclave_init() and __sgx_virt_einit() use the same 304-byte
> launch token. Use SGX_LAUNCH_TOKEN_SIZE in __sgx_virt_einit() instead of
> maintaining a second local definition,
>
[...]
> ensuring the token initialization
> and validation paths use the same size.
Nit:
This part isn't that accurate to me. sgx_ioc_enclave_init() is for running host
SGX enclave and __sgx_virt_einit() is for executing the EINIT trapped from KVM
guests. I.e., IMHO they are not "token initialization" and "token validation"
which sounds like two sides of the same coin. And the access_ok() doesn't
validate the content of the EINITTOKEN anyway.
IHMO we can just remove this part.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> arch/x86/kernel/cpu/sgx/virt.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/sgx/virt.c b/arch/x86/kernel/cpu/sgx/virt.c
> index db6806c40483..fa9173a9384a 100644
> --- a/arch/x86/kernel/cpu/sgx/virt.c
> +++ b/arch/x86/kernel/cpu/sgx/virt.c
> @@ -394,9 +394,8 @@ static int __sgx_virt_einit(void __user *sigstruct, void __user *token,
> * All other checks deferred to ENCLS itself. Also see comment
> * for @secs in sgx_virt_ecreate().
> */
> -#define SGX_EINITTOKEN_SIZE 304
> if (WARN_ON_ONCE(!access_ok(sigstruct, sizeof(struct sgx_sigstruct)) ||
> - !access_ok(token, SGX_EINITTOKEN_SIZE) ||
> + !access_ok(token, SGX_LAUNCH_TOKEN_SIZE) ||
> !access_ok(secs, PAGE_SIZE)))
> return -EINVAL;
>
Not sure whether the name SGX_EINITTOKEN_SIZE slightly matches better, but I am
fine with both.
With the nit mentioned in changelog fixed:
Reviewed-by: Kai Huang <kai.huang@intel.com>
prev parent reply other threads:[~2026-07-14 0:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 10:00 [PATCH 0/3] x86/sgx: Remove unused definitions and reuse launch token size Thorsten Blum
2026-07-11 10:00 ` [PATCH 1/3] x86/sgx: Remove unused TCS definitions Thorsten Blum
2026-07-11 18:22 ` Jarkko Sakkinen
2026-07-14 0:23 ` Huang, Kai
2026-07-11 10:00 ` [PATCH 2/3] x86/sgx: Remove unused size and count definitions Thorsten Blum
2026-07-11 18:22 ` Jarkko Sakkinen
2026-07-14 0:24 ` Huang, Kai
2026-07-11 10:00 ` [PATCH 3/3] x86/sgx: Use SGX_LAUNCH_TOKEN_SIZE in __sgx_virt_einit() Thorsten Blum
2026-07-11 18:23 ` Jarkko Sakkinen
2026-07-14 0:21 ` Huang, Kai [this message]
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=917f1afc4e625b63a3387672b567cacfa1ec5503.camel@intel.com \
--to=kai.huang@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jarkko@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=thorsten.blum@linux.dev \
--cc=x86@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