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 541 forks source link

Got error "Please use the correct uRTS library from PSW package." when SGX_MODE=HW #47

Closed you-n-g closed 7 years ago

you-n-g commented 7 years ago

Error Info

Got error "Please use the correct uRTS library from PSW package." when SGX_MODE=HW Here is my output when trying to run the SampleEnclave with SGX_MODE=HW

[15:05:08]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin/sgxsdk/SampleCode/SampleEnclave# make SGX_MODE=HW SGX_DEBUG=1
GEN => App/Enclave_u.c
CC <= App/Enclave_u.c
CXX <= App/App.cpp
CXX <= App/Edger8rSyntax/Arrays.cpp
CXX <= App/Edger8rSyntax/Functions.cpp
CXX <= App/Edger8rSyntax/Pointers.cpp
CXX <= App/Edger8rSyntax/Types.cpp
CXX <= App/TrustedLibrary/Libc.cpp
CXX <= App/TrustedLibrary/Libcxx.cpp
CXX <= App/TrustedLibrary/Thread.cpp
LINK => app
GEN => Enclave/Enclave_t.c
CC <= Enclave/Enclave_t.c
CXX <= Enclave/Enclave.cpp
CXX <= Enclave/Edger8rSyntax/Arrays.cpp
CXX <= Enclave/Edger8rSyntax/Functions.cpp
CXX <= Enclave/Edger8rSyntax/Pointers.cpp
CXX <= Enclave/Edger8rSyntax/Types.cpp
CXX <= Enclave/TrustedLibrary/Libc.cpp
CXX <= Enclave/TrustedLibrary/Libcxx.cpp
CXX <= Enclave/TrustedLibrary/Thread.cpp
LINK => enclave.so
<EnclaveConfiguration>
  <ProdID>0</ProdID>
  <ISVSVN>0</ISVSVN>
  <StackMaxSize>0x40000</StackMaxSize>
  <HeapMaxSize>0x100000</HeapMaxSize>
  <TCSNum>10</TCSNum>
  <TCSPolicy>1</TCSPolicy>
  <DisableDebug>0</DisableDebug>
  <MiscSelect>0</MiscSelect>
  <MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
Parsing key file is OK.
[build_secs /home/young/repos/linux-sgx/psw/urts/loader.cpp:385] enclave start address = (nil), size = 800000
RSAVerify() returns success. The signature_verified is 1
Succeed.
SIGN => enclave.signed.so
[15:05:14]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin/sgxsdk/SampleCode/SampleEnclave# ./app
Please use the correct uRTS library from PSW package.
Error: Unexpected error occurred.
Enter a character before exit ...

About my Installation

I have successfully installed the sgx driver with this tutorial and loaded it by following https://github.com/01org/linux-sgx-driver

[14:21:18]root@young-Inspiron-13-7359:/home/young/repos/SGX-hardware# lsmod | grep sgx
isgx                   53248  1

I have successfully installed The SGX SDK and SGX PSW by following https://github.com/01org/linux-sgx-driver

[15:08:50]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin# sudo service aesmd restart
aesmd stop/waiting
aesmd start/running, process 4546
[15:09:10]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin# ps aux | grep 4546
aesmd     4546  0.0  0.1 280716 10452 ?        Ssl  15:09   0:00 /opt/intel/sgxpsw/aesm/aesm_service
root      4555  0.0  0.0  15944  2540 pts/33   S+   15:09   0:00 grep --color=auto 4546
[15:09:18]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin#

About my hardware

I'm using dell laptop Inspiron i7359-6790SLV

I'm sure that SGX is available for my CPU and enabled in BIOS by running this script https://github.com/ayeks/SGX-hardware/blob/master/test-sgx.c Here is my result

eax: 406e3 ebx: 1100800 ecx: 7ffafbbf edx: bfebfbff
stepping 3
model 14
family 6
processor type 0
extended model 4
extended family 0
smx: 0

Extended feature bits (EAX=07H, ECX=0H)
eax: 0 ebx: 29c67af ecx: 0 edx: 0
sgx available: 1

CPUID Leaf 12H, Sub-Leaf 0 of Intel SGX Capabilities (EAX=12H,ECX=0)
eax: 1 ebx: 0 ecx: 0 edx: 241f
sgx 1 supported: 1
sgx 2 supported: 0
MaxEnclaveSize_Not64: 1f
MaxEnclaveSize_64: 24

CPUID Leaf 12H, Sub-Leaf 1 of Intel SGX Capabilities (EAX=12H,ECX=1)
eax: 36 ebx: 0 ecx: 1f edx: 0

CPUID Leaf 12H, Sub-Leaf 2 of Intel SGX Capabilities (EAX=12H,ECX=2)
eax: 80200001 ebx: 0 ecx: 5d80001 edx: 0

CPUID Leaf 12H, Sub-Leaf 3 of Intel SGX Capabilities (EAX=12H,ECX=3)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 4 of Intel SGX Capabilities (EAX=12H,ECX=4)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 5 of Intel SGX Capabilities (EAX=12H,ECX=5)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 6 of Intel SGX Capabilities (EAX=12H,ECX=6)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 7 of Intel SGX Capabilities (EAX=12H,ECX=7)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 8 of Intel SGX Capabilities (EAX=12H,ECX=8)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 9 of Intel SGX Capabilities (EAX=12H,ECX=9)
eax: 0 ebx: 0 ecx: 0 edx: 0

About my OS

[15:16:58]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin/sgxsdk/SampleCode/SampleEnclave# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.4 LTS
Release:        14.04
Codename:       trusty
[15:20:53]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin/sgxsdk/SampleCode/SampleEnclave# uname -r
4.2.0-41-generic

Any comments will be appreciated. Thanks!!!!

you-n-g commented 7 years ago

And I'm sure the app is linking to the correct libsgx_urts.so.

[15:23:28]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin/sgxsdk/SampleCode/SampleEnclave# ldd app
        linux-vdso.so.1 =>  (0x00007ffdea1ec000)
        libsgx_urts.so => /opt/intel/sgxsdk/lib64/libsgx_urts.so (0x00007f2edcaf4000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2edc7da000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2edc5c4000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2edc1ff000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2edbef8000)
        /lib64/ld-linux-x86-64.so.2 (0x0000561fb5c94000)
zhaohuidu commented 7 years ago

Make sure PSW installer has been installed. Do not set LD_LIBRARY_PATH=/opt/intel/sgxsdk/lib64/ libsgx_urts.so under system folder instead of the one under /opt/intel/sgxsdk/lib64/ should be used

you-n-g commented 7 years ago

@zhaohuidu I use /usr/lib/libsgx_urts.so and It works!! Thanks very much!

So /usr/lib/libsgx_urts.so comes from the PSW and it is the library for production environment on the hardware. And /opt/intel/sgxsdk/lib64/libsgx_urts.so comes from the SDK and it is only for development.

Did I understand it correctly?

zhaohuidu commented 7 years ago

Yes.

Yonggie commented 5 years ago

can any body tell me where to modify the DL_LIBRARY_PATH mentioned above?????

andyzyb commented 5 years ago

As the answer above, you usually don't need to set LD_LIBRARY_PATH and it will use the right uRTS in /usr/lib

Do not set LD_LIBRARY_PATH=/opt/intel/sgxsdk/lib64/

buttercutter commented 4 years ago

May I know why I do not have this file /usr/lib/libsgx_urts.so installed ?

[phung@archlinux HelloEnclave]$ locate urts /opt/intel/sgxpsw/aesm/liburts_internal.so /opt/intel/sgxpsw/lib64/libsgx_urts.so /opt/intel/sgxsdk/include/sgx_urts.h /opt/intel/sgxsdk/lib64/libsgx_urts.so /opt/intel/sgxsdk/lib64/libsgx_urts_sim.so /opt/intel/sgxsdk/pkgconfig/libsgx_urts.pc /opt/intel/sgxsdk/pkgconfig/libsgx_urts_sim.pc [phung@archlinux HelloEnclave]$

sanmiawi commented 4 years ago

I had a similar error but it went away when I ran the compiled app using the sudo command.

tomoyasuzuki commented 1 year ago

I'm trying to run SampleEnclave with HW mode, but I got same error. How do I use libsgx_urts.so in /usr/lib? I have not set LD_LIBRARY_PATH, but the library in /opt/intel/sgxsdk/lib64 is used. I tried to set SGX_LIBRARY_PATH=/usr/lib in Makefile, but I got same error.

Thank you.

Kskfte commented 5 months ago

I'm trying to run SampleEnclave with HW mode, but I got same error. How do I use libsgx_urts.so in /usr/lib? I have not set LD_LIBRARY_PATH, but the library in /opt/intel/sgxsdk/lib64 is used. I tried to set SGX_LIBRARY_PATH=/usr/lib in Makefile, but I got same error.

Thank you.

I meet the same problem with you, do you solve the problem?

Thank you.