Intel® Software Guard Extensions (Intel® SGX)
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.

Multiple file i/o inside enclave

das__batsayan
New Contributor I
468 Views

I have a code block similar to this running on SDK2.13

main()

{

while(1)
{

do_work_inside_sgx()

}

}

do_work_inside_sgx()

{

SGX_FILE *fp1;

open( fp1)
write_something(fp1)
close(fp1)

open(fp1)
read_from(fp1);
use_the _date_read_from_fp1()
close(fp1)

}

The while loop in some arbitrary iteration sometimes says that "error opening file". Do you see anything wrong in the above code?

0 Kudos
1 Solution
das__batsayan
New Contributor I
377 Views

We debugged the code as suggested by you and found one missing OPENSSL_free() API call in the application code which causes the issue. 

This issue can be closed. 

--Batsayan

View solution in original post

6 Replies
JesusG_Intel
Moderator
452 Views

Hello das_batsayan,


  1. Did you use the Intel Protected File System Library as described in the Intel SGX Developer Reference Guide for Windows or Linux?
  2. Which OS are you on?
  3. Did you capture any returned error codes?
  4. Send more details on your code so we can more clearly see what it is doing.


Sincerely,

Jesus G.

Intel Customer Support


das__batsayan
New Contributor I
424 Views

1. Yes
2. Ubuntu 18.04
3. Yes, error code is 0x3001. It is SGX_ERROR_MAC_MISMATCH, found this in sgx_error.h
4. The basic code tries to read from a file in a infinite loop. First few iterations of the loop is OK, but after some time ( say after 8000th iteration of the loop) got error code 0x3001

JesusG_Intel
Moderator
415 Views

Hello das_batsayan,


Your pseudocode shows that you try to open and close the file twice within the loop. Do you know which fopen is causing the error? Have you tried doing only a single open, read, close within the loop without the write?


To aid in your debugging, you can build the SGX SDK with debug symbols and you can step into the SDK code to see exactly where that error gets generated.


It would help if you provided your actual code. If you do not want to provide the code via this public forum, let me know and I can send you a private email where you can send me your code and we can continue this troubleshooting.


Sincerely,

Jesus G.

Intel Customer Support



JesusG_Intel
Moderator
379 Views

Hello das_batsayan,


Do you still need help with this issue?


Sincerely,

Jesus G.

Intel Customer Support


das__batsayan
New Contributor I
378 Views

We debugged the code as suggested by you and found one missing OPENSSL_free() API call in the application code which causes the issue. 

This issue can be closed. 

--Batsayan

JesusG_Intel
Moderator
370 Views

This thread has been marked as answered and Intel will no longer monitor this thread. If you want a response from Intel in a follow-up question, please open a new thread.


Reply