Title: [250065] trunk
- Revision
- 250065
- Author
- [email protected]
- Date
- 2019-09-18 16:43:09 -0700 (Wed, 18 Sep 2019)
Log Message
TOCTOU bug in havingABadTime related assertion in DFGSpeculativeJIT
https://bugs.webkit.org/show_bug.cgi?id=201953
<rdar://problem/53803524>
Reviewed by Yusuke Suzuki.
JSTests:
* stress/toctou-having-a-bad-time-new-array.js: Added.
(let.code):
Source/_javascript_Core:
We had code in DFGSpeculativeJIT like:
if (!globalObject->isHavingABadTime()) {
<-- here -->
Structure* s = globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
assert 's' has expected indexing type
}
The problem is, we may have a bad time before we actually load the structure
inside the if. We may have a bad time while we're at the "<-- here -->" in the
above program. The fix is to first load the structure, then check if we're
having a bad time. If we're still not having a bad time, it's valid to assert
things about the structure.
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileNewArray):
Modified Paths
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (250064 => 250065)
--- trunk/JSTests/ChangeLog 2019-09-18 23:33:08 UTC (rev 250064)
+++ trunk/JSTests/ChangeLog 2019-09-18 23:43:09 UTC (rev 250065)
@@ -1,5 +1,16 @@
2019-09-18 Saam Barati <[email protected]>
+ TOCTOU bug in havingABadTime related assertion in DFGSpeculativeJIT
+ https://bugs.webkit.org/show_bug.cgi?id=201953
+ <rdar://problem/53803524>
+
+ Reviewed by Yusuke Suzuki.
+
+ * stress/toctou-having-a-bad-time-new-array.js: Added.
+ (let.code):
+
+2019-09-18 Saam Barati <[email protected]>
+
Phantom insertion phase may disagree with arguments forwarding about live ranges
https://bugs.webkit.org/show_bug.cgi?id=200715
<rdar://problem/54301717>
Added: trunk/JSTests/stress/toctou-having-a-bad-time-new-array.js (0 => 250065)
--- trunk/JSTests/stress/toctou-having-a-bad-time-new-array.js (rev 0)
+++ trunk/JSTests/stress/toctou-having-a-bad-time-new-array.js 2019-09-18 23:43:09 UTC (rev 250065)
@@ -0,0 +1,16 @@
+let code = `
+ function foo() {
+ return [Date.prototype];
+ }
+
+ for (let i = 0; i < 50; ++i) {
+ foo();
+ }
+
+ let [proto] = foo();
+ Object.defineProperty(proto, '0', {});
+`;
+
+for (let i = 0; i < 5000; i++) {
+ runString(code);
+}
Modified: trunk/Source/_javascript_Core/ChangeLog (250064 => 250065)
--- trunk/Source/_javascript_Core/ChangeLog 2019-09-18 23:33:08 UTC (rev 250064)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-09-18 23:43:09 UTC (rev 250065)
@@ -1,3 +1,28 @@
+2019-09-18 Saam Barati <[email protected]>
+
+ TOCTOU bug in havingABadTime related assertion in DFGSpeculativeJIT
+ https://bugs.webkit.org/show_bug.cgi?id=201953
+ <rdar://problem/53803524>
+
+ Reviewed by Yusuke Suzuki.
+
+ We had code in DFGSpeculativeJIT like:
+
+ if (!globalObject->isHavingABadTime()) {
+ <-- here -->
+ Structure* s = globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
+ assert 's' has expected indexing type
+ }
+
+ The problem is, we may have a bad time before we actually load the structure
+ inside the if. We may have a bad time while we're at the "<-- here -->" in the
+ above program. The fix is to first load the structure, then check if we're
+ having a bad time. If we're still not having a bad time, it's valid to assert
+ things about the structure.
+
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileNewArray):
+
2019-09-18 Chris Dumez <[email protected]>
Stop calling WTF::initializeMainThread() in JSGlobalContextCreate*()
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (250064 => 250065)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2019-09-18 23:33:08 UTC (rev 250064)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2019-09-18 23:43:09 UTC (rev 250065)
@@ -7954,8 +7954,8 @@
void SpeculativeJIT::compileNewArray(Node* node)
{
JSGlobalObject* globalObject = m_jit.graph().globalObjectFor(node->origin.semantic);
+ RegisteredStructure structure = m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
if (!globalObject->isHavingABadTime() && !hasAnyArrayStorage(node->indexingType())) {
- RegisteredStructure structure = m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
DFG_ASSERT(m_jit.graph(), node, structure->indexingType() == node->indexingType(), structure->indexingType(), node->indexingType());
ASSERT(
hasUndecided(structure->indexingType())
@@ -8028,7 +8028,7 @@
if (!node->numChildren()) {
flushRegisters();
GPRFlushedCallResult result(this);
- callOperation(operationNewEmptyArray, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())));
+ callOperation(operationNewEmptyArray, result.gpr(), structure);
m_jit.exceptionCheck();
cellResult(result.gpr(), node);
return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes