Changeset 239787 in webkit
- Timestamp:
- Jan 9, 2019, 2:45:06 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/JavaScriptCore/ChangeLog ¶
r239774 r239787 1 2019-01-09 Mark Lam <mark.lam@apple.com> 2 3 Gigacage disabling checks should handle the GIGACAGE_ALLOCATION_CAN_FAIL case properly. 4 https://bugs.webkit.org/show_bug.cgi?id=193292 5 <rdar://problem/46485450> 6 7 Reviewed by Yusuke Suzuki. 8 9 * runtime/VM.h: 10 (JSC::VM::gigacageAuxiliarySpace): 11 1 12 2019-01-08 Keith Miller <keith_miller@apple.com> 2 13 -
TabularUnified trunk/Source/JavaScriptCore/runtime/VM.h ¶
r239427 r239787 1 1 /* 2 * Copyright (C) 2008-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2008-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 347 347 { 348 348 switch (kind) { 349 case Gigacage::ReservedForFlagsAndNotABasePtr: 350 RELEASE_ASSERT_NOT_REACHED(); 349 351 case Gigacage::Primitive: 350 352 return primitiveGigacageAuxiliarySpace; -
TabularUnified trunk/Source/WTF/ChangeLog ¶
r239709 r239787 1 2019-01-09 Mark Lam <mark.lam@apple.com> 2 3 Gigacage disabling checks should handle the GIGACAGE_ALLOCATION_CAN_FAIL case properly. 4 https://bugs.webkit.org/show_bug.cgi?id=193292 5 <rdar://problem/46485450> 6 7 Reviewed by Yusuke Suzuki. 8 9 Update the USE_SYSTEM_MALLOC version of Gigacage.h to match the bmalloc version. 10 11 * wtf/Gigacage.h: 12 1 13 2019-01-07 David Kilzer <ddkilzer@apple.com> 2 14 -
TabularUnified trunk/Source/WTF/wtf/Gigacage.h ¶
r231337 r239787 1 1 /* 2 * Copyright (C) 2017-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 41 41 42 42 struct BasePtrs { 43 uintptr_t reservedForFlags; 43 44 void* primitive; 44 45 void* jsValue; … … 46 47 47 48 enum Kind { 49 ReservedForFlagsAndNotABasePtr = 0, 48 50 Primitive, 49 51 JSValue, 50 52 }; 53 54 static_assert(offsetof(BasePtrs, primitive) == Kind::Primitive * sizeof(void*), ""); 55 static_assert(offsetof(BasePtrs, jsValue) == Kind::JSValue * sizeof(void*), ""); 51 56 52 57 inline void ensureGigacage() { } … … 66 71 { 67 72 switch (kind) { 73 case ReservedForFlagsAndNotABasePtr: 74 RELEASE_ASSERT_NOT_REACHED(); 68 75 case Primitive: 69 76 return "Primitive"; … … 78 85 { 79 86 switch (kind) { 87 case ReservedForFlagsAndNotABasePtr: 88 RELEASE_ASSERT_NOT_REACHED(); 80 89 case Primitive: 81 90 return basePtrs.primitive; -
TabularUnified trunk/Source/bmalloc/ChangeLog ¶
r239257 r239787 1 2019-01-09 Mark Lam <mark.lam@apple.com> 2 3 Gigacage disabling checks should handle the GIGACAGE_ALLOCATION_CAN_FAIL case properly. 4 https://bugs.webkit.org/show_bug.cgi?id=193292 5 <rdar://problem/46485450> 6 7 Reviewed by Yusuke Suzuki. 8 9 Previously, when GIGACAGE_ALLOCATION_CAN_FAIL is true, we allow the Gigacage to 10 be disabled if we fail to allocate memory for it. However, Gigacage::primitiveGigacageDisabled() 11 still always assumes that the Gigacage is always enabled after ensureGigacage() is 12 called. 13 14 This patch updates Gigacage::primitiveGigacageDisabled() to allow the Gigacage to 15 already be disabled if GIGACAGE_ALLOCATION_CAN_FAIL is true and wasEnabled() is 16 false. 17 18 In this patch, we also put the wasEnabled flag in the 0th slot of the 19 g_gigacageBasePtrs buffer to ensure that it is also protected against writes just 20 like the Gigacage base pointers. 21 22 To achieve this, we do the following: 23 1. Added a reservedForFlags field in struct BasePtrs. 24 2. Added a ReservedForFlagsAndNotABasePtr Gigacage::Kind. 25 3. Added assertions to ensure that the BasePtrs::primitive is at the offset 26 matching the offset computed from Gigacage::Primitive. Ditto for 27 BasePtrs::jsValue and Gigacage::JSValue. 28 4. Added assertions to ensure that Gigacage::ReservedForFlagsAndNotABasePtr is not 29 used for fetching a Gigacage base pointer. 30 5. Added RELEASE_BASSERT_NOT_REACHED() to implement such assertions in bmalloc. 31 32 No test added because this issue requires Gigacage allocation to fail in order to 33 manifest. I've tested it manually by modifying the code locally to force an 34 allocation failure. 35 36 * bmalloc/BAssert.h: 37 * bmalloc/Gigacage.cpp: 38 (Gigacage::ensureGigacage): 39 (Gigacage::primitiveGigacageDisabled): 40 * bmalloc/Gigacage.h: 41 (Gigacage::wasEnabled): 42 (Gigacage::setWasEnabled): 43 (Gigacage::name): 44 (Gigacage::basePtr): 45 (Gigacage::size): 46 * bmalloc/HeapKind.h: 47 (bmalloc::heapKind): 48 1 49 2018-12-15 Yusuke Suzuki <yusukesuzuki@slowstart.org> 2 50 -
TabularUnified trunk/Source/bmalloc/bmalloc/BAssert.h ¶
r230463 r239787 82 82 83 83 #define RELEASE_BASSERT(x) BASSERT_IMPL(x) 84 #define RELEASE_BASSERT_NOT_REACHED() BCRASH() 84 85 85 86 #if BUSE(OS_LOG) -
TabularUnified trunk/Source/bmalloc/bmalloc/Gigacage.cpp ¶
r239257 r239787 1 1 /* 2 * Copyright (C) 2017-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 43 43 #define GIGACAGE_RUNWAY (32llu * 1024 * 1024 * 1024) 44 44 45 // Note: g_gigacageBasePtrs[0] is reserved for storing the wasEnabled flag. 46 // The first gigacageBasePtr will start at g_gigacageBasePtrs[sizeof(void*)]. 47 // This is done so that the wasEnabled flag will also be protected along with the 48 // gigacageBasePtrs. 45 49 alignas(GIGACAGE_BASE_PTRS_SIZE) char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE]; 46 50 … … 48 52 49 53 namespace Gigacage { 50 51 bool g_wasEnabled;52 54 53 55 namespace { … … 104 106 { 105 107 switch (kind) { 108 case Kind::ReservedForFlagsAndNotABasePtr: 109 RELEASE_BASSERT_NOT_REACHED(); 106 110 case Kind::Primitive: 107 111 return static_cast<size_t>(GIGACAGE_RUNWAY); … … 127 131 Kind shuffledKinds[numKinds]; 128 132 for (unsigned i = 0; i < numKinds; ++i) 129 shuffledKinds[i] = static_cast<Kind>(i );133 shuffledKinds[i] = static_cast<Kind>(i + 1); // + 1 to skip Kind::ReservedForFlagsAndNotABasePtr. 130 134 131 135 // We just go ahead and assume that 64 bits is enough randomness. That's trivially true right … … 183 187 184 188 vmDeallocatePhysicalPages(base, totalSize); 189 setWasEnabled(); 185 190 protectGigacageBasePtrs(); 186 g_wasEnabled = true;187 191 }); 188 192 #endif // GIGACAGE_ENABLED … … 237 241 static void primitiveGigacageDisabled(void*) 238 242 { 243 if (GIGACAGE_ALLOCATION_CAN_FAIL && !wasEnabled()) 244 return; 245 239 246 static bool s_false; 240 247 fprintf(stderr, "FATAL: Primitive gigacage disabled, but we don't want that in this process.\n"); -
TabularUnified trunk/Source/bmalloc/bmalloc/Gigacage.h ¶
r237399 r239787 1 1 /* 2 * Copyright (C) 2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 76 76 namespace Gigacage { 77 77 78 extern BEXPORT bool g_wasEnabled; 79 BINLINE bool wasEnabled() { return g_wasEnabled; }78 BINLINE bool wasEnabled() { return g_gigacageBasePtrs[0]; } 79 BINLINE void setWasEnabled() { g_gigacageBasePtrs[0] = true; } 80 80 81 81 struct BasePtrs { 82 uintptr_t reservedForFlags; 82 83 void* primitive; 83 84 void* jsValue; … … 85 86 86 87 enum Kind { 88 ReservedForFlagsAndNotABasePtr = 0, 87 89 Primitive, 88 90 JSValue, 89 91 }; 90 92 93 static_assert(offsetof(BasePtrs, primitive) == Kind::Primitive * sizeof(void*), ""); 94 static_assert(offsetof(BasePtrs, jsValue) == Kind::JSValue * sizeof(void*), ""); 95 91 96 static constexpr unsigned numKinds = 2; 92 97 … … 108 113 { 109 114 switch (kind) { 115 case ReservedForFlagsAndNotABasePtr: 116 RELEASE_BASSERT_NOT_REACHED(); 110 117 case Primitive: 111 118 return "Primitive"; … … 120 127 { 121 128 switch (kind) { 129 case ReservedForFlagsAndNotABasePtr: 130 RELEASE_BASSERT_NOT_REACHED(); 122 131 case Primitive: 123 132 return basePtrs.primitive; … … 147 156 { 148 157 switch (kind) { 158 case ReservedForFlagsAndNotABasePtr: 159 RELEASE_BASSERT_NOT_REACHED(); 149 160 case Primitive: 150 161 return static_cast<size_t>(PRIMITIVE_GIGACAGE_SIZE); -
TabularUnified trunk/Source/bmalloc/bmalloc/HeapKind.h ¶
r231337 r239787 1 1 /* 2 * Copyright (C) 2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 71 71 { 72 72 switch (kind) { 73 case Gigacage::ReservedForFlagsAndNotABasePtr: 74 RELEASE_BASSERT_NOT_REACHED(); 73 75 case Gigacage::Primitive: 74 76 return HeapKind::PrimitiveGigacage;
Note:
See TracChangeset
for help on using the changeset viewer.