Modified: trunk/Source/_javascript_Core/ChangeLog (253170 => 253171)
--- trunk/Source/_javascript_Core/ChangeLog 2019-12-05 21:22:48 UTC (rev 253170)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-12-05 22:32:55 UTC (rev 253171)
@@ -1,5 +1,19 @@
2019-12-05 Tadeu Zagallo <[email protected]>
+ REGRESSION(r253140): Wasm::FunctionParser needs to bounds check in SetLocal/TeeLocal
+ https://bugs.webkit.org/show_bug.cgi?id=204909
+
+ Reviewed by Keith Miller.
+
+ When moving the code from WasmValidate.cpp to WasmFunctionParser.h, I missed that SetLocal and
+ TeeLocal used to call Wasm::Validate::getLocal, which would perform the bounds check. I just
+ added back the checks to the parser before accessing the local's type from m_locals.
+
+ * wasm/WasmFunctionParser.h:
+ (JSC::Wasm::FunctionParser<Context>::parseExpression):
+
+2019-12-05 Tadeu Zagallo <[email protected]>
+
[WebAssembly] Fix bad assertion in LLIntPlan
https://bugs.webkit.org/show_bug.cgi?id=204893
Modified: trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h (253170 => 253171)
--- trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h 2019-12-05 21:22:48 UTC (rev 253170)
+++ trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h 2019-12-05 22:32:55 UTC (rev 253171)
@@ -536,6 +536,7 @@
TypedExpression value;
WASM_PARSER_FAIL_IF(!parseVarUInt32(index), "can't get index for set_local");
WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "set_local");
+ WASM_VALIDATOR_FAIL_IF(index >= m_locals.size(), "attempt to set unknown local ", index, " last one is ", m_locals.size());
WASM_VALIDATOR_FAIL_IF(!isSubtype(value.type(), m_locals[index]), "set_local to type ", value.type(), " expected ", m_locals[index]);
WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value));
return { };
@@ -546,6 +547,7 @@
WASM_PARSER_FAIL_IF(!parseVarUInt32(index), "can't get index for tee_local");
WASM_PARSER_FAIL_IF(m_expressionStack.isEmpty(), "can't tee_local on empty _expression_ stack");
TypedExpression value = m_expressionStack.last();
+ WASM_VALIDATOR_FAIL_IF(index >= m_locals.size(), "attempt to tee unknown local ", index, " last one is ", m_locals.size());
WASM_VALIDATOR_FAIL_IF(!isSubtype(value.type(), m_locals[index]), "set_local to type ", value.type(), " expected ", m_locals[index]);
WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value));
return { };