|
| 1 | +2017-12-13 Keith Miller <keith_miller@apple.com> |
| 2 | + |
| 3 | + JSObjects should have a mask for loading indexed properties |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=180768 |
| 5 | + |
| 6 | + Reviewed by Mark Lam. |
| 7 | + |
| 8 | + This patch adds a new member to JSObject that holds an indexing |
| 9 | + mask. The indexing mask is bitwise anded with the index used to |
| 10 | + load a property. If for whatever reason an attacker is able to |
| 11 | + clobber the vectorLength of our butterfly they still won't be able |
| 12 | + to read substantially past the end of the buttefly. For |
| 13 | + performance reasons we don't use the indexing masking for |
| 14 | + TypedArrays. Since TypedArrays are already gigacaged the risk of |
| 15 | + wild reads is still restricted. |
| 16 | + |
| 17 | + This patch is a <1% regression on Speedometer and ~3% regression |
| 18 | + on JetStream in my testing. |
| 19 | + |
| 20 | + * assembler/MacroAssembler.h: |
| 21 | + (JSC::MacroAssembler::urshiftPtr): |
| 22 | + * bytecode/AccessCase.cpp: |
| 23 | + (JSC::AccessCase::generateImpl): |
| 24 | + * dfg/DFGAbstractHeap.h: |
| 25 | + * dfg/DFGClobberize.h: |
| 26 | + (JSC::DFG::clobberize): |
| 27 | + * dfg/DFGSpeculativeJIT.cpp: |
| 28 | + (JSC::DFG::SpeculativeJIT::emitAllocateRawObject): |
| 29 | + (JSC::DFG::SpeculativeJIT::compileDoublePutByVal): |
| 30 | + (JSC::DFG::SpeculativeJIT::compileNewFunctionCommon): |
| 31 | + (JSC::DFG::SpeculativeJIT::compileCreateActivation): |
| 32 | + (JSC::DFG::SpeculativeJIT::compileCreateDirectArguments): |
| 33 | + (JSC::DFG::SpeculativeJIT::compileArraySlice): |
| 34 | + (JSC::DFG::SpeculativeJIT::compileNukeStructureAndSetButterfly): |
| 35 | + (JSC::DFG::SpeculativeJIT::compileNewStringObject): |
| 36 | + (JSC::DFG::SpeculativeJIT::compileNewTypedArray): |
| 37 | + * dfg/DFGSpeculativeJIT.h: |
| 38 | + (JSC::DFG::SpeculativeJIT::emitAllocateJSObject): |
| 39 | + (JSC::DFG::SpeculativeJIT::emitAllocateJSObjectWithKnownSize): |
| 40 | + * dfg/DFGSpeculativeJIT32_64.cpp: |
| 41 | + (JSC::DFG::SpeculativeJIT::compile): |
| 42 | + (JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize): |
| 43 | + * dfg/DFGSpeculativeJIT64.cpp: |
| 44 | + (JSC::DFG::SpeculativeJIT::compile): |
| 45 | + (JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize): |
| 46 | + * ftl/FTLAbstractHeap.cpp: |
| 47 | + (JSC::FTL::IndexedAbstractHeap::baseIndex): |
| 48 | + * ftl/FTLAbstractHeap.h: |
| 49 | + * ftl/FTLAbstractHeapRepository.h: |
| 50 | + * ftl/FTLLowerDFGToB3.cpp: |
| 51 | + (JSC::FTL::DFG::LowerDFGToB3::compileAtomicsReadModifyWrite): |
| 52 | + (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): |
| 53 | + (JSC::FTL::DFG::LowerDFGToB3::compileCreateActivation): |
| 54 | + (JSC::FTL::DFG::LowerDFGToB3::compileNewFunction): |
| 55 | + (JSC::FTL::DFG::LowerDFGToB3::compileCreateDirectArguments): |
| 56 | + (JSC::FTL::DFG::LowerDFGToB3::compileNewStringObject): |
| 57 | + (JSC::FTL::DFG::LowerDFGToB3::compileNewTypedArray): |
| 58 | + (JSC::FTL::DFG::LowerDFGToB3::compileMaterializeNewObject): |
| 59 | + (JSC::FTL::DFG::LowerDFGToB3::compileMaterializeCreateActivation): |
| 60 | + (JSC::FTL::DFG::LowerDFGToB3::maskedIndex): |
| 61 | + (JSC::FTL::DFG::LowerDFGToB3::computeButterflyIndexingMask): |
| 62 | + (JSC::FTL::DFG::LowerDFGToB3::allocateObject): |
| 63 | + (JSC::FTL::DFG::LowerDFGToB3::allocateVariableSizedObject): |
| 64 | + (JSC::FTL::DFG::LowerDFGToB3::allocateJSArray): |
| 65 | + (JSC::FTL::DFG::LowerDFGToB3::pointerIntoTypedArray): |
| 66 | + * ftl/FTLOutput.h: |
| 67 | + (JSC::FTL::Output::baseIndex): |
| 68 | + * jit/AssemblyHelpers.h: |
| 69 | + (JSC::AssemblyHelpers::emitComputeButterflyIndexingMask): |
| 70 | + (JSC::AssemblyHelpers::nukeStructureAndStoreButterfly): |
| 71 | + (JSC::AssemblyHelpers::emitAllocateJSObject): |
| 72 | + (JSC::AssemblyHelpers::emitAllocateJSObjectWithKnownSize): |
| 73 | + (JSC::AssemblyHelpers::emitAllocateVariableSizedJSObject): |
| 74 | + (JSC::AssemblyHelpers::emitAllocateDestructibleObject): |
| 75 | + (JSC::AssemblyHelpers::storeButterfly): Deleted. |
| 76 | + * jit/JITOpcodes.cpp: |
| 77 | + (JSC::JIT::emit_op_new_object): |
| 78 | + (JSC::JIT::emit_op_create_this): |
| 79 | + * jit/JITOpcodes32_64.cpp: |
| 80 | + (JSC::JIT::emit_op_new_object): |
| 81 | + (JSC::JIT::emit_op_create_this): |
| 82 | + * jit/JITPropertyAccess.cpp: |
| 83 | + (JSC::JIT::emitDoubleLoad): |
| 84 | + (JSC::JIT::emitContiguousLoad): |
| 85 | + (JSC::JIT::emitArrayStorageLoad): |
| 86 | + * llint/LowLevelInterpreter32_64.asm: |
| 87 | + * llint/LowLevelInterpreter64.asm: |
| 88 | + * runtime/ArrayStorage.h: |
| 89 | + (JSC::ArrayStorage::availableVectorLength): |
| 90 | + * runtime/Butterfly.h: |
| 91 | + (JSC::ContiguousData::ContiguousData): |
| 92 | + (JSC::ContiguousData::at const): |
| 93 | + (JSC::ContiguousData::at): |
| 94 | + (JSC::Butterfly::publicLength const): |
| 95 | + (JSC::Butterfly::vectorLength const): |
| 96 | + (JSC::Butterfly::computeIndexingMaskForVectorLength): |
| 97 | + (JSC::Butterfly::computeIndexingMask): |
| 98 | + (JSC::Butterfly::contiguousInt32): |
| 99 | + (JSC::ContiguousData::operator[] const): Deleted. |
| 100 | + (JSC::ContiguousData::operator[]): Deleted. |
| 101 | + (JSC::Butterfly::publicLength): Deleted. |
| 102 | + (JSC::Butterfly::vectorLength): Deleted. |
| 103 | + * runtime/ButterflyInlines.h: |
| 104 | + (JSC::ContiguousData<T>::at const): |
| 105 | + (JSC::ContiguousData<T>::at): |
| 106 | + * runtime/ClonedArguments.cpp: |
| 107 | + (JSC::ClonedArguments::createEmpty): |
| 108 | + * runtime/JSArray.cpp: |
| 109 | + (JSC::JSArray::tryCreateUninitializedRestricted): |
| 110 | + (JSC::JSArray::appendMemcpy): |
| 111 | + (JSC::JSArray::setLength): |
| 112 | + (JSC::JSArray::pop): |
| 113 | + (JSC::JSArray::fastSlice): |
| 114 | + (JSC::JSArray::shiftCountWithArrayStorage): |
| 115 | + (JSC::JSArray::shiftCountWithAnyIndexingType): |
| 116 | + (JSC::JSArray::unshiftCountWithAnyIndexingType): |
| 117 | + (JSC::JSArray::fillArgList): |
| 118 | + (JSC::JSArray::copyToArguments): |
| 119 | + * runtime/JSArrayBufferView.cpp: |
| 120 | + (JSC::JSArrayBufferView::JSArrayBufferView): |
| 121 | + * runtime/JSArrayInlines.h: |
| 122 | + (JSC::JSArray::pushInline): |
| 123 | + * runtime/JSFixedArray.h: |
| 124 | + (JSC::JSFixedArray::createFromArray): |
| 125 | + * runtime/JSGenericTypedArrayViewInlines.h: |
| 126 | + (JSC::JSGenericTypedArrayView<Adaptor>::slowDownAndWasteMemory): |
| 127 | + * runtime/JSObject.cpp: |
| 128 | + (JSC::JSObject::getOwnPropertySlotByIndex): |
| 129 | + (JSC::JSObject::putByIndex): |
| 130 | + (JSC::JSObject::createInitialInt32): |
| 131 | + (JSC::JSObject::createInitialDouble): |
| 132 | + (JSC::JSObject::createInitialContiguous): |
| 133 | + (JSC::JSObject::convertUndecidedToInt32): |
| 134 | + (JSC::JSObject::convertUndecidedToDouble): |
| 135 | + (JSC::JSObject::convertUndecidedToContiguous): |
| 136 | + (JSC::JSObject::convertInt32ToDouble): |
| 137 | + (JSC::JSObject::convertInt32ToArrayStorage): |
| 138 | + (JSC::JSObject::convertDoubleToContiguous): |
| 139 | + (JSC::JSObject::convertDoubleToArrayStorage): |
| 140 | + (JSC::JSObject::convertContiguousToArrayStorage): |
| 141 | + (JSC::JSObject::createInitialForValueAndSet): |
| 142 | + (JSC::JSObject::deletePropertyByIndex): |
| 143 | + (JSC::JSObject::getOwnPropertyNames): |
| 144 | + (JSC::JSObject::putByIndexBeyondVectorLengthWithoutAttributes): |
| 145 | + (JSC::JSObject::countElements): |
| 146 | + (JSC::JSObject::ensureLengthSlow): |
| 147 | + (JSC::JSObject::reallocateAndShrinkButterfly): |
| 148 | + (JSC::JSObject::getEnumerableLength): |
| 149 | + * runtime/JSObject.h: |
| 150 | + (JSC::JSObject::canGetIndexQuickly): |
| 151 | + (JSC::JSObject::getIndexQuickly): |
| 152 | + (JSC::JSObject::tryGetIndexQuickly const): |
| 153 | + (JSC::JSObject::setIndexQuickly): |
| 154 | + (JSC::JSObject::initializeIndex): |
| 155 | + (JSC::JSObject::initializeIndexWithoutBarrier): |
| 156 | + (JSC::JSObject::butterflyIndexingMaskOffset): |
| 157 | + (JSC::JSObject::butterflyIndexingMask const): |
| 158 | + (JSC::JSObject::setButterflyWithIndexingMask): |
| 159 | + (JSC::JSObject::setButterfly): |
| 160 | + (JSC::JSObject::nukeStructureAndSetButterfly): |
| 161 | + (JSC::JSObject::JSObject): |
| 162 | + * runtime/RegExpMatchesArray.h: |
| 163 | + (JSC::tryCreateUninitializedRegExpMatchesArray): |
| 164 | + * runtime/Structure.cpp: |
| 165 | + (JSC::Structure::flattenDictionaryStructure): |
| 166 | + |
1 | 167 | 2017-12-14 David Kilzer <ddkilzer@apple.com> |
2 | 168 |
|
3 | 169 | REGRESSION (r225799/r225887): Remove duplicate entries for JSCPoisonedPtr.h in Xcode project |
|
0 commit comments