Skip to content

Pointer authentication (PAC) for clang#60

Open
mingxwa wants to merge 3 commits into
ngcpp:feature/v5from
mingxwa:user/mingxwa/pac-6
Open

Pointer authentication (PAC) for clang#60
mingxwa wants to merge 3 commits into
ngcpp:feature/v5from
mingxwa:user/mingxwa/pac-6

Conversation

@mingxwa

@mingxwa mingxwa commented Jul 15, 2026

Copy link
Copy Markdown
Member

NOTE: This is PR 1 of n for the upcoming v5 major release, targeting the feature/v5 branch. Once the feature branch is stable, it will be merged into main. This PR introduces critical ABI-breaking changes.

Changes

  • Added header file detail/facade_meta_traits.h, which introduces two new public APIs: compact_facade_meta_traits and flat_facade_meta_traits. These are metadata policy in v5. Currently only compact_facade_meta_traits is used from core.h. Later this will become a new dimension of facade, and the reference from core.h will be removed.
  • detail::invoker, detail::inline_meta_storage and detail::static_meta_storage are the implementation types of the meta traits. When PAC is enabled for compiler ABI, they will have the same level of security strength as virtual functions.
  • Added unit tests for PAC.
  • Added a new pipeline and benchmarking for PAC.

Documentation will be updated separately.

(CI is not triggered for the new feature branch (filed #61). Manual CI: https://github.com/mingxwa/proxy/actions/runs/29681375711)

Resolves #7

Comment thread include/proxy/v4/detail/core.h Outdated
public:
code_ptr() = default;
template <class F>
explicit code_ptr(const F& f) noexcept

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

constraint?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since it's an internal API (in namespace details), I don't think it's necessary to add constraints. If static_cast<O*>(f) won't compile, a hard error should be fine.

}
bool operator==(std::nullptr_t) const noexcept { return p_ == nullptr; }
template <class... Args>
decltype(auto) operator()(Args&&... args) const {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can this be optimized later for small objects? Maybe use the convert-to-function-ptr approach? (a user-defined type, if converts to function pointer, can be used like this obj(args) without defining operator())

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This type is just an equivalent to function pointers (see L99) in PAC mode. It is not intended for public use at all. But the idea to allow "proxy to decay to a function pointer" is a good one - I will implement it later, but not in this layer.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's only an efficiency concern. Passing arguments by reference (i.e., pointers in the calling convention) isn't ideal. Many libraries have some optimizations.

class meta_ptr {
public:
meta_ptr() = default;
explicit meta_ptr(const T* p) noexcept

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

constraint?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I believe no constraint is needed for this internal API either, but what constraints are you referring to assuming it would go public someday?

}
bool operator==(std::nullptr_t) const noexcept { return p_ == nullptr; }
template <class... Args>
decltype(auto) operator()(Args&&... args) const {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's only an efficiency concern. Passing arguments by reference (i.e., pointers in the calling convention) isn't ideal. Many libraries have some optimizations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants