[libcxx-commits] [libcxx] [PAC] Make __is_function_overridden pauth-aware on ELF platforms (PR #107498)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 9 11:39:51 PDT 2024


================
@@ -116,6 +116,14 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no
   uintptr_t __end   = reinterpret_cast<uintptr_t>(&__stop___lcxx_override);
   uintptr_t __ptr   = reinterpret_cast<uintptr_t>(__fptr);
 
+#  if __has_feature(ptrauth_calls)
+  // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular,
+  // we must NOT pass a function pointer, otherwise we will strip the function pointer, and then attempt
+  // to authenticate and re-sign it when casting it to a uintptr_t again, which will fail because we just
+  // stripped the function pointer.
----------------
ldionne wrote:

I would either copy the comment as-is (including the rdar link) or leave the comment out entirely and say e.g. `see above`.

Otherwise, we risk the code being refactored and the link being dropped, and while I know that these links are not universally popular, they do provide additional (often important) context for bugs. In this case I made a clear effort to explain what was going on and why so that all _necessary_ information was available upstream, however the link does still provide additional useful context for why this is written in that way.

TLDR: I suggest you just avoid duplicating the comment.

https://github.com/llvm/llvm-project/pull/107498


More information about the libcxx-commits mailing list