Skip to content

Commit 3a987ca

Browse files
committed
Add verification for projections from structs with ptrauth qualified fields
1 parent e637dde commit 3a987ca

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,6 +3271,10 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
32713271
EI->getForwardingOwnershipKind() == OwnershipKind::Guaranteed,
32723272
"invalid forwarding ownership kind on tuple_extract instruction");
32733273

3274+
require(!EI->getStructDecl()->isNonTrivialPtrAuth(),
3275+
"Imported structs with ptrauth qualified fields should not be "
3276+
"promoted to a value");
3277+
32743278
if (EI->getModule().getStage() != SILStage::Lowered) {
32753279
SILType loweredFieldTy = operandTy.getFieldType(
32763280
EI->getField(), F.getModule(), F.getTypeExpansionContext());
@@ -3318,6 +3322,14 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
33183322
require(EI->getField()->getDeclContext() == sd,
33193323
"struct_element_addr field is not a member of the struct");
33203324

3325+
if (EI->getStructDecl()->isNonTrivialPtrAuth()) {
3326+
for (auto *use : EI->getUses()) {
3327+
auto *bai = dyn_cast<BeginAccessInst>(use->getUser());
3328+
require(bai && bai->getEnforcement() == SILAccessEnforcement::Signed,
3329+
"Access to ptrauth qualified fields should be scoped with "
3330+
"begin_access [signed]/end_access");
3331+
}
3332+
}
33213333
if (EI->getModule().getStage() != SILStage::Lowered) {
33223334
SILType loweredFieldTy = operandTy.getFieldType(
33233335
EI->getField(), F.getModule(), F.getTypeExpansionContext());

0 commit comments

Comments
 (0)