Skip to content

[Async CC] Ptrauth for parent context. #34470

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/swift/AST/IRGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ struct PointerAuthOptions : clang::PointerAuthOptions {

/// Resilient class stub initializer callbacks.
PointerAuthSchema ResilientClassStubInitCallbacks;

/// The parent async context stored within a child async context.
PointerAuthSchema AsyncContextParent;
};

enum class JITDebugArtifact : unsigned {
Expand Down
10 changes: 9 additions & 1 deletion lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2246,8 +2246,16 @@ class AsyncCallEmission final : public CallEmission {
// Set caller info into the context.
{ // caller context
Explosion explosion;
explosion.add(IGF.getAsyncContext());
auto fieldLayout = layout.getParentLayout();
auto *context = IGF.getAsyncContext();
if (auto schema = IGF.IGM.getOptions().PointerAuth.AsyncContextParent) {
Address fieldAddr =
fieldLayout.project(IGF, this->context, /*offsets*/ llvm::None);
auto authInfo = PointerAuthInfo::emit(
IGF, schema, fieldAddr.getAddress(), PointerAuthEntity());
context = emitPointerAuthSign(IGF, context, authInfo);
}
explosion.add(context);
saveValue(fieldLayout, explosion, isOutlined);
}
{ // caller executor
Expand Down
4 changes: 4 additions & 0 deletions lib/IRGen/IRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,10 @@ static void setPointerAuthOptions(PointerAuthOptions &opts,
opts.ResilientClassStubInitCallbacks =
PointerAuthSchema(codeKey, /*address*/ true, Discrimination::Constant,
SpecialPointerAuthDiscriminators::ResilientClassStubInitCallback);

opts.AsyncContextParent =
PointerAuthSchema(codeKey, /*address*/ true, Discrimination::Constant,
SpecialPointerAuthDiscriminators::AsyncContextParent);
}

std::unique_ptr<llvm::TargetMachine>
Expand Down