Changeset 138293 in webkit
- Timestamp:
- Dec 20, 2012, 1:35:56 PM (12 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r138194 r138293 1 2012-12-20 Oliver Hunt <oliver@apple.com> 2 3 Harden pointers in FastMalloc's singly linked list implementation 4 https://bugs.webkit.org/show_bug.cgi?id=105571 5 6 Reviewed by Gavin Barraclough. 7 8 Add simple xor based hardening of the next pointer in the 9 fast malloc singly linked list implementation. We rely on 10 ASLR to introduce the address randomness we want for the mask. 11 Happily this produces a very low cost random value to use. 12 13 * wtf/FastMalloc.cpp: 14 (WTF): 15 (WTF::SLL_Next): 16 (WTF::SLL_SetNext): 17 1 18 2012-12-19 Oliver Hunt <oliver@apple.com> 2 19 -
trunk/Source/WTF/wtf/FastMalloc.cpp
r134493 r138293 101 101 #endif 102 102 103 // Harden the pointers stored in the TCMalloc linked lists 104 #if COMPILER(GCC) 105 #define ENABLE_TCMALLOC_HARDENING 1 106 #endif 107 103 108 // Use a background thread to periodically scavenge memory to release back to the system 104 109 #if PLATFORM(IOS) … … 496 501 #define MESSAGE LOG_ERROR 497 502 #define CHECK_CONDITION ASSERT 503 504 #if ENABLE(TCMALLOC_HARDENING) 505 /* 506 * To make it harder to exploit use-after free style exploits 507 * we mask the addresses we put into our linked lists with the 508 * address of kLLHardeningMask. Due to ASLR the address of 509 * kLLHardeningMask should be sufficiently randomized to make direct 510 * freelist manipulation much more difficult. 511 */ 512 static const char kLLHardeningMask = 0; 513 #define MASK_PTR(ptr) (reinterpret_cast<typeof(ptr)>(reinterpret_cast<uintptr_t>(ptr)^reinterpret_cast<uintptr_t>(&kLLHardeningMask))) 514 #define UNMASK_PTR(ptr) (reinterpret_cast<typeof(ptr)>(reinterpret_cast<uintptr_t>(ptr)^reinterpret_cast<uintptr_t>(&kLLHardeningMask))) 515 #else 516 #define MASK_PTR(ptr) (ptr) 517 #define UNMASK_PTR(ptr) (ptr) 518 #endif 519 498 520 499 521 //------------------------------------------------------------------- … … 663 685 664 686 static inline void *SLL_Next(void *t) { 665 return *(reinterpret_cast<void**>(t));687 return UNMASK_PTR(*(reinterpret_cast<void**>(t))); 666 688 } 667 689 668 690 static inline void SLL_SetNext(void *t, void *n) { 669 *(reinterpret_cast<void**>(t)) = n;691 *(reinterpret_cast<void**>(t)) = MASK_PTR(n); 670 692 } 671 693
Note:
See TracChangeset
for help on using the changeset viewer.