When a program calls `sgx_tprotected_fs::write`, the following error occurs 
during the execution:

```
thread 'main' panicked at 
rust-sgx-sdk/sgx_urts/src/ocall/sgxfile.rs:56:5:
misaligned pointer dereference: address must be a multiple of 0x8 but is 
0x7ffeb7fdbd25
```

To avoid this panic happening while writing a value into a variable on an 
unaligned memory region, we can use an unsafe method `write_unaligned`.

I checked this patch works well with my own program based on Automata SGX SDK 
which is based on the customized version of Teaclave SGX SDK with this patch.
You can view, comment on, or merge this pull request online at:

  https://github.com/apache/incubator-teaclave-sgx-sdk/pull/463

-- Commit Summary --

  * Use `write_unaligned` to avoid panic

-- File Changes --

    M sgx_urts/src/ocall/sgxfile.rs (3)

-- Patch Links --

https://github.com/apache/incubator-teaclave-sgx-sdk/pull/463.patch
https://github.com/apache/incubator-teaclave-sgx-sdk/pull/463.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/apache/incubator-teaclave-sgx-sdk/pull/463
You are receiving this because you are subscribed to this thread.

Message ID: <apache/incubator-teaclave-sgx-sdk/pull/4...@github.com>

Reply via email to