Uh oh!
There was an error while loading. Please reload this page.
SGX: Clear additional flag on enclave entry - #65810
Conversation
rust-highfive
commented
Oct 25, 2019
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @rkruppe (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
jethrogb
commented
Oct 25, 2019
| cld /* x86-64 ABI requires DF to be unset at function entry/exit */ | ||
| /* making sure AC flag is not set in rflags */ | ||
| /* avoid using the 'clac' instruction to be compatible with older compilers */ |
There was a problem hiding this comment.
clac was introduced in 5th generation Intel CPUs, SGX in 6th generation, so this isn't an issue
| pushfq | ||
| popq %rcx | ||
| and $0xFFFFFFFFFFFBFFFF, %rcx | ||
| push %rcx |
There was a problem hiding this comment.
You can clear DF and AC in a single instruction. e.g. andq $~0x40400, (%rsp)
| cld /* x86-64 ABI requires DF to be unset at function entry/exit */ | ||
| /* - DF flag: x86-64 ABI requires DF to be unset at function entry/exit */ | ||
| /* - AC flag: AEX on misaligned memory accesses leaks side channel info */ | ||
| andq $~0x40400, (%rsp) |
jethrogb
commented
Oct 25, 2019
cc @Goirad can you please update toolchain after this is merged and a new nightly is published? |
nagisa
commented
Oct 25, 2019
bors
commented
Oct 25, 2019
📌 Commit 5aafa98 has been approved by |
SGX: Clear additional flag on enclave entry An attacker could set both the AC flag in CR0 as in rflags. This causes the enclave to perform an AEX upon a misaligned memory access, and an attacker learns some information about the internal enclave state. The AC flag in rflags is copied from userspace upon an enclave entry. Upon AEX it is copied and later restored. This patch forces the rflag.AC bit to be reset right after an enter.
alexcrichton
commented
Oct 25, 2019
r? @nagisa |
SGX: Clear additional flag on enclave entry An attacker could set both the AC flag in CR0 as in rflags. This causes the enclave to perform an AEX upon a misaligned memory access, and an attacker learns some information about the internal enclave state. The AC flag in rflags is copied from userspace upon an enclave entry. Upon AEX it is copied and later restored. This patch forces the rflag.AC bit to be reset right after an enter.
SGX: Clear additional flag on enclave entry An attacker could set both the AC flag in CR0 as in rflags. This causes the enclave to perform an AEX upon a misaligned memory access, and an attacker learns some information about the internal enclave state. The AC flag in rflags is copied from userspace upon an enclave entry. Upon AEX it is copied and later restored. This patch forces the rflag.AC bit to be reset right after an enter.
Rollup of 7 pull requests Successful merges: - #63810 (Make <*const/mut T>::offset_from `const fn`) - #65705 (Add {String,Vec}::into_raw_parts) - #65749 (Insurance policy in case `iter.size_hint()` lies.) - #65799 (Fill tracking issue number for `array_value_iter`) - #65800 (self-profiling: Update measureme to 0.4.0 and remove non-RAII methods from profiler.) - #65806 (Add [T]::as_ptr_range() and [T]::as_mut_ptr_range().) - #65810 (SGX: Clear additional flag on enclave entry) Failed merges: r? @ghost
SGX: Clear additional flag on enclave entry An attacker could set both the AC flag in CR0 as in rflags. This causes the enclave to perform an AEX upon a misaligned memory access, and an attacker learns some information about the internal enclave state. The AC flag in rflags is copied from userspace upon an enclave entry. Upon AEX it is copied and later restored. This patch forces the rflag.AC bit to be reset right after an enter.
Rollup of 6 pull requests Successful merges: - #65705 (Add {String,Vec}::into_raw_parts) - #65749 (Insurance policy in case `iter.size_hint()` lies.) - #65799 (Fill tracking issue number for `array_value_iter`) - #65800 (self-profiling: Update measureme to 0.4.0 and remove non-RAII methods from profiler.) - #65806 (Add [T]::as_ptr_range() and [T]::as_mut_ptr_range().) - #65810 (SGX: Clear additional flag on enclave entry) Failed merges: r? @ghost
An attacker could set both the AC flag in CR0 as in rflags. This causes the enclave to perform an AEX upon a misaligned memory access, and an attacker learns some information about the internal enclave state.
The AC flag in rflags is copied from userspace upon an enclave entry. Upon AEX it is copied and later restored. This patch forces the rflag.AC bit to be reset right after an enter.