pub struct StackBudget(/* private fields */);Expand description
A native-stack budget a RuntimeContext may be minted with: a u32 proven
no larger than STACK_BUDGET_BYTES at construction.
The proof is the point. SHADOW_STACK_SLOTS is sized from
STACK_BUDGET_BYTES, on the strength of “a frame spends at least
FRAME_BYTES_PER_SLOT per slot it claims, so the slots of every live frame
sum to at most budget / FRAME_BYTES_PER_SLOT”. A host that could install a
larger budget would make shadow-stack overflow reachable from generated
code — silently, because generated code does not check the reservation. It
cannot: StackBudget::new is the only constructor and it refuses.
Same shape as SlotCount, and for the same reason: the
bound is checked once, where the value is made, and every consumer downstream
may assume it.
Implementations§
Source§impl StackBudget
impl StackBudget
Sourcepub const DEFAULT: StackBudget
pub const DEFAULT: StackBudget
The budget every Runtime starts with: the whole of
STACK_BUDGET_BYTES.
Sourcepub const fn new(bytes: u32) -> Option<StackBudget>
pub const fn new(bytes: u32) -> Option<StackBudget>
Some iff bytes is a budget the shadow-stack reservation covers.
const so a caller can prove a literal at compile time.
Trait Implementations§
Source§impl Clone for StackBudget
impl Clone for StackBudget
Source§fn clone(&self) -> StackBudget
fn clone(&self) -> StackBudget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more