- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to pass an instance of a class with multiple containers, defined in Untrust memory, to Enclave.
As shown below, after passing a class (ClassTest) defined in the Untrust area to Enclave, vector and string (char*) values could be read, but unorderd_map could not be read correctly.
In std::unorderd_map<std::string, uint64_t> mapt, the value is always 0, and in std::unorderd_map<int, uint64_t> mapt2, Segmentation Fault or Illegal Instruction would occur. What could be the cause? I would like to know if anyone can help me.
ClassTest
class ClassTest {
public:
char* ident;
std::vector<int> vvv;
std::unordered_map<std::string, uint64_t> mapt;
std::unordered_map<int, uint64_t> mapt2;
explicit ClassTest()
: ident("hello class test"),
vvv({1, 2, 3}),
mapt({{"hoge", 4}, {"fuga", 5}}),
mapt2({{1, 6}, {2, 7}}){};
~ClassTest(){};
};
Enclave Process
void ecall_class_test(void* class_test) {
printf("--- Enclave Process.\n");
ClassTest* enclave_class_test = static_cast<ClassTest*>(class_test);
printf("%s\n", enclave_class_test->ident);
for (int i = 0; i < enclave_class_test->vvv.size(); i++) {
printf("vvv: %d\n", enclave_class_test->vvv[i]);
}
// value is always 0
printf("mapt: hoge: %ld\n", enclave_class_test->mapt["hoge"]);
printf("mapt: fuga: %ld\n", enclave_class_test->mapt["fuga"]);
// cause segmentation fault or illegal instruction
printf("mapt2: 1: %ld\n", enclave_class_test->mapt2[1]);
printf("mapt2: 2: %ld\n", enclave_class_test->mapt2[2]);
}
Normal Process
ClassTest* class_test = new ClassTest();
printf("---Normal Process---\n");
printf("mapt: hoge: %ld\n", class_test->mapt["hoge"]);
printf("mapt: fuga: %ld\n", class_test->mapt["fuga"]);
printf("mapt2: 1 %ld\n", class_test->mapt2[1]);
printf("mapt2: 2 %ld\n", class_test->mapt2[2]);
// cast class ptr to void*
void* enclave_class_test = static_cast<void*>(class_test);
// ecall
ecall_class_test(global_eid, enclave_class_test);
EDL
public void ecall_class_test([user_check] void* class_test);
Execution Result
---Normal Process---
mapt: hoge: 4
mapt: fuga: 5
mapt2: 1 6
mapt2: 2 7
--- Enclave Process.
hello class test
vvv: 1
vvv: 2
vvv: 3
mapt: hoge: 0
mapt: fuga: 0
Segmentation fault
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I apologize for getting back to you a little late.
is this a similar error to your other post? (https://community.intel.com/t5/Intel-Software-Guard-Extensions/How-to-pass-a-structure-pointer-of-a-recursive-structure-between/m-p/1391069#M5324)
Are you able to send over log files?
Sincerely,
Sahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply!
I think the essence of the problem is the same as the one previous question.
However, even though the program here is able to read the vector container correctly (so I believe that casting the class pointer to void*, passing it to another area, and casting it back to the class pointer is successful), the unordered_map container cannot be read and I have no idea why.
Is casting to void* not the recommended way to pass class information between Enclave and Untrust areas in this way?
Sincerely,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Did you get a chance to look at the sample I linked on your other post?
I think it would help with this issue:
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