- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear All,
I am trying to pass a recursive structure to Untrust memory with Ocall. However, when I try to access the next member of the structure, I get a Segmentation Fault.
What should I do to correctly pass the structure of the recursive structure? I would like to know if anyone can help me.
In the sample below, the process transits to the Enclave with ecall_enter(), creates an instance of the recursive structure there, and passes it to the Untrust area with ocall_struct_test_func4.
recursive structure in edl (OcallClassTest4)
struct OcallStructTest4 {
[size=100] char* ident;
struct OcallStructTest4* next;
};
ecall_enter
void ecall_enter() {
OcallStructTest4* ocall_struct_test4 = new OcallStructTest4();
ocall_struct_test4->ident = "hello struct!";
ocall_struct_test4->next = new OcallStructTest4();
OcallStructTest4* next = ocall_struct_test4->next;
next->ident = "hello next!!!";
ocall_struct_test_func4(ocall_struct_test4);
}
ocall_struct_test_func4
void ocall_struct_test_func4(OcallStructTest4* ocall_struct_test4) {
std::cout << "ocall struct test func4 start.\n";
std::cout << ocall_struct_test4->ident << std::endl;
OcallStructTest4* next = ocall_struct_test4->next;
std::cout << "next ident" << next->ident << std::endl;
}
ocall definition in edl
void ocall_struct_test_func4([in] struct OcallStructTest4* ocall_struct_test);
Execution result
ocall struct test func4 start.
hello struct!
Segmentation fault
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
No trouble at all.
In the SGX Developer Guide, there is a section on Structure Deep Copy: https://download.01.org/intel-sgx/latest/linux-latest/docs/Intel_SGX_Developer_Reference_Linux_2.17_Open_Source.pdf#page=56
There is a sample there that you can follow that might help
Sincerely,
Sahira
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You might need to increase heap size. Seg fault usually means there is not enough memory allocated to the enclave
Can you please send over your enclave config file so I can take a look.
Sincerely,
Sahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply!
The config file for Enclave is below (the application I am currently making is based on SampleEnclave from SampleCode, and the config file has not been changed).
Enclave.config.xml
<EnclaveConfiguration>
<ProdID>0</ProdID>
<ISVSVN>0</ISVSVN>
<StackMaxSize>0x40000</StackMaxSize>
<HeapMaxSize>0x100000</HeapMaxSize>
<TCSNum>10</TCSNum>
<TCSPolicy>1</TCSPolicy>
<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
<MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
Also, I have a question, is it not possible to access the next referenced data just by passing the pointer of the self-reference structure from the Enclave to the Untrust area (or vice versa)?
Currently I am not able to do that, so I am using a technique such as passing a uint8_t* converted to a byte string. Is there another smarter way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have escalated this issue further. I will let you know when I have more information.
Sincerely,
Sahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply!
I am sorry for the trouble. I look forward to hearing back from you.
Sincerely
wwfbear789
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
No trouble at all.
In the SGX Developer Guide, there is a section on Structure Deep Copy: https://download.01.org/intel-sgx/latest/linux-latest/docs/Intel_SGX_Developer_Reference_Linux_2.17_Open_Source.pdf#page=56
There is a sample there that you can follow that might help
Sincerely,
Sahira

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page