Skip to content

Commit 7ff7d12

Browse files
committed
[JSC] Integrity::isSanePointer() should check alignment for typed pointers
https://bugs.webkit.org/show_bug.cgi?id=319215 Reviewed by Yusuke Suzuki. A sane pointer to a T must be aligned like a T. Add a typed overload that checks this on top of the existing canonical-address check. The void* overload keeps its old behavior for callers probing arbitrary addresses (e.g. the disassembler); all typed call sites pick up the stricter check without change. This catches the value seen in a real crash: a concurrent DFG thread read HeapCell::zap() residue (0x21700000002) out of a freshly reused JSString and dereferenced it as a StringImpl*, because it passed every existing check in speculationFromCell() (oven-sh#285). The reordering race itself is fixed in bug 319213; this hardens the checks that bug 216638 added as a mitigation for bad pointers from profiling data. * Source/JavaScriptCore/tools/Integrity.h: (JSC::Integrity::isSanePointer): Canonical link: https://commits.webkit.org/317118@main
1 parent 904ba51 commit 7ff7d12

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎Source/JavaScriptCore/tools/Integrity.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ ALWAYS_INLINE bool isSanePointer(const void* pointer)
115115
#endif // CPU(ADDRESS64)
116116
}
117117

118+
template<typename T>
119+
ALWAYS_INLINE bool isSanePointer(const T* pointer)
120+
{
121+
return isSanePointer(static_cast<const void*>(pointer)) && !(std::bit_cast<uintptr_t>(pointer) & (alignof(T) - 1));
122+
}
123+
118124
#if USE(JSVALUE64)
119125

120126
class Analyzer {

0 commit comments

Comments
 (0)