Browse Source

mpk: turn on `memory_protection_keys` during fuzzing (#7393)

This also twists the `max_memory_protection_keys` knob.
pull/7397/head
Andrew Brown 1 year ago
committed by GitHub
parent
commit
ecd37470fc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      crates/fuzzing/src/generators/pooling_config.rs
  2. 2
      crates/runtime/src/mpk/mod.rs

9
crates/fuzzing/src/generators/pooling_config.rs

@ -1,6 +1,7 @@
//! Generate instance limits for the pooling allocation strategy.
use arbitrary::{Arbitrary, Unstructured};
use wasmtime::MpkEnabled;
/// Configuration for `wasmtime::PoolingAllocationStrategy`.
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
@ -30,6 +31,9 @@ pub struct PoolingAllocationConfig {
pub async_stack_zeroing: bool,
pub async_stack_keep_resident: usize,
pub memory_protection_keys: MpkEnabled,
pub max_memory_protection_keys: usize,
}
impl PoolingAllocationConfig {
@ -62,6 +66,8 @@ impl PoolingAllocationConfig {
cfg.async_stack_zeroing(self.async_stack_zeroing);
cfg.async_stack_keep_resident(self.async_stack_keep_resident);
cfg.memory_protection_keys(self.memory_protection_keys);
cfg
}
}
@ -104,6 +110,9 @@ impl<'a> Arbitrary<'a> for PoolingAllocationConfig {
async_stack_zeroing: u.arbitrary()?,
async_stack_keep_resident: u.int_in_range(0..=1 << 20)?,
memory_protection_keys: u.choose(&[MpkEnabled::Auto, MpkEnabled::Disable])?.clone(),
max_memory_protection_keys: u.int_in_range(0..=20)?,
})
}
}

2
crates/runtime/src/mpk/mod.rs

@ -42,7 +42,7 @@ cfg_if::cfg_if! {
}
/// Describe the tri-state configuration of memory protection keys (MPK).
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum MpkEnabled {
/// Use MPK if supported by the current system; fall back to guard regions
/// otherwise.

Loading…
Cancel
Save