Open ndokmai opened 7 months ago
I have the same problem. It is specifically not #526. Also I can easily run the SampleEnclave from the SGX-SDK.
Any updates on this?
Always
Can you please post the output of running the program with strace -etrace=ioctl
Can you please post the output of running the program with
strace -etrace=ioctl
user@host $ strace -etrace=ioctl sgx-detect
ioctl(1, TCGETS, {c_iflag=ICRNL|IXON|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
Detecting SGX, this may take a minute...
ioctl(3, FIONBIO, [1]) = 0
ioctl(3, FIONBIO, [0]) = 0
ioctl(4, FIONBIO, [1]) = 0
ioctl(6, FIONBIO, [1]) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2368758, si_uid=21621, si_status=0, si_utime=0, si_stime=0} ---
ioctl(6, FIONBIO, [0]) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2368759, si_uid=21621, si_status=127, si_utime=0, si_stime=0} ---
ioctl(5, FIONBIO, [1]) = 0
ioctl(7, FIONBIO, [1]) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2368765, si_uid=21621, si_status=3, si_utime=0, si_stime=0} ---
ioctl(7, FIONBIO, [0]) = 0
ioctl(5, FIONBIO, [1]) = 0
ioctl(7, FIONBIO, [1]) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2368766, si_uid=21621, si_status=0, si_utime=0, si_stime=0} ---
ioctl(7, FIONBIO, [0]) = 0
ioctl(4, FIONBIO, [1]) = 0
ioctl(4, FIONBIO, [0]) = 0
ioctl(4, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270be000) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_INIT, 0x7ffd270c15e0) = 0
ioctl(4, FIONBIO, [1]) = 0
ioctl(4, FIONBIO, [0]) = 0
ioctl(4, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270be000) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(4, SGX_IOC_ENCLAVE_INIT, 0x7ffd270c15e0) = 0
ioctl(5, FIONBIO, [1]) = 0
ioctl(5, FIONBIO, [0]) = 0
ioctl(5, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270be000) = -1 EIO (Input/output error)
ioctl(5, FIONBIO, [1]) = 0
ioctl(5, FIONBIO, [0]) = 0
ioctl(5, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270bcf68) = -1 EIO (Input/output error)
ioctl(5, FIONBIO, [1]) = 0
ioctl(5, FIONBIO, [0]) = 0
ioctl(5, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270be000) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_INIT, 0x7ffd270c15e0) = 0
ioctl(5, FIONBIO, [1]) = 0
ioctl(5, FIONBIO, [0]) = 0
ioctl(5, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270be000) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(5, SGX_IOC_ENCLAVE_INIT, 0x7ffd270c15e0) = 0
ioctl(6, FIONBIO, [1]) = 0
ioctl(6, FIONBIO, [0]) = 0
ioctl(6, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270be000) = -1 EIO (Input/output error)
ioctl(6, FIONBIO, [1]) = 0
ioctl(6, FIONBIO, [0]) = 0
ioctl(6, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270bcf68) = -1 EIO (Input/output error)
ioctl(6, FIONBIO, [1]) = 0
ioctl(6, FIONBIO, [0]) = 0
ioctl(6, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270be000) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_INIT, 0x7ffd270c15e0) = 0
ioctl(6, FIONBIO, [1]) = 0
ioctl(6, FIONBIO, [0]) = 0
ioctl(6, SGX_IOC_ENCLAVE_CREATE, 0x7ffd270be000) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd270bdf08) = 0
ioctl(6, SGX_IOC_ENCLAVE_INIT, 0x7ffd270c15e0) = 0
✔ SGX instruction set
✔ CPU support
✔ CPU configuration
✔ Enclave attributes
✔ Enclave Page Cache
SGX features
✔ SGX2 ✔ EXINFO ✘ ENCLV ✘ OVERSUB ✔ KSS
Total EPC size: 2.0GiB (no integrity protection)
✔ Flexible launch control
✔ CPU support
? CPU configuration
✔ Able to launch production mode enclave
✘ SGX system software
✔ SGX kernel device (/dev/sgx_enclave)
✔ libsgx_enclave_common
✔ AESM service
✘ Able to launch enclaves
✘ Debug mode
✔ Production mode
🕮 SGX system software > Able to launch enclaves > Debug mode
The enclave could not be launched.
(run with `--verbose` for more details)
More information: https://edp.fortanix.com/docs/installation/help/#run-enclave-debug
+++ exited with 0 +++
Is the problem just with sgx-detect
and the unit tests? Are you able to run e.g. hello world?
I think the problem is in generate_dummy_signature
we always create a dummy signature with attributes based on xgetbv(0)
even though ssaframesize for the enclave may be set to a value lower than needed for that xfrm. If attributes are not explicitly specified, we then copy those attributes from the dummy signature to the ECREATE call.
Instead, in generate_dummy_signature
, we should call read_meas
once and cache the result for later use, and then come up with an xfrm that matches the ssaframesize in the first measurement in the SGXS.
I get the same error when I follow the lines from the readme:
# Install EDP components
rustup target add x86_64-fortanix-unknown-sgx --toolchain nightly
cargo install fortanix-sgx-tools sgxs-tools
echo >> ~/.cargo/config -e '[target.x86_64-fortanix-unknown-sgx]\nrunner = "ftxsgx-runner-cargo"'
# Run your enclave!
cargo new --bin hello-world
cd hello-world
cargo run --target x86_64-fortanix-unknown-sgx
the last command yields:
Error: Create(Io(Os { code: 5, kind: Uncategorized, message: "Input/output error" }))
While loading SGX enclave
ERROR: while running "ftxsgx-runner" "target/x86_64-fortanix-unknown-sgx/debug/hello-world.sgxs" got exit status: 1
Edit: with strace
root@103139b6faf0# strace -etrace=ioctl cargo run --target x86_64-fortanix-unknown-sgx
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TIOCGWINSZ, {ws_row=49, ws_col=190, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(2, TIOCGWINSZ, {ws_row=49, ws_col=190, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(2, TIOCGWINSZ, {ws_row=49, ws_col=190, ws_xpixel=0, ws_ypixel=0}) = 0
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
Running `ftxsgx-runner-cargo target/x86_64-fortanix-unknown-sgx/debug/hello-world`
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=392, si_uid=0, si_status=0, si_utime=0, si_stime=3} ---
Error: Create(Io(Os { code: 5, kind: Uncategorized, message: "Input/output error" }))
While loading SGX enclave
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=393, si_uid=0, si_status=1, si_utime=1, si_stime=1} ---
ERROR: while running "ftxsgx-runner" "target/x86_64-fortanix-unknown-sgx/debug/hello-world.sgxs" got exit status: 1
+++ exited with 1 +++
It doesn't really look like ecreate fails in the second log. Any other ideas?
From the error message in the second log, clearly ECREATE fails. To see it in strace, you need to run with -f
. I'm fairly certain the problem I outlined before is the issue.
Ran with -f
:
root@103139b6faf0:/ftx/hello-world# strace -etrace=ioctl -f cargo run --target x86_64-fortanix-unknown-sgx
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TIOCGWINSZ, {ws_row=50, ws_col=190, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(2, TIOCGWINSZ, {ws_row=50, ws_col=190, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(2, TIOCGWINSZ, {ws_row=50, ws_col=190, ws_xpixel=0, ws_ypixel=0}) = 0
strace: Process 19 attached
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
[pid 19] --- SIGUSR1 {si_signo=SIGUSR1, si_code=SI_TKILL, si_pid=18, si_uid=0} ---
[pid 19] +++ exited with 0 +++
Running `ftxsgx-runner-cargo target/x86_64-fortanix-unknown-sgx/debug/hello-world`
strace: Process 20 attached
[pid 20] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=20, si_uid=0, si_status=0, si_utime=0, si_stime=8} ---
strace: Process 21 attached
[pid 21] ioctl(4, FIONBIO, [1]) = 0
[pid 21] ioctl(4, FIONBIO, [0]) = 0
[pid 21] ioctl(5, _IOC(_IOC_WRITE, 0xa4, 0, 0x8), 0x7fff78959000) = -1 EIO (Input/output error)
Error: Create(Io(Os { code: 5, kind: Uncategorized, message: "Input/output error" }))
While loading SGX enclave
[pid 21] +++ exited with 1 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21, si_uid=0, si_status=1, si_utime=2, si_stime=9} ---
ERROR: while running "ftxsgx-runner" "target/x86_64-fortanix-unknown-sgx/debug/hello-world.sgxs" got exit status: 1
+++ exited with 1 +++
I don't know, what that ioctl_write
does. But if ioctl(5, _IOC(_IOC_WRITE, 0xa4, 0, 0x8), 0x7fff78959000) == ECREATE
, I agree.
@raoulstrackx - didn't we meet in Switzerland, last year? On Pascal's workshop at CSF?
Yes I was there :)
Describe the bug:
sgx-detect
reports the following error:Running the test on the most recent commit of
sgxs-loaders
also produces similar results:Upon trying to debug the loader, I found that the error
Create(Io(Os { code: 5, kind: Uncategorized, message: "Input/output error" }))
originated from this specific linehttps://github.com/fortanix/rust-sgx/blob/e2f677b28e2a934bc3b3d20cc201962f0bf556b3/intel-sgx/sgxs-loaders/src/isgx/mod.rs#L202C1-L202C70
To Reproduce: See above.
Expected behavior: ECREATE is expected to be successful in running an application.
Reproducibility:
Environment:
Severity:
Related Issue This feels similar to this issue #526 but updating the kernel didn't fix it.
Additional context: I don't have any issues running sample applications in SGX with Gramine or the Intel SGX SDK, which suggests that the SGX kernel device is working properly.