Skip to content

Fix comparison of none and unreachable types#2514

Merged
aheejin merged 1 commit intoWebAssembly:masterfrom
aheejin:type_less_than
Dec 9, 2019
Merged

Fix comparison of none and unreachable types#2514
aheejin merged 1 commit intoWebAssembly:masterfrom
aheejin:type_less_than

Conversation

@aheejin
Copy link
Copy Markdown
Member

@aheejin aheejin commented Dec 7, 2019

Currently none and unreachable types are stored as the same empty
{}
in src/wasm/wasm-type.cpp. This makes Type::operator< incorrectly
when given none and unreachable, because it expands both given types
and lexicographically compare them, when both of the expanded vector
will be empty.

This was found by the fuzzer. This line in Modder::visitExpression
tries to retrieve candidates of the same type. Because we can't really
compare these two types, if you give unreachable as the key,
candidates of none type can be returned. This generates incorrect code
that ends up failing in validation in a very weird way.

It was hard to generate a small testcase to trigger this part because it
was found by generating fuzzed code from a random data file. But I guess
this fix is pretty straightforward.

Fixes #2512.

Currently `none` and `unreachable` types are stored as the same empty
`{}` in src/wasm/wasm-type.cpp. This makes `Type::operator<` incorrectly
when given `none` and `unreachable`, because it expands both given types
and lexicographically compare them, when both of the expanded vector
will be empty.

This was found by the fuzzer. This line in `Modder::visitExpression`
tries to retrieve candidates of the same type. Because we can't really
compare these two types, if you give `unreachable` as the key,
candidates of `none` type can be returned. This generates incorrect code
that ends up failing in validation in a very weird way.

It was hard to generate a small testcase to trigger this part because it
was found by generating fuzzed code from a random data file. But I guess
this fix is pretty straightforward.

Fixes WebAssembly#2512.
@aheejin aheejin merged commit 72bacfd into WebAssembly:master Dec 9, 2019
@aheejin aheejin deleted the type_less_than branch December 9, 2019 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fuzz error after #2466

2 participants