-
Notifications
You must be signed in to change notification settings - Fork 13.3k
SGX: Fix fuzzy provenance casts with AtomicUsize
#139775
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
Thanks for the PR! I think both of these cases can probably just be replaced by |
What about the linkage? Surely that would change the layout. But, if that's fine, then we could unbox them too. |
That's just there to ensure there's a single instance of the |
Stepping back a little bit, these are used for initializing the args and env. Examining that might yield a better design. For args, every other platform allocates them on demand, not in As for env, I plan to do work on that next across all platforms. For now, at least, I see that iteration order for SGX is non-deterministic and differs between calls, because it collects from a |
I don't think there's any particular problem with delaying this until first use, as long as everything is copied into the enclave at once. Thoughts on this @raoulstrackx? It does mean the user memory can't be freed, but that's cheaper memory than enclave memory anyway. If you want to go this route, I recommend using a
I don't know how much overlap there'll really be with other platforms. The enclave env starts out empty, and can only be populated using
For a single instantiation of a HashMap iteration order should be constant? |
4c548fc
to
7215f24
Compare
I've switched to |
Reminder, once the PR becomes ready for a review, use |
I think I understand how the user memory is managed. To make Then, on Then in the |
No, as mentioned, you must copy the data once, to avoid equivocation. |
library/std/src/sys/pal/sgx/os.rs
Outdated
#[cfg_attr(test, linkage = "available_externally")] | ||
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE")] | ||
static ENV_INIT: Once = Once::new(); | ||
static ENV: OnceLock<EnvStore> = OnceLock::new(); |
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.
Better to use a LazyLock and get rid of get_env_store/create_env_store.
☔ The latest upstream changes (presumably #140127) made this pull request unmergeable. Please resolve the merge conflicts. |
Fixes fuzzy provenance casts with `AtomicUsize`.
7215f24
to
f3a33ce
Compare
Thanks, LGTM!
|
Ah, right. So the only reason a deferred initialization is needed is because the I just noticed that Xous does essentially the same thing as SGX here, but they've fixed only the provenance issues, so I'll mirror the changes over to there. |
Fix a pattern of
#![allow(fuzzy_provenance_casts)]
for SGX which uses anAtomicUsize
as anAtomicPtr<_>
. These symbols are linked to be available externally, but I thinkAtomicUsize
andAtomicPtr<_>
have the same layout.I have not addressed the other provenance issues for SGX.
cc @jethrogb @raoulstrackx @mzohreva