Log Message
Wasm StreamingParser should validate that number of functions matches number of declarations https://bugs.webkit.org/show_bug.cgi?id=201850 <rdar://problem/55290186>
Reviewed by Yusuke Suzuki. JSTests: * wasm/regress/validate-number-of-functions-match-declarations.js: Added. (catch): Source/_javascript_Core: Currently, when parsing the code section, we check that the number of functions matches the number of declarations in the function section. However, that check is never performed if the module does not have a code section. To fix that, we perform the check again in StreamingParser::finalize. * wasm/WasmStreamingParser.cpp: (JSC::Wasm::StreamingParser::finalize):
Modified Paths
- trunk/JSTests/ChangeLog
- trunk/Source/_javascript_Core/ChangeLog
- trunk/Source/_javascript_Core/wasm/WasmStreamingParser.cpp
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (249934 => 249935)
--- trunk/JSTests/ChangeLog 2019-09-17 01:25:59 UTC (rev 249934)
+++ trunk/JSTests/ChangeLog 2019-09-17 01:40:49 UTC (rev 249935)
@@ -1,3 +1,14 @@
+2019-09-16 Tadeu Zagallo <[email protected]>
+
+ Wasm StreamingParser should validate that number of functions matches number of declarations
+ https://bugs.webkit.org/show_bug.cgi?id=201850
+ <rdar://problem/55290186>
+
+ Reviewed by Yusuke Suzuki.
+
+ * wasm/regress/validate-number-of-functions-match-declarations.js: Added.
+ (catch):
+
2019-09-16 Michael Saboff <[email protected]>
[JSC] Perform check again when we found non-BMP characters
Added: trunk/JSTests/wasm/regress/validate-number-of-functions-match-declarations.js (0 => 249935)
--- trunk/JSTests/wasm/regress/validate-number-of-functions-match-declarations.js (rev 0)
+++ trunk/JSTests/wasm/regress/validate-number-of-functions-match-declarations.js 2019-09-17 01:40:49 UTC (rev 249935)
@@ -0,0 +1,57 @@
+const wasmCode = new Uint8Array([
+ 0, 0x61, 0x73, 0x6d, 0x1, 0, 0, 0, 0x1, 0xe, 0x3, 0x60,
+ 0x2, 0x7c, 0x7c, 0x1, 0x7f, 0x60, 0, 0, 0x60, 0, 0x1, 0x7f,
+ 0x2, 0xe, 0x1, 0x3, 0x65, 0x6e, 0x76, 0x6, 0x6a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 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x74, 0, 0, 0, 0, 0, 0, 0x34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x62, 0, 0x69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x36, 0, 0, 0, 0x69, 0x74, 0x6a, 0x70, 0x69, 0x6b,
+ 0x69, 0x2e, 0x24, 0, 0x6d, 0x61, 0x69, 0x6e, 0, 0x69, 0x41,
+ 0x74, 0, 0, 0x29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0
+]);
+
+try {
+ new WebAssembly.Module(wasmCode)
+ throw new Error('WebAssembly module should have failed to validate');
+} catch (error) {
+ if (error.message !== "WebAssembly.Module doesn't parse at byte 585: Number of functions parsed (0) does not match the number of declared functions (2) (evaluating 'new WebAssembly.Module(wasmCode)')")
+ throw new Error(`Unexpected error: ${error.message}`);
+}
Modified: trunk/Source/_javascript_Core/ChangeLog (249934 => 249935)
--- trunk/Source/_javascript_Core/ChangeLog 2019-09-17 01:25:59 UTC (rev 249934)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-09-17 01:40:49 UTC (rev 249935)
@@ -1,3 +1,18 @@
+2019-09-16 Tadeu Zagallo <[email protected]>
+
+ Wasm StreamingParser should validate that number of functions matches number of declarations
+ https://bugs.webkit.org/show_bug.cgi?id=201850
+ <rdar://problem/55290186>
+
+ Reviewed by Yusuke Suzuki.
+
+ Currently, when parsing the code section, we check that the number of functions matches the number
+ of declarations in the function section. However, that check is never performed if the module does
+ not have a code section. To fix that, we perform the check again in StreamingParser::finalize.
+
+ * wasm/WasmStreamingParser.cpp:
+ (JSC::Wasm::StreamingParser::finalize):
+
2019-09-16 Michael Saboff <[email protected]>
[JSC] Perform check again when we found non-BMP characters
Modified: trunk/Source/_javascript_Core/wasm/WasmStreamingParser.cpp (249934 => 249935)
--- trunk/Source/_javascript_Core/wasm/WasmStreamingParser.cpp 2019-09-17 01:25:59 UTC (rev 249934)
+++ trunk/Source/_javascript_Core/wasm/WasmStreamingParser.cpp 2019-09-17 01:40:49 UTC (rev 249935)
@@ -383,6 +383,10 @@
break;
case State::SectionID:
+ if (m_functionIndex != m_info->functions.size()) {
+ m_state = fail("Number of functions parsed (", m_functionCount, ") does not match the number of declared functions (", m_info->functions.size(), ")");
+ break;
+ }
if (m_remaining.isEmpty()) {
if (UNLIKELY(Options::useEagerWebAssemblyModuleHashing()))
m_info->nameSection->setHash(m_hasher.computeHexDigest());
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
