jovanbulck / sgx-step

A practical attack framework for precise enclave execution control
GNU General Public License v3.0
441 stars 83 forks source link

./app: undefined symbol: sgx_get_aep #43

Closed xiaonan-INTC closed 2 years ago

xiaonan-INTC commented 2 years ago

After SGX-Step using the latest version v2.14, step 1 and 2 succeeded, but step 3.Build and run test applications has an error:

$ cd app/aep-redirect $ make run

...

: note: this is the location of the previous definition [AS] aep_trampoline.S [AS] irq_entry.S [AS] rtm.S [AS] transient.S [AR] libsgx-step.a [CC] main.c [LD] main.o -o app ./app: symbol lookup error: ./app: undefined symbol: sgx_get_aep make: *** [Makefile:45: run] Error 127 And also an error: $ cd app/bench $ NUM=100 STRLEN=1 make parse ... : note: this is the location of the previous definition [AS] aep_trampoline.S [AS] irq_entry.S [AS] rtm.S [AS] transient.S [AR] libsgx-step.a [CC] main.c [LD] main.o -o app ./app: symbol lookup error: ./app: undefined symbol: sgx_get_aep make: *** [Makefile:64: run] Error 127
jovanbulck commented 2 years ago

This error indicates that the linker doesn't find the customly patched SGX SDK. Did you make sure to patch and install the SGX SDK?

Please have a look at #24 and follow steps there, and let me know if this works for you so this issue can be closed.

If problems remain, please post output using ldd and LD_LIBRARY_PATH.

xiaonan-INTC commented 2 years ago

This error indicates that the linker doesn't find the customly patched SGX SDK. Did you make sure to patch and install the SGX SDK?

Please have a look at #24 and follow steps there, and let me know if this works for you so this issue can be closed.

If problems remain, please post output using ldd and LD_LIBRARY_PATH.

@jovanbulck

Hello, when I did “2. Patch and install SGX SDK”, I met following error:

$sudo service aesmd status

● aesmd.service - Intel(R) Architectural Enclave Service Manager Loaded: loaded (/lib/systemd/system/aesmd.service; disabled; vendor preset: enabled) Active: inactive (dead) 4月 20 01:15:33 systemd[1]: Failed to start Intel(R) Architectural Enclave Servi> 4月 20 01:15:49 systemd[1]: aesmd.service: Scheduled restart job, restart counte> 4月 20 01:15:49 systemd[1]: Stopped Intel(R) Architectural Enclave Service Manag> 4月 20 01:15:49 systemd[1]: Starting Intel(R) Architectural Enclave Service Mana> 4月 20 01:15:49 systemd[588511]: aesmd.service: Failed to determine user credent> 4月 20 01:15:49 systemd[588511]: aesmd.service: Failed at step USER spawning /op> 4月 20 01:15:49 systemd[1]: aesmd.service: Control process exited, code=exited, > 4月 20 01:15:49 systemd[1]: aesmd.service: Failed with result 'exit-code'. 4月 20 01:15:49 systemd[1]: Failed to start Intel(R) Architectural Enclave Servi> 4月 20 01:15:55 systemd[1]: Stopped Intel(R) Architectural Enclave Service Manag>

$sudo service aesmd stop $sudo service aesmd start

Job for aesmd.service failed because the control process exited with error code. See "systemctl status aesmd.service" and "journalctl -xe" for details.

$systemctl status aesmd.service

● aesmd.service - Intel(R) Architectural Enclave Service Manager Loaded: loaded (/lib/systemd/system/aesmd.service; disabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Wed 2022-04-20 01:28:25 CST; 11s ago Process: 658964 ExecStartPre=/opt/intel/sgxpsw/aesm/linksgx.sh (code=exited, status=217/USER)

Then did "3. Build and run test applications", met following error:

[main.c] Creating enclave... [init ../../../psw/ae/aesm_service/source/core/ipc/UnixCommunicationSocket.cpp:225] Failed to connect to socket /var/run/aesmd/aesm.socket Error calling enclave at main.c:120 (rv=0x4001) make: *** [Makefile:45: run] Aborted

jovanbulck commented 2 years ago

Now it seems you linked to all required dependencies, but there seems to be an issue with you SGX PSW installation, as the aesmd service is not running. The app then crashes naturally as it cannot communicate with the aesmd service.

I am not sure why your SGX PSW is not working, but I expect it is an issue in the linux-sgx project. This service used to crash frequently, and sometimes could be brought up successfully by $sudo service aesmd stop; $sudo service aesmd start repeatedly until it works.

Also make sure your SGX driver is loaded correctly and check dmesg?

Hope it helps!

xiaonan-INTC commented 2 years ago

Thanks a lot, @jovanbulck It works now, I re-installed intel sgx at first, then re-installed sgx-step.

xiaonan-INTC commented 2 years ago

Sorry, @jovanbulck

I copy libsgx_urts.so from /opt/intel/sgxsdk/lib64 to the app uses, but met following error:

[main.c] Creating enclave... Please use the correct uRTS library from PSW package. Error calling enclave at main.c:120 (rv=0x1) make: *** [Makefile:45: run] Aborted

jovanbulck commented 2 years ago

Glad to hear re-installing SGX-SDK helped. The last error means you are not linking to the PSW library, but to the SDK one.

Have a look at this issue in the linux-sgx repo:

https://github.com/intel/linux-sgx/issues/47

I think you ought not to link to /opt/intel/sgxsdk/lib64, and you should definitely not copy files(!)

Normally this is all not needed when you do the $ source /opt/intel/sgxsdk/environment # add to ~/.bashrc to preserve across terminal sessions from the SGX-Step README before you do the make, and every time you start a new bash session.

Hope it helps. Let me know if things work now, or if problems persist, please output the full exact commands and output, including the output of ldd ./app

xiaonan-INTC commented 2 years ago

Glad to hear re-installing SGX-SDK helped. The last error means you are not linking to the PSW library, but to the SDK one.

Have a look at this issue in the linux-sgx repo:

intel/linux-sgx#47

I think you ought not to link to /opt/intel/sgxsdk/lib64, and you should definitely not copy files(!)

Normally this is all not needed when you do the $ source /opt/intel/sgxsdk/environment # add to ~/.bashrc to preserve across terminal sessions from the SGX-Step README before you do the make, and every time you start a new bash session.

Hope it helps. Let me know if things work now, or if problems persist, please output the full exact commands and output, including the output of ldd ./app

Thank you very much, @jovanbulck it works now!

jovanbulck commented 2 years ago

glad to hear it works now!