[compiler-rt] [compiler-rt][ubsan][nfc-ish] Fix a type conversion bug (PR #100665)
Alan Zhao via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 25 15:40:54 PDT 2024
https://github.com/alanzhao1 created https://github.com/llvm/llvm-project/pull/100665
With https://github.com/llvm/llvm-project/pull/100483, if the inline asm version of `ptrauth_strip` is used instead of the builtin, the inline asm implementation will return an unsigned long, causing an incompatible pointer conversion issue.
>From b2adefcb692b950616b42939d2dc69a47a3355f9 Mon Sep 17 00:00:00 2001
From: Alan Zhao <ayzhao at google.com>
Date: Thu, 25 Jul 2024 15:36:37 -0700
Subject: [PATCH] [compiler-rt][ubsan][nfc-ish] Fix a type conversion bug
With https://github.com/llvm/llvm-project/pull/100483, if the inline asm
version of `ptrauth_strip` is used instead of the builtin, the inline
asm implementation will return an unsigned long, causing an incompatible
pointer conversion issue.
---
compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp b/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp
index 15788574dd995..7cc57268d40da 100644
--- a/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp
+++ b/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp
@@ -207,7 +207,8 @@ struct VtablePrefix {
std::type_info *TypeInfo;
};
VtablePrefix *getVtablePrefix(void *Vtable) {
- Vtable = ptrauth_strip(Vtable, ptrauth_key_cxx_vtable_pointer);
+ Vtable = reinterpret_cast<void *>(
+ ptrauth_strip(Vtable, ptrauth_key_cxx_vtable_pointer));
VtablePrefix *Vptr = reinterpret_cast<VtablePrefix*>(Vtable);
VtablePrefix *Prefix = Vptr - 1;
if (!IsAccessibleMemoryRange((uptr)Prefix, sizeof(VtablePrefix)))
More information about the llvm-commits
mailing list