- Revision
- 287961
- Author
- mark....@apple.com
- Date
- 2022-01-12 16:36:58 -0800 (Wed, 12 Jan 2022)
Log Message
[Re-landing] Update hashThreadState() to exclude __opaque_flags.
https://bugs.webkit.org/show_bug.cgi?id=235081
rdar://86282584
Reviewed by Keith Miller.
Source/_javascript_Core:
Removed some unused code.
* runtime/MachineContext.h:
(JSC::MachineContext::stackPointer):
(JSC::MachineContext::framePointer):
(JSC::MachineContext::instructionPointer):
(JSC::MachineContext::linkRegister):
(JSC::MachineContext::setStackPointer): Deleted.
(JSC::MachineContext::setFramePointer): Deleted.
(JSC::MachineContext::setLinkRegister): Deleted.
Source/WTF:
The __opaque_flags may be used by the OS, and may be altered without our knowledge.
Hence, our hash should not include the __opaque_flags field.
Also remove some unused code.
* wtf/PlatformRegisters.h:
* wtf/threads/Signals.cpp:
(WTF::hashThreadState):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (287960 => 287961)
--- trunk/Source/_javascript_Core/ChangeLog 2022-01-13 00:30:40 UTC (rev 287960)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-01-13 00:36:58 UTC (rev 287961)
@@ -1,3 +1,22 @@
+2022-01-12 Mark Lam <mark....@apple.com>
+
+ [Re-landing] Update hashThreadState() to exclude __opaque_flags.
+ https://bugs.webkit.org/show_bug.cgi?id=235081
+ rdar://86282584
+
+ Reviewed by Keith Miller.
+
+ Removed some unused code.
+
+ * runtime/MachineContext.h:
+ (JSC::MachineContext::stackPointer):
+ (JSC::MachineContext::framePointer):
+ (JSC::MachineContext::instructionPointer):
+ (JSC::MachineContext::linkRegister):
+ (JSC::MachineContext::setStackPointer): Deleted.
+ (JSC::MachineContext::setFramePointer): Deleted.
+ (JSC::MachineContext::setLinkRegister): Deleted.
+
2022-01-12 Commit Queue <commit-qu...@webkit.org>
Unreviewed, reverting r287912.
Modified: trunk/Source/_javascript_Core/runtime/MachineContext.h (287960 => 287961)
--- trunk/Source/_javascript_Core/runtime/MachineContext.h 2022-01-13 00:30:40 UTC (rev 287960)
+++ trunk/Source/_javascript_Core/runtime/MachineContext.h 2022-01-13 00:36:58 UTC (rev 287961)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 Yusuke Suzuki <utatane....@gmail.com>.
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -39,11 +39,8 @@
template<typename T = void*> T stackPointer(const PlatformRegisters&);
#if OS(WINDOWS) || HAVE(MACHINE_CONTEXT)
-template<typename T = void*> void setStackPointer(PlatformRegisters&, T);
template<typename T = void*> T framePointer(const PlatformRegisters&);
-template<typename T = void*> void setFramePointer(PlatformRegisters&, T);
inline MacroAssemblerCodePtr<PlatformRegistersLRPtrTag> linkRegister(const PlatformRegisters&);
-inline void setLinkRegister(PlatformRegisters&, MacroAssemblerCodePtr<CFunctionPtrTag>);
inline std::optional<MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>> instructionPointer(const PlatformRegisters&);
inline void setInstructionPointer(PlatformRegisters&, MacroAssemblerCodePtr<CFunctionPtrTag>);
@@ -67,11 +64,8 @@
#endif // !USE(PLATFORM_REGISTERS_WITH_PROFILE)
template<typename T = void*> T stackPointer(const mcontext_t&);
-template<typename T = void*> void setStackPointer(mcontext_t&, T);
template<typename T = void*> T framePointer(const mcontext_t&);
-template<typename T = void*> void setFramePointer(mcontext_t&, T);
inline MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> instructionPointer(const mcontext_t&);
-inline void setInstructionPointer(mcontext_t&, MacroAssemblerCodePtr<CFunctionPtrTag>);
template<size_t N> void*& argumentPointer(mcontext_t&);
template<size_t N> void* argumentPointer(const mcontext_t&);
@@ -150,19 +144,6 @@
#endif
}
-template<typename T>
-inline void setStackPointer(PlatformRegisters& regs, T value)
-{
-#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
- assertIsNotTagged(bitwise_cast<void*>(value));
- WTF_WRITE_PLATFORM_REGISTERS_SP_WITH_PROFILE(regs, bitwise_cast<void*>(value));
-#elif USE(DARWIN_REGISTER_MACROS)
- __darwin_arm_thread_state64_set_sp(regs, value);
-#else
- stackPointerImpl(regs) = bitwise_cast<void*>(value);
-#endif
-}
-
#else // not OS(WINDOWS) || HAVE(MACHINE_CONTEXT)
template<typename T>
@@ -229,19 +210,6 @@
return bitwise_cast<T>(stackPointerImpl(const_cast<mcontext_t&>(machineContext)));
#endif
}
-
-template<typename T>
-inline void setStackPointer(mcontext_t& machineContext, T value)
-{
-#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
- assertIsNotTagged(bitwise_cast<void*>(value));
- WTF_WRITE_MACHINE_CONTEXT_SP_WITH_PROFILE(machineContext, bitwise_cast<void*>(value));
-#elif USE(DARWIN_REGISTER_MACROS)
- return setStackPointer(machineContext->__ss, value);
-#else
- stackPointerImpl(machineContext) = bitwise_cast<void*>(value);
-#endif
-}
#endif // HAVE(MACHINE_CONTEXT)
@@ -311,17 +279,6 @@
return bitwise_cast<T>(framePointerImpl(const_cast<PlatformRegisters&>(regs)));
#endif
}
-
-template<typename T>
-inline void setFramePointer(PlatformRegisters& regs, T value)
-{
-#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
- assertIsNotTagged(bitwise_cast<void*>(value));
- WTF_WRITE_PLATFORM_REGISTERS_FP_WITH_PROFILE(regs, bitwise_cast<void*>(value));
-#else
- framePointerImpl(regs) = bitwise_cast<void*>(value);
-#endif
-}
#endif // OS(WINDOWS) || HAVE(MACHINE_CONTEXT)
@@ -384,17 +341,6 @@
return bitwise_cast<T>(framePointerImpl(const_cast<mcontext_t&>(machineContext)));
#endif
}
-
-template<typename T>
-inline void setFramePointer(mcontext_t& machineContext, T value)
-{
-#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
- assertIsNotTagged(bitwise_cast<void*>(value));
- WTF_WRITE_MACHINE_CONTEXT_FP_WITH_PROFILE(machineContext, bitwise_cast<void*>(value));
-#else
- framePointerImpl(machineContext) = bitwise_cast<void*>(value);
-#endif
-}
#endif // HAVE(MACHINE_CONTEXT)
@@ -541,17 +487,6 @@
return MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(value);
#endif
}
-
-inline void setInstructionPointer(mcontext_t& machineContext, MacroAssemblerCodePtr<CFunctionPtrTag> value)
-{
-#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
- WTF_WRITE_MACHINE_CONTEXT_PC_WITH_PROFILE(machineContext, value.executableAddress());
-#elif USE(DARWIN_REGISTER_MACROS)
- setInstructionPointer(machineContext->__ss, value);
-#else
- instructionPointerImpl(machineContext) = value.executableAddress();
-#endif
-}
#endif // HAVE(MACHINE_CONTEXT)
@@ -568,15 +503,6 @@
#endif
return MacroAssemblerCodePtr<PlatformRegistersLRPtrTag>(value);
}
-
-inline void setLinkRegister(PlatformRegisters& regs, MacroAssemblerCodePtr<CFunctionPtrTag> value)
-{
-#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
- WTF_WRITE_PLATFORM_REGISTERS_PC_WITH_PROFILE(regs, value.executableAddress());
-#else
- __darwin_arm_thread_state64_set_lr_fptr(regs, value.executableAddress());
-#endif
-}
#endif // OS(DARWIN) && __DARWIN_UNIX03 && CPU(ARM64)
#if HAVE(MACHINE_CONTEXT)
Modified: trunk/Source/WTF/ChangeLog (287960 => 287961)
--- trunk/Source/WTF/ChangeLog 2022-01-13 00:30:40 UTC (rev 287960)
+++ trunk/Source/WTF/ChangeLog 2022-01-13 00:36:58 UTC (rev 287961)
@@ -1,3 +1,20 @@
+2022-01-12 Mark Lam <mark....@apple.com>
+
+ [Re-landing] Update hashThreadState() to exclude __opaque_flags.
+ https://bugs.webkit.org/show_bug.cgi?id=235081
+ rdar://86282584
+
+ Reviewed by Keith Miller.
+
+ The __opaque_flags may be used by the OS, and may be altered without our knowledge.
+ Hence, our hash should not include the __opaque_flags field.
+
+ Also remove some unused code.
+
+ * wtf/PlatformRegisters.h:
+ * wtf/threads/Signals.cpp:
+ (WTF::hashThreadState):
+
2022-01-12 Elliott Williams <e...@apple.com>
[Xcode] Configure each project for the legacy build system
Modified: trunk/Source/WTF/wtf/PlatformRegisters.h (287960 => 287961)
--- trunk/Source/WTF/wtf/PlatformRegisters.h 2022-01-13 00:30:40 UTC (rev 287960)
+++ trunk/Source/WTF/wtf/PlatformRegisters.h 2022-01-13 00:36:58 UTC (rev 287961)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 Yusuke Suzuki <utatane....@gmail.com>
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -119,21 +119,12 @@
#define WTF_READ_PLATFORM_REGISTERS_SP_WITH_PROFILE(regs) \
reinterpret_cast<void*>(arm_thread_state64_get_sp(const_cast<PlatformRegisters&>(regs)))
-#define WTF_WRITE_PLATFORM_REGISTERS_SP_WITH_PROFILE(regs, newPointer) \
- arm_thread_state64_set_sp(regs, reinterpret_cast<uintptr_t>(newPointer))
-
#define WTF_READ_PLATFORM_REGISTERS_FP_WITH_PROFILE(regs) \
reinterpret_cast<void*>(arm_thread_state64_get_fp(const_cast<PlatformRegisters&>(regs)))
-#define WTF_WRITE_PLATFORM_REGISTERS_FP_WITH_PROFILE(regs, newPointer) \
- arm_thread_state64_set_fp(regs, reinterpret_cast<uintptr_t>(newPointer))
-
#define WTF_READ_PLATFORM_REGISTERS_LR_WITH_PROFILE(regs) \
threadStateLRInternal(const_cast<PlatformRegisters&>(regs))
-#define WTF_WRITE_PLATFORM_REGISTERS_LR_WITH_PROFILE(regs, newPointer) \
- arm_thread_state64_set_lr_fptr(regs, newPointer)
-
#define WTF_READ_PLATFORM_REGISTERS_PC_WITH_PROFILE(regs) \
threadStatePCInternal(const_cast<PlatformRegisters&>(regs))
@@ -143,24 +134,12 @@
#define WTF_READ_MACHINE_CONTEXT_SP_WITH_PROFILE(machineContext) \
WTF_READ_PLATFORM_REGISTERS_SP_WITH_PROFILE(machineContext->__ss)
-#define WTF_WRITE_MACHINE_CONTEXT_SP_WITH_PROFILE(machineContext, newPointer) \
- WTF_WRITE_PLATFORM_REGISTERS_SP_WITH_PROFILE(machineContext->__ss, newPointer)
-
#define WTF_READ_MACHINE_CONTEXT_FP_WITH_PROFILE(machineContext) \
WTF_READ_PLATFORM_REGISTERS_FP_WITH_PROFILE(machineContext->__ss)
-#define WTF_WRITE_MACHINE_CONTEXT_FP_WITH_PROFILE(machineContext, newPointer) \
- WTF_WRITE_PLATFORM_REGISTERS_FP_WITH_PROFILE(machineContext->__ss, newPointer)
-
-#define WTF_WRITE_MACHINE_CONTEXT_LR_WITH_PROFILE(machineContext, newPointer) \
- WTF_WRITE_PLATFORM_REGISTERS_LR_WITH_PROFILE(machineContext->__ss, newPointer)
-
#define WTF_READ_MACHINE_CONTEXT_PC_WITH_PROFILE(machineContext) \
WTF_READ_PLATFORM_REGISTERS_PC_WITH_PROFILE(machineContext->__ss)
-#define WTF_WRITE_MACHINE_CONTEXT_PC_WITH_PROFILE(machineContext, newPointer) \
- WTF_WRITE_PLATFORM_REGISTERS_PC_WITH_PROFILE(machineContext->__ss, newPointer)
-
#endif // USE(PLATFORM_REGISTERS_WITH_PROFILE)
using WTF::PlatformRegisters;
Modified: trunk/Source/WTF/wtf/threads/Signals.cpp (287960 => 287961)
--- trunk/Source/WTF/wtf/threads/Signals.cpp 2022-01-13 00:30:40 UTC (rev 287960)
+++ trunk/Source/WTF/wtf/threads/Signals.cpp 2022-01-13 00:36:58 UTC (rev 287961)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -172,10 +172,14 @@
const uintptr_t* srcPtr = reinterpret_cast<const uintptr_t*>(source);
- for (size_t i = 0; i < threadStateSizeInPointers; ++i) {
+ // Exclude the __opaque_flags field which is reserved for OS use.
+ // __opaque_flags is at the end of the payload.
+ for (size_t i = 0; i < threadStateSizeInPointers - 1; ++i) {
if (i != threadStatePCPointerIndex)
hash = ptrauth_sign_generic_data(srcPtr[i], hash);
}
+ const uint32_t* cpsrPtr = reinterpret_cast<const uint32_t*>(&srcPtr[threadStateSizeInPointers - 1]);
+ hash = ptrauth_sign_generic_data(static_cast<uint64_t>(*cpsrPtr), hash);
return hash;
}