[mctp-rs] EOM-bit rebuild can spuriously fail packet serialization under stuffed encodings

Open
#845 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
embedded-iot

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.

Description

From PR #844 review (Copilot):

When end_of_message flips to 1, the transport header is rebuilt and its encoded wire cost may increase under byte-stuffing. Returning an error when rebuilt_header_wire_cost + consumed_wire > max_wire can 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.

Dominant language
Rust
Stars
25
Forks
54
Avg merge
3d 9h
Merged PRs (30d)
7

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenDevicePartnership/embedded-services

All issues in OpenDevicePartnership/embedded-services

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.