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

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

Issue 2403093002: [wasm] Canonicalize function signature indices for matching in indirect calls. (Closed)
Patch Set: Add TODO for myself 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
Index: src/wasm/wasm-interpreter.cc
diff --git a/src/wasm/wasm-interpreter.cc b/src/wasm/wasm-interpreter.cc
index 2ac681eff293dbb1a640ebb16bf6c6e1347323a6..1d03852a2cfa33e9692151d653d91c5d854442db 100644
--- a/src/wasm/wasm-interpreter.cc
+++ b/src/wasm/wasm-interpreter.cc
@@ -1419,7 +1419,15 @@ 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.
+ const WasmIndirectFunctionTable* table =
Clemens Hammacher 2016/10/10 17:35:03 Maybe place a TODO to think about caching this ins
titzer 2016/10/10 17:45:21 Added a TODO here.
+ &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);

Powered by Google App Engine
This is Rietveld 408576698