Skip to content

Commit bfe219f

Browse files
Merge pull request #34470 from nate-chandler/concurrency/irgen/nonfunction-field-ptrauth
[Async CC] Ptrauth for parent context.
2 parents f434edc + c502e97 commit bfe219f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ struct PointerAuthOptions : clang::PointerAuthOptions {
137137

138138
/// Resilient class stub initializer callbacks.
139139
PointerAuthSchema ResilientClassStubInitCallbacks;
140+
141+
/// The parent async context stored within a child async context.
142+
PointerAuthSchema AsyncContextParent;
140143
};
141144

142145
enum class JITDebugArtifact : unsigned {

lib/IRGen/GenCall.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2246,8 +2246,16 @@ class AsyncCallEmission final : public CallEmission {
22462246
// Set caller info into the context.
22472247
{ // caller context
22482248
Explosion explosion;
2249-
explosion.add(IGF.getAsyncContext());
22502249
auto fieldLayout = layout.getParentLayout();
2250+
auto *context = IGF.getAsyncContext();
2251+
if (auto schema = IGF.IGM.getOptions().PointerAuth.AsyncContextParent) {
2252+
Address fieldAddr =
2253+
fieldLayout.project(IGF, this->context, /*offsets*/ llvm::None);
2254+
auto authInfo = PointerAuthInfo::emit(
2255+
IGF, schema, fieldAddr.getAddress(), PointerAuthEntity());
2256+
context = emitPointerAuthSign(IGF, context, authInfo);
2257+
}
2258+
explosion.add(context);
22512259
saveValue(fieldLayout, explosion, isOutlined);
22522260
}
22532261
{ // caller executor

lib/IRGen/IRGen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,10 @@ static void setPointerAuthOptions(PointerAuthOptions &opts,
688688
opts.ResilientClassStubInitCallbacks =
689689
PointerAuthSchema(codeKey, /*address*/ true, Discrimination::Constant,
690690
SpecialPointerAuthDiscriminators::ResilientClassStubInitCallback);
691+
692+
opts.AsyncContextParent =
693+
PointerAuthSchema(codeKey, /*address*/ true, Discrimination::Constant,
694+
SpecialPointerAuthDiscriminators::AsyncContextParent);
691695
}
692696

693697
std::unique_ptr<llvm::TargetMachine>

0 commit comments

Comments
 (0)