[BUG] Pipeline write overflow mutates retained bytes before refusal #15

Closed
opened 2026-09-30 20:59:09 +02:00 by erikinkinen · 0 comments
Owner

Summary

Launchd's retained pipeline writer appends accepted bytes before checking whether its cumulative write offset can represent them. At the u64 offset boundary, a rejected write can therefore change queued content while preserving the old offset. The source review found this during original stream metadata work; no runtime reproduction or practical route to that cumulative byte count is claimed.

Reproduction

Source-derived unit reproduction: create a one-byte-capacity native pipeline with its exact authenticated writer and reader, seed its retained cumulative write/read offsets at u64::MAX, then submit a one-byte write at that offset. Inspect the same original queue and offsets after LaunchStreamStateError::Overflow. A new focused control will retain this boundary without sending 2^64 bytes. It is authored but will remain unrun under the current testing waiver.

Expected and actual behavior

Expected: complete arithmetic admission before any byte, lifecycle, timestamp or offset changes; the overflow result preserves the entire prior object.

Actual source order: append_bytes changes the arena and byte_len, then checked_add fails. The error leaves the appended byte alongside the old cumulative offset. The fix moves offset and response-count conversion before the first append.

Environment and identity

Evidence and prior checks

The selected revision contains append_bytes(index, &request.data[..accepted])? before write_offset.checked_add(accepted_u64). The direct retained-state control will assert an empty unchanged queue, unchanged full-width offsets and no timestamp query on refusal. Tests, builds and CI observation remain deferred; this issue does not claim an executed failure or pass.

Tracking

Related original-source status feature, Launchd feature review and phase completion.

Original native stream event times — 30 September 2026

Alias creation, metadata queries, empty or refused operations and terminal device progress do not query a historical clock.

Ttyd receives an exact authenticated SEND-only Timed endpoint for this source purpose; Launchd uses its already admitted endpoint. Clean refusal remains Unknown.

The seeded boundary control retains the whole original object and proves the intended no-clock refusal contract when executed; no runtime reproduction or practical path to 2^64 bytes is claimed.

They cover source-event independence, unknown evidence, full-range dates, malformed replies, receipt cleanup, exact SEND-only admission, alias/retirement/reuse and overflow refusal. The existing realm workload now requires successful inherited fstat and original PTY clock evidence with stable birth before and after realm retirement; its independent transcript remains 385 calls.

The full status/directory feature remains open for complete FAT metadata and whole-feature integration. Both full EriX guest build generations and external Rust/LLVM rebuilding inside EriX remain required and unperformed.

Related records and contracts
Repository Links
docs PR 4
exsh PR 3
integration PR 12
launchd issue 15
lib-capabi PR 2
lib-ipc PR 2, stream-metadata.md
posixd PR 5
rootd PR 2
ttyd PR 3
## Summary Launchd's retained pipeline writer appends accepted bytes before checking whether its cumulative write offset can represent them. At the u64 offset boundary, a rejected write can therefore change queued content while preserving the old offset. The source review found this during original stream metadata work; no runtime reproduction or practical route to that cumulative byte count is claimed. ## Reproduction Source-derived unit reproduction: create a one-byte-capacity native pipeline with its exact authenticated writer and reader, seed its retained cumulative write/read offsets at `u64::MAX`, then submit a one-byte write at that offset. Inspect the same original queue and offsets after `LaunchStreamStateError::Overflow`. A new focused control will retain this boundary without sending 2^64 bytes. It is authored but will remain unrun under the current testing waiver. ## Expected and actual behavior Expected: complete arithmetic admission before any byte, lifecycle, timestamp or offset changes; the overflow result preserves the entire prior object. Actual source order: `append_bytes` changes the arena and `byte_len`, then `checked_add` fails. The error leaves the appended byte alongside the old cumulative offset. The fix moves offset and response-count conversion before the first append. ## Environment and identity - Component: [Launchd `0f1997119add18d48c2db41fc209c2798a63b3a0`](https://git.erikinkinen.fi/erix/launchd/commit/0f1997119add18d48c2db41fc209c2798a63b3a0), `src/stream_state_io.rs::apply_write_request`. - Integration graph: [Integration `c0e56fac9e2322bc61b8cbc991752f4502640606`](https://git.erikinkinen.fi/erix/integration/commit/c0e56fac9e2322bc61b8cbc991752f4502640606). - Image, hardware, firmware and toolchain: not exercised; this is a source-confirmed arithmetic/mutation ordering defect. - Route: the original admitted native pipeline writer; no additional capability is involved. - Last known working revision: unknown. ## Evidence and prior checks The selected revision contains `append_bytes(index, &request.data[..accepted])?` before `write_offset.checked_add(accepted_u64)`. The direct retained-state control will assert an empty unchanged queue, unchanged full-width offsets and no timestamp query on refusal. Tests, builds and CI observation remain deferred; this issue does not claim an executed failure or pass. ## Tracking Related [original-source status feature](https://git.erikinkinen.fi/erix/posixd/issues/25), [Launchd feature review](https://git.erikinkinen.fi/erix/launchd/pulls/2) and [phase completion](https://git.erikinkinen.fi/erix/integration/issues/65). ### Original native stream event times — 30 September 2026 Alias creation, metadata queries, empty or refused operations and terminal device progress do not query a historical clock. Ttyd receives an exact authenticated SEND-only Timed endpoint for this source purpose; Launchd uses its already admitted endpoint. Clean refusal remains Unknown. The seeded boundary control retains the whole original object and proves the intended no-clock refusal contract when executed; no runtime reproduction or practical path to 2^64 bytes is claimed. They cover source-event independence, unknown evidence, full-range dates, malformed replies, receipt cleanup, exact SEND-only admission, alias/retirement/reuse and overflow refusal. The existing realm workload now requires successful inherited fstat and original PTY clock evidence with stable birth before and after realm retirement; its independent transcript remains 385 calls. The [full status/directory feature](https://git.erikinkinen.fi/erix/posixd/issues/25) remains open for complete FAT metadata and whole-feature integration. Both full EriX guest build generations and external Rust/LLVM rebuilding inside EriX remain required and unperformed. <details> <summary>Related records and contracts</summary> | Repository | Links | | --- | --- | | docs | [PR 4](https://git.erikinkinen.fi/erix/docs/pulls/4) | | exsh | [PR 3](https://git.erikinkinen.fi/erix/exsh/pulls/3) | | integration | [PR 12](https://git.erikinkinen.fi/erix/integration/pulls/12) | | launchd | [issue 15](https://git.erikinkinen.fi/erix/launchd/issues/15) | | lib-capabi | [PR 2](https://git.erikinkinen.fi/erix/lib-capabi/pulls/2) | | lib-ipc | [PR 2](https://git.erikinkinen.fi/erix/lib-ipc/pulls/2), [stream-metadata.md](https://git.erikinkinen.fi/erix/lib-ipc/src/branch/feature/posix-compat/docs/stream-metadata.md) | | posixd | [PR 5](https://git.erikinkinen.fi/erix/posixd/pulls/5) | | rootd | [PR 2](https://git.erikinkinen.fi/erix/rootd/pulls/2) | | ttyd | [PR 3](https://git.erikinkinen.fi/erix/ttyd/pulls/3) | </details>
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:34:32 +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/launchd#15
No description provided.