Repository navigation
[CTX-0202] fix(render): bound headless surface allocation (CR-RENDER-01) - #346
Merged
Merged
Conversation
…(CR-RENDER-01) Headless present paths allocated width*height*4 unchecked, allowing extreme extents to OOM the host. Add MAX_HEADLESS_SURFACE_BYTES (64 MiB, mirroring software::MAX_SURFACE_BYTES) plus a u64 checked helper and enforce it in both present_draw_list and headless_present before any allocation. Adds fail-closed regression tests and a sw-fallback cap parity test. Task: CTX-0202 | FIND-0002 CR-RENDER-01
… (CR-RENDER-01) Plain u64 products overflow for extreme u32 extents ((u32::MAX^2)*4 exceeds u64::MAX), panicking under default overflow checks instead of returning InvalidInput. Use a checked_mul chain mapping any overflow to InvalidInput, same error contract.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Priority: P1 | Area: render | Labels: fix,area:render,P1 | Milestone: v0.1.0 | RFC: FIND-0002 | Task: CTX-0202
Closes #345
Summary
Headless present paths in
crates/bitty-render/src/gpu.rsallocatedwidth*height*4with uncheckedas usizearithmetic, so extreme extents could OOM the host (FIND-0002 CR-RENDER-01, memory/DoS).MAX_HEADLESS_SURFACE_BYTES(64 MiB), mirroringsoftware::MAX_SURFACE_BYTES(lives ingpu.rsbecausesoftwareissw-fallback-gated; a cfg-gated parity test pins them together).u64checked helperheadless_buffer_len(); bothpresent_draw_list(headless branch) andheadless_presentfail closed withRenderError::InvalidInputbefore allocating.InvalidInput; implementation was missing).Tests
headless_buffer_len_enforces_byte_cap_without_allocating: exact-cap boundary (4096x4096 ok), one-row-over fails,u32::MAXextremes fail.headless_present_rejects_extreme_extents_without_allocating: 5000x5000 (100 MiB) fails closed, stores no partial buffer, normal 32x16 frames still present afterwards.headless_cap_matches_software_cap(sw-fallback only): mirror cannot drift.Verification
cargo fmt -p bitty-render -- --check: cleancargo clippy -p bitty-render --all-targets -- -D warnings: cleancargo test -p bitty-render --lib: 131/131 passcargo test -p bitty-render --features sw-fallback --lib: 141/141 passcargo test -p bitty-render --all-targets: passcargo test --workspace --locked: 0 failurescargo check --target x86_64-pc-windows-gnu -p bitty-render --all-targets: cleanCarryCtx: CTX-0202 | Session: 01M1VDCXZEK98MFA6RNB7YTACG | Agent: core-impl-0202