pub struct RevocationState { /* private fields */ }Expand description
Revocation epoch tracking
Corresponds to Lean: structure RevocationState
INVARIANTS:
- caps is sorted by CapId, no duplicate IDs
caps[i].0 == caps[i].1.id()for all entries (keys match cap IDs)- Parent IDs are always less than child IDs (ParentLt)
- Valid capabilities have valid parents (ValidParentPresent)
- children_index is consistent with parent relationships in caps (ChildrenIndexConsistent)
- children_index is complete: every cap with a parent is in the index (ChildrenIndexComplete)
Implementations§
Source§impl RevocationState
impl RevocationState
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create empty revocation state
Corresponds to Lean: def RevocationState.empty : RevocationState
Sourcepub fn is_valid(&self, cap_id: CapId) -> bool
pub fn is_valid(&self, cap_id: CapId) -> bool
Helper: Find insertion point for sorted insert using binary search
Check if capability exists and is valid
Corresponds to Lean: def RevocationState.is_valid
Sourcepub fn get(&self, cap_id: CapId) -> Option<&Capability>
pub fn get(&self, cap_id: CapId) -> Option<&Capability>
Get a capability by ID
Sourcepub fn revoke(&self, cap_id: CapId) -> Self
pub fn revoke(&self, cap_id: CapId) -> Self
Revoke capability by ID (single cap only)
Corresponds to Lean: def RevocationState.revoke
Returns the new state with the capability revoked. If the capability doesn’t exist, returns the state unchanged.
Sourcepub fn revoke_mut(&mut self, cap_id: CapId) -> Result<(), KernelError>
pub fn revoke_mut(&mut self, cap_id: CapId) -> Result<(), KernelError>
Revoke capability by ID (mutating version)
§Errors
Returns KernelError::CapNotFound if the capability ID is not in the table.
Sourcepub fn has_ancestor(&self, cap_id: CapId, ancestor_id: CapId) -> bool
pub fn has_ancestor(&self, cap_id: CapId, ancestor_id: CapId) -> bool
Check if ancestorId is in the parent chain of capId
Corresponds to Lean: def RevocationState.has_ancestor
Uses a fuel parameter for termination (ParentLt guarantees termination with fuel = capId).
Sourcepub fn in_revoke_set(&self, k: CapId, cap_id: CapId) -> bool
pub fn in_revoke_set(&self, k: CapId, cap_id: CapId) -> bool
Check if cap_id is in the revoke set (id == cap_id OR has cap_id as ancestor)
Corresponds to Lean: def RevocationState.in_revoke_set
Sourcepub fn revoke_transitive(&self, cap_id: CapId) -> Self
pub fn revoke_transitive(&self, cap_id: CapId) -> Self
Revoke capability and all descendants transitively
Corresponds to Lean: def RevocationState.revoke_transitive
Sets valid=false on capId and any cap whose parent chain includes capId.
Sourcepub fn revoke_transitive_mut(&mut self, cap_id: CapId)
pub fn revoke_transitive_mut(&mut self, cap_id: CapId)
Revoke capability and all descendants transitively (mutating version)
Sourcepub fn insert(&self, cap: Capability) -> Result<Self, KernelError>
pub fn insert(&self, cap: Capability) -> Result<Self, KernelError>
Insert a capability (returns error on collision)
Corresponds to Lean: def RevocationState.insert
SECURITY: This function MUST check for ID collision to maintain the uniqueness invariant and prevent capability forgery via replacement.
Also maintains children_index for O(log n) revocation.
§Errors
Returns KernelError::CapIdCollision if a capability with the same ID already exists.
Sourcepub fn insert_mut(&mut self, cap: Capability) -> Result<(), KernelError>
pub fn insert_mut(&mut self, cap: Capability) -> Result<(), KernelError>
Insert a capability (mutating version)
Also maintains children_index for O(log n) revocation.
§Errors
Returns KernelError::CapIdCollision if a capability with the same ID already exists.
Sourcepub fn revoke_transitive_fast(&self, cap_id: CapId) -> Self
pub fn revoke_transitive_fast(&self, cap_id: CapId) -> Self
Add a child to the children_index (maintains sorted order)
Rebuilds the index using only Vec::new/push/len and array indexing. Semantically identical to the production version above. Revoke capability and all descendants transitively (O(k) optimized)
Corresponds to Lean: def RevocationState.revoke_transitive_fast
Uses children_index for O(k) traversal where k = number of descendants.
Sourcepub fn revoke_transitive_fast_mut(
&mut self,
cap_id: CapId,
) -> Result<(), KernelError>
pub fn revoke_transitive_fast_mut( &mut self, cap_id: CapId, ) -> Result<(), KernelError>
Revoke capability and all descendants transitively (O(k) optimized, mutating)
§Errors
Returns KernelError::CapNotFound if the capability does not exist.
Sourcepub fn valid_caps(&self) -> Vec<(CapId, Capability)>
pub fn valid_caps(&self) -> Vec<(CapId, Capability)>
Get all valid capabilities
Sourcepub fn iter(&self) -> Iter<'_, (CapId, Capability)>
pub fn iter(&self) -> Iter<'_, (CapId, Capability)>
Iterate over all capabilities
Returns a slice iterator over (CapId, Capability) pairs. This provides compatibility with code that uses .iter() on the caps.
Sourcepub fn any_valid_targeting(&self, target: ResourceId) -> bool
pub fn any_valid_targeting(&self, target: ResourceId) -> bool
Check if any valid capability targets the given resource
SECURITY: This check is CRITICAL for apply_free. If any valid capability targets an address, freeing that address would create a USE-AFTER-FREE vulnerability (dangling capability).
Corresponds to Lean: Memory safety guard in apply_free
Trait Implementations§
Source§impl Clone for RevocationState
impl Clone for RevocationState
Source§fn clone(&self) -> RevocationState
fn clone(&self) -> RevocationState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more