Skip to content

Commit e058535

Browse files
committed
[Runtime] Authenticate relative witness tables in _checkWitnessTableIsolation.
When SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES is set, witness table pointers are signed. We need to authenticate them before using them. rdar://148687148
1 parent 3f4519e commit e058535

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,18 @@ static bool _checkWitnessTableIsolation(
444444
llvm::ArrayRef<const void *> conditionalArgs,
445445
ConformanceExecutionContext &context
446446
) {
447-
// If there's no protocol conformance descriptor, do nothing.
447+
#if SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES && SWIFT_PTRAUTH
448+
wtable = ptrauth_auth_data(
449+
wtable, ptrauth_key_process_independent_data,
450+
SpecialPointerAuthDiscriminators::RelativeProtocolWitnessTable);
451+
auto description = lookThroughOptionalConditionalWitnessTable(
452+
reinterpret_cast<const RelativeWitnessTable *>(wtable))
453+
->getDescription();
454+
#else
448455
auto description = wtable->getDescription();
456+
#endif
457+
458+
// If there's no protocol conformance descriptor, do nothing.
449459
if (!description)
450460
return false;
451461

0 commit comments

Comments
 (0)