[metadata prespecialization] Ptrauth for compared protocol conformances.

Two protocol conformance descriptors are passed to
swift_compareProtocolConformanceDecriptors from generic metadata
accessors when there is a canonical prespecialization and one of the
generic arguments has a protocol requirement.

Previously, the descriptors were incorrectly being passed without
ptrauth processing: one from the witness table in the arguments that are
passed in to the accessor and one known statically.

Here, the descriptor in the witness table is authed using the
ProtocolConformanceDescriptor schema.  Then, both descriptors are signed
using the ProtocolConformanceDescriptorsAsArguments schema.  Finally, in
the runtime function, the descriptors are authed.
This commit is contained in:
Nate Chandler
2020-07-09 09:50:00 -07:00
parent a5f0069b8d
commit 2701a0809b
7 changed files with 51 additions and 1 deletions

View File

@@ -4996,6 +4996,11 @@ const WitnessTable *swift::swift_getAssociatedConformanceWitness(
bool swift::swift_compareProtocolConformanceDescriptors(
const ProtocolConformanceDescriptor *lhs,
const ProtocolConformanceDescriptor *rhs) {
lhs = swift_auth_data_non_address(
lhs, SpecialPointerAuthDiscriminators::ProtocolConformanceDescriptor);
rhs = swift_auth_data_non_address(
rhs, SpecialPointerAuthDiscriminators::ProtocolConformanceDescriptor);
return MetadataCacheKey::compareProtocolConformanceDescriptors(lhs, rhs) == 0;
}