You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that libsgx's malloc implementation does not work correctly with many small allocations. This can be verified with the following program, which incorrectly segfaults:
Increasing the size that is malloced to 1024 bytes prevents the segfault (although after 1359 allocations, it gives a different error, which I suspect is due to a hardcoded maximum memory limit).
I believe this bug is caused by the way libsgx handles the EAUG/EACCEPT process: when the enclave needs more memory, it will allocate a SECINFO structure (64 bytes) that is used to request another page to be mapped into its memory. However, if there are less than 64 bytes of memory available due to previous small allocations (or just bad luck), this allocation will fail and require allocation of another page, causing a recursion that overflows the stack.
This should be fixable by allocating the SECINFO on initialization and immediately after every EAUG/EACCEPT and then storing it for the next time it is needed, rather than allocating it on-demand just before the EAUG/EACCEPT.
The text was updated successfully, but these errors were encountered:
It appears that libsgx's
malloc
implementation does not work correctly with many small allocations. This can be verified with the following program, which incorrectly segfaults:Increasing the size that is
malloc
ed to 1024 bytes prevents the segfault (although after 1359 allocations, it gives a different error, which I suspect is due to a hardcoded maximum memory limit).I believe this bug is caused by the way libsgx handles the
EAUG
/EACCEPT
process: when the enclave needs more memory, it will allocate aSECINFO
structure (64 bytes) that is used to request another page to be mapped into its memory. However, if there are less than 64 bytes of memory available due to previous small allocations (or just bad luck), this allocation will fail and require allocation of another page, causing a recursion that overflows the stack.This should be fixable by allocating the
SECINFO
on initialization and immediately after everyEAUG
/EACCEPT
and then storing it for the next time it is needed, rather than allocating it on-demand just before theEAUG
/EACCEPT
.The text was updated successfully, but these errors were encountered: