Re: [PATCH v2] arch/x86: Fix size overflows in sgx_encl_create()

2025-03-04 Thread Jarkko Sakkinen
On Tue, Mar 04, 2025 at 04:30:21PM -0800, Dave Hansen wrote: > On 3/4/25 16:19, Jarkko Sakkinen wrote: > > On Tue, Mar 04, 2025 at 04:18:03PM -0800, Dave Hansen wrote: > >> On 3/4/25 16:06, Jarkko Sakkinen wrote: > >>> + /* > >>> + * This is a micro-architectural requirement. ECREATE would detect

Re: [PATCH v2] arch/x86: Fix size overflows in sgx_encl_create()

2025-03-04 Thread Dave Hansen
On 3/4/25 16:19, Jarkko Sakkinen wrote: > On Tue, Mar 04, 2025 at 04:18:03PM -0800, Dave Hansen wrote: >> On 3/4/25 16:06, Jarkko Sakkinen wrote: >>> + /* >>> +* This is a micro-architectural requirement. ECREATE would detect this >>> +* too without mentionable overhead but this check gua

Re: [PATCH v2] arch/x86: Fix size overflows in sgx_encl_create()

2025-03-04 Thread Jarkko Sakkinen
On Tue, Mar 04, 2025 at 04:18:03PM -0800, Dave Hansen wrote: > On 3/4/25 16:06, Jarkko Sakkinen wrote: > > + /* > > +* This is a micro-architectural requirement. ECREATE would detect this > > +* too without mentionable overhead but this check guarantees also that > > +* the space calc

Re: [PATCH v2] arch/x86: Fix size overflows in sgx_encl_create()

2025-03-04 Thread Dave Hansen
On 3/4/25 16:06, Jarkko Sakkinen wrote: > + /* > + * This is a micro-architectural requirement. ECREATE would detect this > + * too without mentionable overhead but this check guarantees also that > + * the space calculations for EPC and shmem allocations never overflow. > +

Re: [PATCH v2] arch/x86: Fix size overflows in sgx_encl_create()

2025-03-04 Thread Jarkko Sakkinen
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 > sp

[PATCH v2] arch/x86: Fix size overflows in sgx_encl_create()

2025-03-04 Thread Jarkko Sakkinen
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 pr