-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mitigate stale data reads on SGX platform #100383
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
50066f9
to
34d7310
Compare
r? @cuviper, perhaps |
debug_assert!(len < 8); | ||
debug_assert_eq!(aligned_src as usize % 8, 0); | ||
debug_assert_eq!(aligned_len % 8, 0); | ||
debug_assert!(aligned_len < 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two asserts also support that aligned_len
can only be 0 or 8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See discussion above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this should check aligned_len <= 16
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Good catch! I've updated the commit.
I would've imagined that the test_copy_from_userspace_function
would've tripped this. Aren't these debug_assert
statements evaluated during those tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, CI isn't running any SGX tests, since it's a tier-2 target. If you tried those tests yourself, the debug-asserts may have been compiled out since std
is usually compiled in release mode. Is it worth turning these into full-time asserts? LLVM might optimize them out anyway if it can statically prove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did run these tests locally. It must indeed be because stdlib was build in release mode. That's good to know! I don't think it's worth turning these debug_asserts
into asserts
and pay the performance penalty.
34d7310
to
a6383be
Compare
a6383be
to
c012f13
Compare
In order to mitigate the Stale Data Read for xAPIC vulnerability completely, reading userspace from an SGX enclave must be aligned and in 8-bytes chunks. References: - https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00657.html - https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/stale-data-read-from-xapic.html
c012f13
to
2a23d08
Compare
@bors r+ rollup |
…on, r=cuviper Mitigate stale data reads on SGX platform Intel disclosed the Stale Data Read vulnerability yesterday. In order to mitigate this issue completely, reading userspace from an SGX enclave must be aligned and in 8-bytes chunks. This PR implements this mitigation References: - https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00657.html - https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/stale-data-read-from-xapic.html cc: `@jethrogb`
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#100186 (Mention `as_mut` alongside `as_ref` in borrowck error message) - rust-lang#100383 (Mitigate stale data reads on SGX platform) - rust-lang#100507 (suggest `once_cell::Lazy` for non-const statics) - rust-lang#100617 (Suggest the right help message for as_ref) - rust-lang#100667 (Migrate "invalid variable declaration" errors to SessionDiagnostic) - rust-lang#100709 (Migrate typeck's `used` expected symbol diagnostic to `SessionDiagnostic`) - rust-lang#100723 (Add the diagnostic translation lints to crates that don't emit them) - rust-lang#100729 (Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf`) - rust-lang#100750 (improved diagnostic for function defined with `def`, `fun`, `func`, or `function` instead of `fn`) - rust-lang#100763 (triagebot: Autolabel `A-rustdoc-json`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…copies, r=workingjubilee Clean up SGX user memory copies Follow-up on rust-lang#98126 and rust-lang#100383 r? `@cuviper` cc `@raoulstrackx`
Intel disclosed the Stale Data Read vulnerability yesterday. In order to mitigate this issue completely, reading userspace from an SGX enclave must be aligned and in 8-bytes chunks. This PR implements this mitigation
References:
cc: @jethrogb