Skip to content

Initial support for ptrauth qualified function pointers in C #63204

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 5 commits into from
Jan 26, 2023

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Jan 25, 2023

This PR adds support for ptrauth qualified non-address discriminated field function pointers in C. It consists of changes in SILGen and IRGen in order to support code generation of such pointers. This can be enabled by setting the flag -enable-import-ptrauth-field-function-pointers.

Summary of changes:

  • Use QualType::getPointerAuth() on clang::ValueDecl::getType() to get pointer auth qualifier info from clang
  • In SILGen, generate begin_access [signed]/end_access around access to signed field function pointers
  • In IRGen, generate ptrauth.auth builtin before reading and ptrauth.sign for writing in to signed field function pointers using a shadow stack slot for translation.

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@xedin xedin removed their request for review January 25, 2023 18:53
Copy link
Contributor

@aschwaighofer aschwaighofer left a comment

Choose a reason for hiding this comment

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

LGTM!

@meg-gupta
Copy link
Contributor Author

@swift-ci test and merge

This will be used for supporting imported c function pointers with custom __ptrauth qualifier.
…d field function pointers

Access to such pointers are protected by begin_access [signed]/end_access.
Generate code to auth/sign them before access.
@meg-gupta
Copy link
Contributor Author

@swift-ci test and merge

@meg-gupta
Copy link
Contributor Author

@swift-ci test macOS platform

@swift-ci swift-ci merged commit 281088e into swiftlang:main Jan 26, 2023
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.

3 participants