Re: [PATCH v2] arch/x86: Fix size overflows in sgx_encl_create()
From: Jarkko Sakkinen
Date: Tue Mar 04 2025 - 19:09:22 EST
On Wed, Mar 05, 2025 at 02:06:02AM +0200, Jarkko Sakkinen wrote:
> The total size calculated for EPC can overflow u64 given the added up page
> for SECS. Further, the total size calculated for shmem can overflow even
> when the EPC size stays within limits of u64, given that it adds the extra
> space for 128 byte PCMD structures (one for each page).
>
> Address this by pre-evaluating the micro-architectural requirement of
> SGX: the address space size must be power of two. This is eventually
> checked up by ECREATE but the pre-check has the additional benefit of
> making sure that there is some space for additional data.
>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Closes: https://lore.kernel.org/linux-sgx/c87e01a0-e7dd-4749-a348-0980d3444f04@stanley.mountain/
> Signed-off-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx # v5.11+
Fixes: 888d24911787 ("x86/sgx: Add SGX_IOC_ENCLAVE_CREATE")
BR, Jarkko