Skip to content

fix: reject oversized payloads at LIN publish paths; correct E2E manual - #26

Open
SoundMatt wants to merge 1 commit into
mainfrom
fix/e2e-oversized-payload-validation
Open

fix: reject oversized payloads at LIN publish paths; correct E2E manual#26
SoundMatt wants to merge 1 commit into
mainfrom
fix/e2e-oversized-payload-validation

Conversation

@SoundMatt

Copy link
Copy Markdown
Owner

Summary

SAFETY_MANUAL.md documented the canonical ASIL-B E2E-protected publish
pattern as Protector::protect() output fed directly into
Bus::do_publish()/slave::Node::set_response(). protect() always
prepends a fixed kHeaderSize (10) byte header, which already exceeds
kLINMaxDataLen (8) for any payload, including a zero-byte one — so the
documented pattern can never actually fit in a single LIN frame. None of
the real publish paths validated payload length at all, so this silently
produced out-of-spec frames instead of failing loudly.

  • Bus::do_publish() now rejects any non-empty payload longer than
    kLINMaxDataLen with ErrInvalidFrame (an empty payload keeps its
    existing "unregister this ID" meaning). slave::Node::set_response()
    delegates to do_publish() and is covered transitively.
  • The RELAY adapter's LinAdapter::send() translates that same condition to
    ErrPayloadTooLargerelay::INode::send()'s documented contract
    (spec §10.1) only allows ErrClosed/ErrNotConnected/ErrTimeout/
    ErrPayloadTooLarge, so it can't just forward IBus's
    lin::Errc::invalid_frame raw (mirrors the existing precedent for
    invalid-ID handling right above it).
  • SAFETY_MANUAL.md §4.2 no longer presents the broken pattern as usable.
    It states the real numeric constraint, explains why no payload size makes
    it fit, and documents that Protector/Receiver are for use over a
    transport that can carry more than 8 bytes per logical message (e.g. a
    future multi-frame LIN diagnostic transport — not yet implemented, see
    ROADMAP.md) rather than direct single-frame publish, with a corrected
    example that never calls Bus::publish()/set_response() on protected
    output.

Closes #17

Test plan

  • ctest — 175/175 pass (4 new regression tests across
    test_virtual.cpp, test_slave.cpp, test_relay_adapter.cpp)
  • ASan+UBSan build — 175/175 pass
  • relay conform --strict / relay interop --protocol LIN — both PASS

SAFETY_MANUAL.md documented the canonical ASIL-B E2E-protected publish
pattern as safety::Protector::protect() output fed directly into
Bus::do_publish()/slave::Node::set_response(). protect() always
prepends a fixed kHeaderSize (10) byte header, so its output is always
>= 10 bytes -- but kLINMaxDataLen (8) already caps a LIN frame's data
field below that, for any payload including a zero-byte one. None of
the actual publish paths validated data.size() at all, so the
documented "safe" pattern silently produced out-of-spec frames instead
of failing loudly.

Fixes:
- Bus::do_publish() now rejects any non-empty payload longer than
  kLINMaxDataLen with ErrInvalidFrame (empty payload keeps its existing
  "unregister this ID" meaning and is unaffected). slave::Node::
  set_response() delegates to do_publish() and is covered transitively.
- The RELAY adapter's LinAdapter::send() translates that same condition
  to ErrPayloadTooLarge before it would otherwise leak
  lin::Errc::invalid_frame through relay::INode::send(), whose
  documented contract (spec §10.1) only allows ErrClosed,
  ErrNotConnected, ErrTimeout, or ErrPayloadTooLarge.
- SAFETY_MANUAL.md §4.2 no longer presents the broken single-frame
  pattern as usable. It now states the real numeric constraint,
  explains why no payload size makes it fit, and documents that
  Protector/Receiver are for use over a transport capable of carrying
  more than 8 bytes per logical message (e.g. a future multi-frame LIN
  diagnostic transport -- not yet implemented, see ROADMAP.md) rather
  than direct single-frame publish -- with a corrected example that
  never calls Bus::publish()/set_response() on protected output.

Closes #17

Signed-off-by: Matt <47545907+SoundMatt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASIL-B E2E-protected publish pattern always produces payloads exceeding kLINMaxDataLen, and no publish path validates length

1 participant