Skip to content

[IRGen] Upstream pointer auth for value witness tables #74625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Jun 21, 2024

This makes Swift emit a signed pointer to the value witness table in type metadata.

The original change was done by Varun Gandhi.

@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan marked this pull request as ready for review June 27, 2024 15:23
@egorzhdan egorzhdan force-pushed the egorzhdan/upstream-ptrauth-vwt branch from b16d6d5 to 162ff58 Compare June 27, 2024 15:25
@egorzhdan egorzhdan requested a review from rjmccall June 27, 2024 15:25
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, but some small requests.


const auto &ptrAuthOpts = IGM.getOptions().PointerAuth;
if (ptrAuthOpts.FunctionPointers && ptrAuthOpts.FunctionPointers.getKind() ==
PointerAuthSchema::Kind::ARM8_3) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should really just be if (auto schema = IGM.getOptions().PointerAuth.ValueWitnessTable) {. We don't need to test function pointers or the kind of ptrauth we're doing in general; knowing that we have a request to sign vwtables is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this check is already performed in IRGen's setPointerAuthOptions. Removed it here.

auto *Clang =
static_cast<ClangImporter *>(IGM.Context.getClangModuleLoader());
auto &targetInfo = Clang->getTargetInfo();
auto intSize = Size::forBits(targetInfo.getIntWidth());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the patch seems to be trying to set a more accurate bound on the dereferenceable range of the vwtable. That's fine, but it should be a separate patch (and probably extracted into a nice helper function).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I removed this change from the patch.

@egorzhdan egorzhdan force-pushed the egorzhdan/upstream-ptrauth-vwt branch from 162ff58 to 30cd90c Compare June 28, 2024 12:59
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan requested a review from rjmccall June 28, 2024 13:00
Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last tweak, but otherwise LGTM

This makes Swift emit a signed pointer to the value witness table in type metadata.

The original change was done by Varun Gandhi.
@egorzhdan egorzhdan force-pushed the egorzhdan/upstream-ptrauth-vwt branch from 30cd90c to b22057e Compare July 1, 2024 15:38
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan requested a review from rjmccall July 1, 2024 15:38
@egorzhdan egorzhdan enabled auto-merge July 1, 2024 16:45
@egorzhdan egorzhdan merged commit 75a00ad into main Jul 1, 2024
4 of 5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/upstream-ptrauth-vwt branch July 1, 2024 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants