Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: src/wasm/wasm-interpreter.cc

Issue 2403093002: [wasm] Canonicalize function signature indices for matching in indirect calls. (Closed)
Patch Set: Address review comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/signature-map.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-interpreter.cc
diff --git a/src/wasm/wasm-interpreter.cc b/src/wasm/wasm-interpreter.cc
index 2ac681eff293dbb1a640ebb16bf6c6e1347323a6..8064bf2765c71c483c743092aa638fb4075e58ee 100644
--- a/src/wasm/wasm-interpreter.cc
+++ b/src/wasm/wasm-interpreter.cc
@@ -1419,7 +1419,16 @@ class ThreadImpl : public WasmInterpreter::Thread {
if (target == nullptr) {
return DoTrap(kTrapFuncInvalid, pc);
} else if (target->function->sig_index != operand.index) {
- return DoTrap(kTrapFuncSigMismatch, pc);
+ // If not an exact match, we have to do a canonical check.
+ // TODO(titzer): make this faster with some kind of caching?
+ const WasmIndirectFunctionTable* table =
+ &module()->function_tables[0];
+ int function_key = table->map.Find(target->function->sig);
+ if (function_key < 0 ||
+ (function_key !=
+ table->map.Find(module()->signatures[operand.index]))) {
+ return DoTrap(kTrapFuncSigMismatch, pc);
+ }
}
DoCall(target, &pc, pc + 1 + operand.length, &limit);
« no previous file with comments | « src/wasm/signature-map.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698