On Sat, Jul 11, 2026 at 12:00:57PM +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.
> 
> Signed-off-by: Thorsten Blum <[email protected]>
> ---
>  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;
>  

true:

❯ git grep LAUNCH_TOKEN_SIZE
arch/x86/include/asm/sgx.h:#define SGX_LAUNCH_TOKEN_SIZE 304
arch/x86/kernel/cpu/sgx/ioctl.c:        memset(token, 0, SGX_LAUNCH_TOKEN_SIZE);

Reviewed-by: Jarkko Sakkinen <[email protected]>

BR, Jarkko

Reply via email to