Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpk: turn on memory_protection_keys during fuzzing #7393

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/fuzzing/src/generators/pooling_config.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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 changes: 1 addition & 1 deletion crates/runtime/src/mpk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down