• eholk's avatar
    [wasm] Syntax- and Type-aware Fuzzer · 3e1db847
    eholk authored
    This is the beginning of a new fuzzer that generates
    correct-by-construction Wasm modules. This should allow us to better
    exercise the compiler and correctness aspects of fuzzing. It is based off
    of ahaas' original Wasm fuzzer.
    
    At the moment, it can generate expressions made up of most binops, and
    also nested blocks with unconditional breaks. Future CLs will add
    additional constructs, such as br_if, loops, memory access, etc.
    
    The way the fuzzer works is that it starts with an array of arbitrary
    data provided by libfuzzer. It uses the data to generate an expression.
    Care is taken to make use of the entire string. Basically, the
    generator has a bunch of grammar-like rules for how to construct an
    expression of a given type. For example, an i32 can be made by adding
    two other i32s, or by wrapping an i64. The process then continues
    recursively until all the data is consumed.
    
    We generate an expression from a slice of data as follows:
    * If the slice is less than or equal to the size of the type (e.g. 4
      bytes for i32), then it will emit the entire slice as a constant.
    * Otherwise, it will consume the first 4 bytes of the slice and use
      this to select which rule to apply. Each rule then consumes the
      remainder of the slice in an appropriate way. For example:
      * Unary ops use the remainder of the slice to generate the argument.
      * Binary ops consume another four bytes and mod this with the length
        of the remaining slice to split the slice into two parts. Each of
        these subslices are then used to generate one of the arguments to
        the binop.
      * Blocks are basically like a unary op, but a stack of block types is
        maintained to facilitate branches. For blocks that end in a break,
        the first four bytes of a slice are used to select the break depth
        and the stack determines what type of expression to generate.
    The goal is that once this generator is complete, it will provide a one
    to one mapping between binary strings and valid Wasm modules.
    
    Review-Url: https://codereview.chromium.org/2658723006
    Cr-Commit-Position: refs/heads/master@{#43289}
    3e1db847
Name
Last commit
Last update
..
json Loading commit data...
parser Loading commit data...
regexp Loading commit data...
wasm_call Loading commit data...
wasm_code Loading commit data...
wasm_compile Loading commit data...
wasm_data_section Loading commit data...
wasm_function_sigs_section Loading commit data...
wasm_globals_section Loading commit data...
wasm_imports_section Loading commit data...
wasm_memory_section Loading commit data...
wasm_names_section Loading commit data...
wasm_types_section Loading commit data...
DEPS Loading commit data...
README.md Loading commit data...
fuzzer-support.cc Loading commit data...
fuzzer-support.h Loading commit data...
fuzzer.cc Loading commit data...
fuzzer.gyp Loading commit data...
fuzzer.isolate Loading commit data...
fuzzer.status Loading commit data...
json.cc Loading commit data...
parser.cc Loading commit data...
regexp.cc Loading commit data...
testcfg.py Loading commit data...
wasm-asmjs.cc Loading commit data...
wasm-call.cc Loading commit data...
wasm-code.cc Loading commit data...
wasm-compile.cc Loading commit data...
wasm-data-section.cc Loading commit data...
wasm-function-sigs-section.cc Loading commit data...
wasm-globals-section.cc Loading commit data...
wasm-imports-section.cc Loading commit data...
wasm-memory-section.cc Loading commit data...
wasm-names-section.cc Loading commit data...
wasm-section-fuzzers.cc Loading commit data...
wasm-section-fuzzers.h Loading commit data...
wasm-types-section.cc Loading commit data...
wasm.cc Loading commit data...
wasm.tar.gz.sha1 Loading commit data...
wasm_asmjs.tar.gz.sha1 Loading commit data...