Skip to content

Cherry-pick the enforce_tcb attribute. #2335

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

Merged

Conversation

haoNoQ
Copy link

@haoNoQ haoNoQ commented Jan 14, 2021

Introduce a function attribute 'enforce_tcb' that prevents the function
from calling other functions without the same attribute. This allows
isolating code that's considered to be somehow privileged so that it could not
use its privileges to exhibit arbitrary behavior.

Introduce an on-by-default warning '-Wtcb-enforcement' that warns
about violations of the above rule.

Introduce a function attribute 'enforce_tcb_leaf' that suppresses
the new warning within the function it is attached to. Such leaf functions
may implement common functionality between the trusted and the untrusted code
but they require extra careful audit with respect to their capabilities.

Fixes after a revert in 419ef38:
Fix a test.
Add workaround for GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67274).
Attribute the patch appropriately!

Differential Revision: https://reviews.llvm.org/D91898

(cherry picked from commit 35c9baa)

Introduce a function attribute 'enforce_tcb' that prevents the function
from calling other functions without the same attribute. This allows
isolating code that's considered to be somehow privileged so that it could not
use its privileges to exhibit arbitrary behavior.

Introduce an on-by-default warning '-Wtcb-enforcement' that warns
about violations of the above rule.

Introduce a function attribute 'enforce_tcb_leaf' that suppresses
the new warning within the function it is attached to. Such leaf functions
may implement common functionality between the trusted and the untrusted code
but they require extra careful audit with respect to their capabilities.

Fixes after a revert in 419ef38:
Fix a test.
Add workaround for GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67274).
Attribute the patch appropriately!

Differential Revision: https://reviews.llvm.org/D91898

(cherry picked from commit 35c9baa)
@haoNoQ
Copy link
Author

haoNoQ commented Jan 14, 2021

@swift-ci test

@SavchenkoValeriy
Copy link

Uh-oh, I kinda missed the resolution of this change getting reverted, can you please point it out?

@haoNoQ
Copy link
Author

haoNoQ commented Jan 14, 2021

This is already the fixed patch that was re-committed after the revert. I fixed the test and worked around the gcc bug on one of the buildbots. I didn't cherry-pick the reverted patch (c163aae) or the revert commit (419ef38).

@haoNoQ
Copy link
Author

haoNoQ commented Jan 14, 2021

The fix for the gcc error is here. I had to say this->Diag instead of just Diag because gcc before 7.1 is buggy.

Copy link

@SavchenkoValeriy SavchenkoValeriy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
(Let's still wait for the Mac bot)

@haoNoQ haoNoQ merged commit 6a76fcc into swiftlang:apple/stable/20210107 Jan 14, 2021
@haoNoQ haoNoQ deleted the enforce-tcb-cherrypick branch January 14, 2021 17:01
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

Successfully merging this pull request may close these issues.

3 participants