From b04c7d4c3b63b2d6097949f347bb3ec6fe342430 Mon Sep 17 00:00:00 2001 From: Mike Ash Date: Wed, 28 May 2025 21:05:09 -0400 Subject: [PATCH] [6.2][Runtime] Add ptrauth attribute to TargetGlobalActorReference conformance pointer. When the TargetGlobalActorReference conformance is an indirect pointer, the indirect pointer is signed when ptrauth is enabled. rdar://151945202 (cherry picked from commit ea785c191cd5a49947f784707b0873b54417fdee) --- include/swift/ABI/Metadata.h | 13 ++++++++++++- include/swift/Runtime/Config.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/swift/ABI/Metadata.h b/include/swift/ABI/Metadata.h index 52d6355ebb289..d2a14e21ca3bf 100644 --- a/include/swift/ABI/Metadata.h +++ b/include/swift/ABI/Metadata.h @@ -2792,11 +2792,22 @@ using ResilientWitnessesHeader = TargetResilientWitnessesHeader; /// global actor protocol. template struct TargetGlobalActorReference { +private: + using SignedDescriptorPointer = + const TargetProtocolConformanceDescriptor + *__ptrauth_swift_protocol_conformance_descriptor; + +public: /// The type of the global actor. RelativeDirectPointer type; /// The conformance of the global actor to the GlobalActor protocol. - TargetRelativeProtocolConformanceDescriptorPointer conformance; + RelativeIndirectablePointer< + const TargetProtocolConformanceDescriptor, + /*nullable*/ false, + /*offset*/ int32_t, + /*indirect type*/ SignedDescriptorPointer> + conformance; }; /// Describes the context of a protocol conformance that is relevant when diff --git a/include/swift/Runtime/Config.h b/include/swift/Runtime/Config.h index 2b50bf4429443..e7c125b5a4b3a 100644 --- a/include/swift/Runtime/Config.h +++ b/include/swift/Runtime/Config.h @@ -272,6 +272,9 @@ extern uintptr_t __COMPATIBILITY_LIBRARIES_CANNOT_CHECK_THE_IS_SWIFT_BIT_DIRECTL #define __ptrauth_swift_type_descriptor \ __ptrauth(ptrauth_key_process_independent_data, 1, \ SpecialPointerAuthDiscriminators::TypeDescriptor) +#define __ptrauth_swift_protocol_conformance_descriptor \ + __ptrauth(ptrauth_key_process_independent_data, 1, \ + SpecialPointerAuthDiscriminators::ProtocolConformanceDescriptor) #define __ptrauth_swift_dynamic_replacement_key \ __ptrauth(ptrauth_key_process_independent_data, 1, \ SpecialPointerAuthDiscriminators::DynamicReplacementKey) @@ -365,6 +368,7 @@ extern uintptr_t __COMPATIBILITY_LIBRARIES_CANNOT_CHECK_THE_IS_SWIFT_BIT_DIRECTL #define __ptrauth_swift_runtime_function_entry_strip(__fn) (__fn) #define __ptrauth_swift_heap_object_destructor #define __ptrauth_swift_type_descriptor +#define __ptrauth_swift_protocol_conformance_descriptor #define __ptrauth_swift_nonunique_extended_existential_type_shape #define __ptrauth_swift_dynamic_replacement_key #define swift_ptrauth_sign_opaque_read_resume_function(__fn, __buffer) (__fn)