Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JSC] Improve Wasm binary test coverage
https://bugs.webkit.org/show_bug.cgi?id=204843 Reviewed by Darin Adler. JSTests: * wasm/function-tests/grow-memory.js: (binaryShouldNotParse): * wasm/spec-tests/binary-leb128.wast.js: * wasm/spec-tests/binary.wast.js: * wasm/wasm.json: Source/JavaScriptCore: This patch fixes some of bugs in wasm parser so that we validate malformed wasm modules more strictly. 1. current_memory / grow_memory should have uint8 flag, not varuint32 flag. 2. global section should have uint8 mutability information, not varuint32. 3. memory section should have varuint32 memory count. * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseResizableLimits): (JSC::Wasm::SectionParser::parseMemory): (JSC::Wasm::SectionParser::parseGlobalType): * wasm/wasm.json: Source/WTF: LEBDecoder should have more strict validation. One thing is that, we should reject pattern that includes ignored bits. For example, in uint32_t, we can represent UINT32_MAX in 5 bytes like this. 0xff, 0xff, 0xff, 0xff, 0x0f 0b1111111_1111111_1111111_1111111_1111 Leading bytes has 0x80 trailing marker. And they includes each 7 bit slice. And the last byte includes 0b1111 part. But we can also make it in the following form 0xff, 0xff, 0xff, 0xff, 0xff 0b1111111_1111111_1111111_1111111_1111 In the above case, the last byte's upper 4 bits are ignored in the result, and this is wrong in LEB128 encoding. We should reject this input since the last byte includes overflown bits. This patch adds this validation to WTF. * wtf/LEBDecoder.h: (WTF::LEBDecoder::maxByteLength): (WTF::LEBDecoder::lastByteMask): (WTF::LEBDecoder::decodeUInt): (WTF::LEBDecoder::decodeInt): Tools: We add more tests for LEBDecoder. In particular, the added tests focus on the case which overflow bits. * TestWebKitAPI/Tests/WTF/LEBDecoder.cpp: (TestWebKitAPI::toString): (TestWebKitAPI::testUInt32LEBDecode): (TestWebKitAPI::TEST): (TestWebKitAPI::testUInt64LEBDecode): (TestWebKitAPI::testInt32LEBDecode): (TestWebKitAPI::testInt64LEBDecode): Canonical link: https://commits.webkit.org/231741@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
71ab041
commit 25be2dc
Showing
16 changed files
with
266 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.