[BUG] Failed CSpace allocation consumes an identity before storage is reserved #12

Closed
opened 2026-09-14 14:29:11 +02:00 by erikinkinen · 0 comments
Owner

Summary

CSpace creation increments its finite identity allocator before reserving record storage. A heap-allocation failure consumes an identity despite returning no CSpace. The source also scans all live records to find each reusable ID, making repeated empty-space creation increasingly expensive as live population grows.

Reproduction

Compile the original Kernel release library at e6bea362f9199230bf84269b1a8da6bd8da6470d with its original pinned dependencies. In an independently owned host test process, initialize the root CSpace and create empty private spaces while rejecting actual allocation/reallocation requests only within each create operation. Detect the real vector growth boundary without assuming capacity. Restore normal allocation, create one more space and compare its identity with the last successful identity plus one.

The original regression executable uses a thread-local System allocator observer; assertions and output run after allocation rejection is disabled. It submits no IPC or privileged instruction. The retained control fails with actual ID 5 versus expected ID 4 after one rejected growth attempt.

Expected and actual behavior

Expected: failed storage reservation publishes no record and consumes no identity. Root protection, empty-only destruction and nonwrapping identity exhaustion remain intact. Reusing a destroyed record must not recover old capability slots.

Actual: the next-ID counter advances before fallible vector growth. The control returns KernelHeapExhausted, followed by successful creation with ID 5. The failed attempt to create ID 4 is not rolled back. No guest failure, unauthorized capability or observed ID-wrap event is attributed to this finding.

Environment and identity

Original signed Kernel e6bea362f9199230bf84269b1a8da6bd8da6470d; Rust 1.97.1; x86_64 Linux host; release library and original Git dependency objects. The fault control runs the actual CSpace object API in a separate process, with explicitly bounded command ownership. No dependency override is used.

Evidence and prior checks

The original control exits 101 with one failed test and clean process cleanup. The new implementation reserves before publishing a new ID, uses a vacant-entry chain for constant-time reuse, and validates emptiness and vacancy publication under the same table lock. Focused CSpace and allocation/lifetime tests pass; full formatting, strict Clippy, unit/doc, freestanding and native VM validation remains in progress.

A separate three-repetition host elapsed profile measures 32,768 create/destroy cycles at each retained population. Median reuse is 1.635981 ms at zero retained private spaces and 643.094176 ms at 32,768. Setup is measured separately. This identifies host scaling; it is not exclusive CPU time or a native guest performance result.

The actual allocator rejection control fails the original signed library with next ID 5 instead of 4; the corrected test covers repeated failed growth, initialization failure and allocation-free reuse.

Tracking

Owning audit #2 and Kernel PR 3. The owned invocation proposal #11 remains a separate design decision; this allocator correction does not select escrow storage or establish realm provisioning. Keep the issue open until the signed correction, strict matrices and relevant native/CI results are recorded.

## Summary CSpace creation increments its finite identity allocator before reserving record storage. A heap-allocation failure consumes an identity despite returning no CSpace. The source also scans all live records to find each reusable ID, making repeated empty-space creation increasingly expensive as live population grows. ## Reproduction Compile the original Kernel release library at `e6bea362f9199230bf84269b1a8da6bd8da6470d` with its original pinned dependencies. In an independently owned host test process, initialize the root CSpace and create empty private spaces while rejecting actual allocation/reallocation requests only within each create operation. Detect the real vector growth boundary without assuming capacity. Restore normal allocation, create one more space and compare its identity with the last successful identity plus one. The original regression executable uses a thread-local System allocator observer; assertions and output run after allocation rejection is disabled. It submits no IPC or privileged instruction. The retained control fails with actual ID 5 versus expected ID 4 after one rejected growth attempt. ## Expected and actual behavior Expected: failed storage reservation publishes no record and consumes no identity. Root protection, empty-only destruction and nonwrapping identity exhaustion remain intact. Reusing a destroyed record must not recover old capability slots. Actual: the next-ID counter advances before fallible vector growth. The control returns `KernelHeapExhausted`, followed by successful creation with ID 5. The failed attempt to create ID 4 is not rolled back. No guest failure, unauthorized capability or observed ID-wrap event is attributed to this finding. ## Environment and identity Original signed Kernel `e6bea362f9199230bf84269b1a8da6bd8da6470d`; Rust 1.97.1; x86_64 Linux host; release library and original Git dependency objects. The fault control runs the actual CSpace object API in a separate process, with explicitly bounded command ownership. No dependency override is used. ## Evidence and prior checks The original control exits 101 with one failed test and clean process cleanup. The new implementation reserves before publishing a new ID, uses a vacant-entry chain for constant-time reuse, and validates emptiness and vacancy publication under the same table lock. Focused CSpace and allocation/lifetime tests pass; full formatting, strict Clippy, unit/doc, freestanding and native VM validation remains in progress. A separate three-repetition host elapsed profile measures 32,768 create/destroy cycles at each retained population. Median reuse is 1.635981 ms at zero retained private spaces and 643.094176 ms at 32,768. Setup is measured separately. This identifies host scaling; it is not exclusive CPU time or a native guest performance result. The actual allocator rejection control fails the original signed library with next ID 5 instead of 4; the corrected test covers repeated failed growth, initialization failure and allocation-free reuse. ## Tracking Owning audit #2 and [Kernel PR 3](https://git.erikinkinen.fi/erix/kernel/pulls/3). The owned invocation proposal #11 remains a separate design decision; this allocator correction does not select escrow storage or establish realm provisioning. Keep the issue open until the signed correction, strict matrices and relevant native/CI results are recorded.
erikinkinen 2026-09-14 14:29:11 +02:00
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:34:25 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
erix/kernel#12
No description provided.