Changeset 248989 in webkit


Ignore:
Timestamp:
Aug 21, 2019 6:42:22 PM (5 years ago)
Author:
mark.lam@apple.com
Message:

Wasm::FunctionParser is failing to enforce maxFunctionLocals.
https://bugs.webkit.org/show_bug.cgi?id=201016
<rdar://problem/54579911>

Reviewed by Yusuke Suzuki.

JSTests:

  • wasm/stress/too-many-locals.js: Added.

(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.catch):

Source/JavaScriptCore:

Currently, Wasm::FunctionParser is allowing

maxFunctionParams + maxFunctionLocals * maxFunctionLocals

... locals, which is 0x9502FCE8. It should be enforcing max locals of
maxFunctionLocals instead.

  • wasm/WasmFunctionParser.h:

(JSC::Wasm::FunctionParser<Context>::parse):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r248955 r248989  
     12019-08-21  Mark Lam  <mark.lam@apple.com>
     2
     3        Wasm::FunctionParser is failing to enforce maxFunctionLocals.
     4        https://bugs.webkit.org/show_bug.cgi?id=201016
     5        <rdar://problem/54579911>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * wasm/stress/too-many-locals.js: Added.
     10        (import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.catch):
     11
    1122019-08-21  Ross Kirsling  <ross.kirsling@sony.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r248951 r248989  
     12019-08-21  Mark Lam  <mark.lam@apple.com>
     2
     3        Wasm::FunctionParser is failing to enforce maxFunctionLocals.
     4        https://bugs.webkit.org/show_bug.cgi?id=201016
     5        <rdar://problem/54579911>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        Currently, Wasm::FunctionParser is allowing
     10
     11            maxFunctionParams + maxFunctionLocals * maxFunctionLocals
     12
     13        ... locals, which is 0x9502FCE8.  It should be enforcing max locals of
     14        maxFunctionLocals instead.
     15
     16        * wasm/WasmFunctionParser.h:
     17        (JSC::Wasm::FunctionParser<Context>::parse):
     18
    1192019-08-21  Michael Saboff  <msaboff@apple.com>
    220
  • trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h

    r248878 r248989  
    116116auto FunctionParser<Context>::parse() -> Result
    117117{
    118     uint32_t localCount;
     118    uint32_t localGroupsCount;
    119119
    120120    WASM_PARSER_FAIL_IF(!m_context.addArguments(m_signature), "can't add ", m_signature.argumentCount(), " arguments to Function");
    121     WASM_PARSER_FAIL_IF(!parseVarUInt32(localCount), "can't get local count");
    122     WASM_PARSER_FAIL_IF(localCount > maxFunctionLocals, "Function section's local count is too big ", localCount, " maximum ", maxFunctionLocals);
    123 
    124     for (uint32_t i = 0; i < localCount; ++i) {
     121    WASM_PARSER_FAIL_IF(!parseVarUInt32(localGroupsCount), "can't get local groups count");
     122
     123    uint64_t totalNumberOfLocals = m_signature.argumentCount();
     124    for (uint32_t i = 0; i < localGroupsCount; ++i) {
    125125        uint32_t numberOfLocals;
    126126        Type typeOfLocal;
    127127
    128128        WASM_PARSER_FAIL_IF(!parseVarUInt32(numberOfLocals), "can't get Function's number of locals in group ", i);
    129         WASM_PARSER_FAIL_IF(numberOfLocals > maxFunctionLocals, "Function section's ", i, "th local group count is too big ", numberOfLocals, " maximum ", maxFunctionLocals);
     129        totalNumberOfLocals += numberOfLocals;
     130        WASM_PARSER_FAIL_IF(totalNumberOfLocals > maxFunctionLocals, "Function's number of locals is too big ", totalNumberOfLocals, " maximum ", maxFunctionLocals);
    130131        WASM_PARSER_FAIL_IF(!parseValueType(typeOfLocal), "can't get Function local's type in group ", i);
    131132        WASM_TRY_ADD_TO_CONTEXT(addLocal(typeOfLocal, numberOfLocals));
Note: See TracChangeset for help on using the changeset viewer.