From 40721cae3572f5aabbba1de4a37f441528fdeca2 Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Tue, 16 Jul 2024 12:00:22 +0200 Subject: [PATCH] WASM PVM: Check for floats in the Fast Exec runtime There has been a long standing issue in the rollup node, where it would happily use WASMER to execute a kernel featuring floats. Under the hood, the culprit is actually the Fast Exec runtime, which is not defensive enough when loading a new kernel. This patch should fix this shortcoming, and ensure no commitment are wrongfully posted when a rollup ends up with a kernel featuring floats. --- src/lib_scoru_wasm/fast/module_cache.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib_scoru_wasm/fast/module_cache.ml b/src/lib_scoru_wasm/fast/module_cache.ml index af9b08c0b5a5..c4f5bceb87f7 100644 --- a/src/lib_scoru_wasm/fast/module_cache.ml +++ b/src/lib_scoru_wasm/fast/module_cache.ml @@ -39,6 +39,18 @@ let kernel_cache = Kernel_cache.create 2 let load_parse_module store key durable = let open Lwt.Syntax in let* kernel = Durable.find_value_exn durable key in + (* We use the WASM PVM to decode the kernel, not for using the result, + but to ensure the absence of floats. + + If the call fails, an exception is raised, which is later catch by the + Fast Exec. This effectively ensures WASMER will never be used with + kernels including floats. *) + let* _ast = + Tezos_webassembly_interpreter.Decode.decode + ~allow_floats:false + ~name:"boot.wasm" + ~bytes:kernel + in let+ kernel = Lazy_containers.Chunked_byte_vector.to_string kernel in Wasmer.Module.(create store Binary kernel) -- GitLab