v8/test/common/wasm
Manos Koukoutos 0396b732e7 [wasm-gc] read_heap_type should check if index is in module bounds
read_heap_type did not have knowledge of the module for which the heap
type was being decoded. As a result, callers of read_heap_type (or
read_value_type, which in turn calls read_heap_type) had to check after
the fact that a decoded indexed type (ref, ref null, or rtt) references
a type index within the module's bounds. This was not done consistently,
and was missing (at least) in DecodeLocals.
To avoid such problems in the future, this CL refactors read_heap_type
to accept a module and check the decoded index against it.

Changes:
- Add WasmModule argument to read_heap_type. Do so accordingly to all
  its transitive callers (read_value_type, immediate arguments,
  DecodeLocalDecls, DecodeValue/HeapType in unittests).
- Add index check to read_heap_type and emit an error for an
  out-of-bounds index.
- Remove all other now-redundant index validations. Replace them with
  decoder->ok() if needed (since read_heap_type will now emit an error).
- Fix error message in Validate for BlockTypeImmediate.
- In DecodeLocalDecls in unittests, pass an empty module to
  DecodeLocalDecls in the main code.
- Add a unit test with an invalid index in local type declarations.

Bug: v8:9495
Change-Id: I4ed1204847db80f78b6ae85fa40d300cd2456295
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2569757
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71572}
2020-12-02 16:52:51 +00:00
..
flag-utils.h [config] Add V8_NODISCARD for Scope classes 2020-11-26 11:08:45 +00:00
OWNERS Use relative paths to OWNERS files 2019-08-12 13:52:52 +00:00
test-signatures.h [wasm-simd][scalar-lowering] Fix more lowering of returns 2020-09-11 01:48:16 +00:00
wasm-interpreter.cc [wasm-gc] read_heap_type should check if index is in module bounds 2020-12-02 16:52:51 +00:00
wasm-interpreter.h [cleanup] Remove DISALLOW_COPY_AND_ASSIGN in test/{common,unittests} 2020-11-06 06:07:54 +00:00
wasm-macro-gen.h Reland: [wasm][memory64] Decode memory offset as 64-bit LEB 2020-11-25 16:21:35 +00:00
wasm-module-runner.cc [wasm] Handle multi-value return in compiled fuzzing result 2020-11-30 13:44:29 +00:00
wasm-module-runner.h [wasm][fuzzer] Fix BigInt parameters 2020-08-26 14:22:19 +00:00