Skip to content
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

Tcs should not be a NonNull pointer #407

Closed
joboet opened this issue Sep 4, 2022 · 5 comments
Closed

Tcs should not be a NonNull pointer #407

joboet opened this issue Sep 4, 2022 · 5 comments

Comments

@joboet
Copy link

joboet commented Sep 4, 2022

TCSs may be located at logical address zero. Defining Tcs to be NonNull leads to bugs and even soundness issues that may be exposed to attackers. For instance, the internal abi::thread::current() function in the Rust standard library does not check for zero pointers and unconditionally returns a NonNull. If the TCS address is null, this leads to immediate undefined behaviour.

@jethrogb
Copy link
Member

jethrogb commented Sep 5, 2022

Not sure I agree? It's always possible to place things at address zero, but we generally adhere to the convention to not do that so that we can use null as a niche or sentinel value.

@joboet
Copy link
Author

joboet commented Sep 5, 2022

Ok. Then this is simply a bug in std (it should really check for null pointers here). Thanks!

@joboet joboet closed this as completed Sep 5, 2022
@jethrogb
Copy link
Member

jethrogb commented Sep 5, 2022

Not sure if it's necessary to do the check in std either, we can just define that TCSes are never placed at address 0?

@joboet
Copy link
Author

joboet commented Sep 5, 2022

No, since EENTER does not check if the address is null, only that it is well-aligned. Unconditionally casting the address to a NonNull (which is what std currently does) allows attackers to cause undefined behaviour within the enclave.

@jethrogb
Copy link
Member

jethrogb commented Sep 5, 2022

See discussion at rust-lang/rust#98391 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants