From e96bb3dfeda472e1d721ded85758936e69a1ea86 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 8 Jul 2020 07:36:35 -0700 Subject: [PATCH] Disallow module linking sections by default Only allow module linking sections, even if they're empty, to show up if the module linking feature is enabled. --- crates/wasmparser/src/validator.rs | 5 +++++ tests/local/missing-features/linking-not-enabled.wast | 7 +++++++ tests/roundtrip.rs | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/local/missing-features/linking-not-enabled.wast diff --git a/crates/wasmparser/src/validator.rs b/crates/wasmparser/src/validator.rs index d8fbe2b317..2abe3bf347 100644 --- a/crates/wasmparser/src/validator.rs +++ b/crates/wasmparser/src/validator.rs @@ -610,6 +610,11 @@ impl<'a> ValidatingParser<'a> { Some(state) => state, None => return Ok(self.cur_module().section_order_state), }; + if state == SectionOrderState::ModuleLinkingHeader + && !self.config.operator_config.enable_module_linking + { + return self.create_error("module linking proposal not enabled"); + } Ok(match self.cur_module().section_order_state { // Did we just start? In that case move to our newly-found state. Initial => state, diff --git a/tests/local/missing-features/linking-not-enabled.wast b/tests/local/missing-features/linking-not-enabled.wast new file mode 100644 index 0000000000..9de4cc48a4 --- /dev/null +++ b/tests/local/missing-features/linking-not-enabled.wast @@ -0,0 +1,7 @@ +(assert_invalid + (module binary + "\00asm" + "\01\00\00\00" + "\64\01\00" + ) + "module linking proposal not enabled") diff --git a/tests/roundtrip.rs b/tests/roundtrip.rs index 5a3ed63a0d..7707f67b32 100644 --- a/tests/roundtrip.rs +++ b/tests/roundtrip.rs @@ -665,7 +665,7 @@ impl TestState { }; for part in test.iter().filter_map(|t| t.to_str()) { match part { - "testsuite" | "wasmtime905.wast" => { + "testsuite" | "wasmtime905.wast" | "missing-features" => { config.operator_config.enable_threads = false; config.operator_config.enable_reference_types = false; config.operator_config.enable_simd = false;