Title: [288778] branches/safari-613-branch/Source
Revision
288778
Author
[email protected]
Date
2022-01-28 19:27:40 -0800 (Fri, 28 Jan 2022)

Log Message

Cherry-pick r287961. rdar://problem/86282584

    [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):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287961 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/_javascript_Core/ChangeLog (288777 => 288778)


--- branches/safari-613-branch/Source/_javascript_Core/ChangeLog	2022-01-29 02:56:40 UTC (rev 288777)
+++ branches/safari-613-branch/Source/_javascript_Core/ChangeLog	2022-01-29 03:27:40 UTC (rev 288778)
@@ -1,3 +1,60 @@
+2022-01-28  Russell Epstein  <[email protected]>
+
+        Cherry-pick r287961. rdar://problem/86282584
+
+    [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):
+    
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287961 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-12  Mark Lam  <[email protected]>
+
+            [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-09  Sam Weinig  <[email protected]>
 
         Remove support for Direct2D

Modified: branches/safari-613-branch/Source/_javascript_Core/runtime/MachineContext.h (288777 => 288778)


--- branches/safari-613-branch/Source/_javascript_Core/runtime/MachineContext.h	2022-01-29 02:56:40 UTC (rev 288777)
+++ branches/safari-613-branch/Source/_javascript_Core/runtime/MachineContext.h	2022-01-29 03:27:40 UTC (rev 288778)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2017 Yusuke Suzuki <[email protected]>.
- * 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: branches/safari-613-branch/Source/WTF/ChangeLog (288777 => 288778)


--- branches/safari-613-branch/Source/WTF/ChangeLog	2022-01-29 02:56:40 UTC (rev 288777)
+++ branches/safari-613-branch/Source/WTF/ChangeLog	2022-01-29 03:27:40 UTC (rev 288778)
@@ -1,3 +1,58 @@
+2022-01-28  Russell Epstein  <[email protected]>
+
+        Cherry-pick r287961. rdar://problem/86282584
+
+    [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):
+    
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287961 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-12  Mark Lam  <[email protected]>
+
+            [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-24  Alan Coon  <[email protected]>
 
         Cherry-pick r288389. rdar://problem/85405320

Modified: branches/safari-613-branch/Source/WTF/wtf/PlatformRegisters.h (288777 => 288778)


--- branches/safari-613-branch/Source/WTF/wtf/PlatformRegisters.h	2022-01-29 02:56:40 UTC (rev 288777)
+++ branches/safari-613-branch/Source/WTF/wtf/PlatformRegisters.h	2022-01-29 03:27:40 UTC (rev 288778)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2017 Yusuke Suzuki <[email protected]>
- * 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: branches/safari-613-branch/Source/WTF/wtf/threads/Signals.cpp (288777 => 288778)


--- branches/safari-613-branch/Source/WTF/wtf/threads/Signals.cpp	2022-01-29 02:56:40 UTC (rev 288777)
+++ branches/safari-613-branch/Source/WTF/wtf/threads/Signals.cpp	2022-01-29 03:27:40 UTC (rev 288778)
@@ -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;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to