[BUG] Reject every malformed materialization relocation record before advancing the batch #7

Closed
opened 2026-10-12 00:28:56 +02:00 by erikinkinen · 0 comments
Owner

Summary

A malformed relocation record after the first valid record can terminate the batch iterator without making complete-batch validation fail. Procd can then apply only the decoded prefix while advancing its original relocation counter by the full declared count. This is a reliability defect in the existing authenticated Loaderd-to-Procd materialization protocol: an incomplete image can appear to have consumed all authoritative writes.

Reproduction

At the identified source revisions, construct the existing 24-byte batch prefix with a valid request/operation/transaction and record count two, followed by two exact 24-byte records. Record zero has relocation index zero, nonzero target 0x500000 and value one. Record one has index one, target zero and value two. The complete body is 72 bytes. Inspect ProcdApplyMaterializedRelocationBatchRequestV1::parse/new and then records().

The record parser refuses target zero, but the iterator converts that refusal to None. Complete validation uses that iterator and checks only that at least one record decoded, so its loop can end after the valid prefix. With an original active materialization and a writable first target, Procd derives progress from record_count() while the write loop consumes the truncated iterator. No test, image or VM has been run for this reproduction; this report is based on the exact source control flow. A literal first/middle/last malformed-record control will be authored as part of the correction.

Expected and actual behavior

Expected: every declared record must decode and validate before constructing an accepted batch, touching any process memory or advancing materialization progress. Any malformed record must refuse the complete batch and preserve output and original native cleanup custody.

Actual source behavior: a malformed non-first record ends the iterator; the validator can accept the declared batch, and the consumer can advance by records it did not write. Unknown or newly introduced patch widths must not create another path through this same defect.

Environment and identity

  • Component revisions: LibIPC 33993be8d2 and Procd e87738da669735065ec6e8e7c154f3d0ab0732d0.
  • Integration source graph: 49cef46d69793d2700be9ff9ccea4369d0d02e20; independent helper 6cad2280bea053419cfe4e43435219d1cc7ce740.
  • Image profile/digest, hardware/VM/firmware and toolchain run identity: none; source inspection only, with testing/builds/VM/CI observation currently deferred.
  • Input route/authority: the existing authenticated private Loaderd materialization endpoint and Procd's original retained stage/process cleanup owner; numeric records create no new capability. This report does not assert an authority bypass.
  • Last known working revision: unknown; the iterator-based validation is present in the identified source.

Evidence and prior checks

Original codec and validator contain the fallible record parser, Iterator::next returning parse(record).ok(), and complete validation over that iterator. Original Procd consumer derives expected progress from declared record_count() and writes the iterator's decoded prefix. These are read-only source observations, not executed regression results. No CI run, compiler result or hardware reproduction is claimed.

Tracking

Correct the complete-record validation while migrating production TLS materialization and exact-width patches. Keep LibIPC review, Procd review and phase completion synchronized. Preserve whole-batch refusal before output/native effects, exact plan order/counts and original cleanup on partial write failures. Author literal malformed-first/middle/last, mixed-width and unchanged-output/progress controls; execution remains deferred under the current testing waiver.

Exact-width materialization and complete raw-record refusal — 12 October 2026

Old scalar-only record/body widths reject and retired value fields are removed without aliases.

Complete-batch validation now decodes every raw record and propagates each refusal before exposing an accepted immutable iterator.

Fifteen new unit controls are authored and unrun: five literal codec/full-record controls, five mixed-width/span/boundary/failure/producer-state controls, three client correlation/refusal/uncertainty controls and two original graph producer/short-output controls. They include malformed-first/middle/last validation, no early output/native/progress/cleanup effect, exact bytes and untouched spare capacity, complete overflow refusal and original abort custody.

Actual TLS graph/module/template/immutable registry/image production, dedicated mapping geometry, libc resolvers, normal additional thread birth/FP inheritance, complete lifecycle and required imported/native consumers remain unfinished. Existing ELF/artifact TLS refusal stays. Both complete EriX guest generations and external Rust/LLVM rebuilding inside EriX remain mandatory and unperformed. Full native and TLS acceptance stays open; this exact-width stream is a prerequisite, not a substitute for complete producer adoption.

Related records and contracts
Repository Links
kernel issue 47
lib-cstd issue 1
lib-ipc relocation-patches.md
posixd issue 34
## Summary A malformed relocation record after the first valid record can terminate the batch iterator without making complete-batch validation fail. Procd can then apply only the decoded prefix while advancing its original relocation counter by the full declared count. This is a reliability defect in the existing authenticated Loaderd-to-Procd materialization protocol: an incomplete image can appear to have consumed all authoritative writes. ## Reproduction At the identified source revisions, construct the existing 24-byte batch prefix with a valid request/operation/transaction and record count two, followed by two exact 24-byte records. Record zero has relocation index zero, nonzero target 0x500000 and value one. Record one has index one, target zero and value two. The complete body is 72 bytes. Inspect ProcdApplyMaterializedRelocationBatchRequestV1::parse/new and then records(). The record parser refuses target zero, but the iterator converts that refusal to None. Complete validation uses that iterator and checks only that at least one record decoded, so its loop can end after the valid prefix. With an original active materialization and a writable first target, Procd derives progress from record_count() while the write loop consumes the truncated iterator. No test, image or VM has been run for this reproduction; this report is based on the exact source control flow. A literal first/middle/last malformed-record control will be authored as part of the correction. ## Expected and actual behavior Expected: every declared record must decode and validate before constructing an accepted batch, touching any process memory or advancing materialization progress. Any malformed record must refuse the complete batch and preserve output and original native cleanup custody. Actual source behavior: a malformed non-first record ends the iterator; the validator can accept the declared batch, and the consumer can advance by records it did not write. Unknown or newly introduced patch widths must not create another path through this same defect. ## Environment and identity - Component revisions: LibIPC 33993be8d2c3654de55e0c6637d46a805c1b4264 and Procd e87738da669735065ec6e8e7c154f3d0ab0732d0. - Integration source graph: 49cef46d69793d2700be9ff9ccea4369d0d02e20; independent helper 6cad2280bea053419cfe4e43435219d1cc7ce740. - Image profile/digest, hardware/VM/firmware and toolchain run identity: none; source inspection only, with testing/builds/VM/CI observation currently deferred. - Input route/authority: the existing authenticated private Loaderd materialization endpoint and Procd's original retained stage/process cleanup owner; numeric records create no new capability. This report does not assert an authority bypass. - Last known working revision: unknown; the iterator-based validation is present in the identified source. ## Evidence and prior checks [Original codec and validator](https://git.erikinkinen.fi/erix/lib-ipc/src/commit/33993be8d2c3654de55e0c6637d46a805c1b4264/src/body/bootstrap/procd_materialization.rs) contain the fallible record parser, Iterator::next returning parse(record).ok(), and complete validation over that iterator. [Original Procd consumer](https://git.erikinkinen.fi/erix/procd/src/commit/e87738da669735065ec6e8e7c154f3d0ab0732d0/src/runtime_materialization_batch.rs) derives expected progress from declared record_count() and writes the iterator's decoded prefix. These are read-only source observations, not executed regression results. No CI run, compiler result or hardware reproduction is claimed. ## Tracking Correct the complete-record validation while migrating [production TLS materialization and exact-width patches](https://git.erikinkinen.fi/erix/lib-dynlink/issues/4). Keep [LibIPC review](https://git.erikinkinen.fi/erix/lib-ipc/pulls/2), [Procd review](https://git.erikinkinen.fi/erix/procd/pulls/2) and [phase completion](https://git.erikinkinen.fi/erix/integration/issues/65) synchronized. Preserve whole-batch refusal before output/native effects, exact plan order/counts and original cleanup on partial write failures. Author literal malformed-first/middle/last, mixed-width and unchanged-output/progress controls; execution remains deferred under the current testing waiver. ### Exact-width materialization and complete raw-record refusal — 12 October 2026 Old scalar-only record/body widths reject and retired value fields are removed without aliases. Complete-batch validation now decodes every raw record and propagates each refusal before exposing an accepted immutable iterator. Fifteen new unit controls are authored and unrun: five literal codec/full-record controls, five mixed-width/span/boundary/failure/producer-state controls, three client correlation/refusal/uncertainty controls and two original graph producer/short-output controls. They include malformed-first/middle/last validation, no early output/native/progress/cleanup effect, exact bytes and untouched spare capacity, complete overflow refusal and original abort custody. Actual TLS graph/module/template/immutable registry/image production, dedicated mapping geometry, libc resolvers, normal additional thread birth/FP inheritance, complete lifecycle and required imported/native consumers remain unfinished. Existing ELF/artifact TLS refusal stays. Both complete EriX guest generations and external Rust/LLVM rebuilding inside EriX remain mandatory and unperformed. Full native and TLS acceptance stays open; this exact-width stream is a prerequisite, not a substitute for complete producer adoption. <details> <summary>Related records and contracts</summary> | Repository | Links | | --- | --- | | kernel | [issue 47](https://git.erikinkinen.fi/erix/kernel/issues/47) | | lib-cstd | [issue 1](https://git.erikinkinen.fi/erix/lib-cstd/issues/1) | | lib-ipc | [relocation-patches.md](https://git.erikinkinen.fi/erix/lib-ipc/src/branch/feature/posix-compat/docs/relocation-patches.md) | | posixd | [issue 34](https://git.erikinkinen.fi/erix/posixd/issues/34) | </details>
erikinkinen 2026-10-12 00:56:18 +02:00
  • closed this issue
  • added the
    docs
    label
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:34:47 +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/lib-ipc#7
No description provided.