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

未关闭
#845 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
rust
领域
embedded-iot

调研方向

从 mctp-rs/src/serialize.rs:117 开始跟踪 MctpPacketContext::serialize_packet,重点关注启用 serial feature 时的 SerialEncoding 路径。复现 EOM 翻转后的 header 获得一个 stuffed byte 的 max_wire 边界,然后验证序列化会使用更小的最后一个 body chunk 重试,而不是返回 assembly-buffer error。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Rust
星标
25
派生
54
平均合并
3 天 9 小时
30 天内合并 PR
7

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OpenDevicePartnership/embedded-services 的其他 Issue

查看 OpenDevicePartnership/embedded-services 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。