intel / linux-sgx

Intel SGX for Linux*
https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html
Other
1.32k stars 543 forks source link

Failed to load enclave in ubuntu 18.04.5 #623

Open panguangming opened 3 years ago

panguangming commented 3 years ago

I compiled the sample code SampleCode/LocalAttestation in hardware mode and ran it with error listed below(it runs ok when compiled in SIMULATION mode).

OS version:4.15.0-122-generic #124-Ubuntu SMP Thu Oct 15 13:03:05 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

the make result is listed below: @@@@@@@@@@@@ make result @@@@@@@@@@@@@

0
<ISVSVN>0</ISVSVN>
<StackMaxSize>0x40000</StackMaxSize>
<HeapMaxSize>0x100000</HeapMaxSize>
<TCSNum>1</TCSNum>
<TCSPolicy>1</TCSPolicy>
<DisableDebug>0</DisableDebug>

[build_secs /home/sgx/linux-sgx/psw/urts/loader.cpp:517] Enclave start addr. = (nil), Size = 0x400000, 4096 KB SIGN => libenclave_initiator.signed.so make[1]: leave“/home/sgx/linux-sgx/SampleCode/LocalAttestation/EnclaveInitiator” make[1]: enter“/home/sgx/linux-sgx/SampleCode/LocalAttestation/EnclaveResponder” GEN => EnclaveResponder_t.h CC <= EnclaveResponder_t.c [build_secs /home/sgx/linux-sgx/psw/urts/loader.cpp:517] Enclave start addr. = (nil), Size = 0x400000, 4096 KB SIGN => libenclave_responder.signed.so make[1]: leave dirctory“/home/sgx/linux-sgx/SampleCode/LocalAttestation/EnclaveResponder” make[1]: enter“/home/sgx/linux-sgx/SampleCode/LocalAttestation/App” CC <= EnclaveInitiator_u.c CC <= EnclaveResponder_u.c CXX <= App.cpp SGX_INC is -I/opt/intel/sgxsdk//include LIB is -lsgx_urts -lsgx_uae_service -L/opt/intel/sgxsdk//lib64 -lpthread CC <= UntrustedEnclaveMessageExchange.cpp GEN => app make[1]: leave “/home/sgx/linux-sgx/SampleCode/LocalAttestation/App” The project has been built in hardware debug mode.

@@@@@@@@@@@@@run error@@@@@@@@@@@@@ sgx@scott-Server-Platform:~/linux-sgx/SampleCode/LocalAttestation$ bin/app:

[CEnclavePool /home/sgx/linux-sgx/psw/urts/enclave.cpp:629] enter CEnclavePool constructor [__sgx_create_enclave_ex urts.cpp:91] Couldn't open the enclave file, error = 2 failed to load enclave. [remove_enclave /home/sgx/linux-sgx/psw/urts/enclave.cpp:783] remove an unknown enclave [remove_enclave /home/sgx/linux-sgx/psw/urts/enclave.cpp:783] remove an unknown enclave sgx@scott-Server-Platform:~/linux-sgx/SampleCode/LocalAttestation$

@@@@@@@@@@@@@ library info@@@@@@@@@@@@@@ sgx@scott-Server-Platform:~/linux-sgx/SampleCode/LocalAttestation$ ldd bin/app linux-vdso.so.1 (0x00007fff6b188000) libsgx_urts.so => /usr/lib/x86_64-linux-gnu/libsgx_urts.so (0x00007fae6c9db000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fae6c42c000) libsgx_enclave_common.so.1 => /usr/lib/x86_64-linux-gnu/libsgx_enclave_common.so.1 (0x00007fae6c9c5000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fae6c20d000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fae6c009000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fae6bc80000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fae6ba68000) /lib64/ld-linux-x86-64.so.2 (0x00007fae6c81d000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fae6b6ca000) sgx@scott-Server-Platform:~/linux-sgx/SampleCode/LocalAttestation$

@@@@@@@@@@@@@ ldconfig info@@@@@@@@@@@@@@ sgx@scott-Server-Platform:~/linux-sgx/SampleCode/LocalAttestation$ sudo ldconfig -v |grep sgx /sbin/ldconfig.real: /lib/x86_64-linux-gnu/ld-2.27.so is the dynamic linker, ignoring

libsgx_dcap_quoteverify.so.1 -> libsgx_dcap_quoteverify.so.1.8.100.2 libsgx_dcap_ql.so.1 -> libsgx_dcap_ql.so.1.8.100.2 libsgx_launch.so.1 -> libsgx_launch.so.1.0.107.2 libsgx_pce_logic.so -> libsgx_pce_logic.so libsgx_epid.so.1 -> libsgx_epid.so.1.0.107.2 libsgx_pce.signed.so -> libsgx_pce.signed.so libsgx_quote_ex.so.1 -> libsgx_quote_ex.so.1.1.107.2 libsgx_qe3.signed.so -> libsgx_qe3.signed.so libsgx_qve.signed.so -> libsgx_qve.signed.so libsgx_enclave_common.so.1 -> libsgx_enclave_common.so.1.0.112.2 libsgx_qe3_logic.so -> libsgx_qe3_logic.so libsgx_urts.so -> libsgx_urts.so.1.1.109.2 /sbin/ldconfig.real: /lib32/ld-2.27.so is the dynamic linker, ignoring

lzha101 commented 3 years ago

You can try to enter bin folder and then run the application. Please refer to https://github.com/intel/linux-sgx/blob/master/SampleCode/LocalAttestation/README.txt#L29

panguangming commented 3 years ago

when i entered bin folder and tried to run run "./appresponder" and "./appinitiator".

bothe failed with the following error msg: init_enclave failed failed to load enclave libenclave_initiator.signed.so, error code is 0x1.

init_enclave failed failed to load enclave libenclave_responder.signed.so, error code is 0x1. image

lzha101 commented 3 years ago

Suggest to build a debug version SGX sdk/psw and debug your project using sgx-gdb.