OpenDevicePartnership / OpenDevicePartnership/embedded-services
[mctp-rs] EOM-bit rebuild can spuriously fail packet serialization under stuffed encodings
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 23
- Forks
- 53
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 13
Description
From PR #844 review (Copilot):
When
end_of_messageflips to 1, the transport header is rebuilt and its encoded wire cost may increase under byte-stuffing. Returning an error whenrebuilt_header_wire_cost + consumed_wire > max_wirecan cause serialization to fail even though it could succeed by reducing the body chunk size and retrying with the EOM header. Consider recomputing chunk sizing using the final header (or iteratively shrinking the last chunk) instead of erroring.
Location: mctp-rs/src/serialize.rs:117
Reachability: PassthroughEncoding (SMBus/eSPI medium): never — header wire-size is constant regardless of EOM bit.
SerialEncoding (opt-in serial feature): possible when the EOM-flipped flags byte happens to encode to 0x7D or 0x7E (which need byte-stuffing → 2 bytes wire instead of 1). The chunking algorithm at the boundary of max_wire could fail rather than retrying with a smaller body.
Workaround: the existing inline comment notes "do not assume" — the error path returns a clear SerializeError("assembly buffer too small after EOM bit set") for diagnosis.
Fix sketch: when rebuilt_header_wire_cost + consumed_wire > max_wire, instead of erroring, shrink the last body chunk by the delta (or iteratively retry with smaller body.len()) and re-emit. Requires non-trivial chunking restructure in MctpPacketContext::serialize_packet.
Scope: out of scope for the source-bump PR #844 (which is a verbatim port of dymk/mctp-rs main @ 1b8b7f5); follow-up against the in-tree source.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in mctp-rs/src/serialize.rs:117 and trace MctpPacketContext::serialize_packet, focusing on the SerialEncoding path with the serial feature enabled. Reproduce the max_wire boundary where the EOM-flipped header gains a stuffed byte, then verify serialization retries with a smaller final body chunk instead of returning the assembly-buffer error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100