fix: shrink E2E header so protected payloads fit a LIN frame; validate publish length - #29
Open
SoundMatt wants to merge 1 commit into
Open
fix: shrink E2E header so protected payloads fit a LIN frame; validate publish length#29SoundMatt wants to merge 1 commit into
SoundMatt wants to merge 1 commit into
Conversation
…e publish length The documented ASIL-B E2E-protected publish pattern (SAFETY_MANUAL.md §4.2: Protector::protect() output fed into Bus::publish()/ slave::Node::set_response()) was unimplementable as written: the E2E header (kHeaderSize = 10) alone already exceeded kLINMaxDataLen (8), so every protected payload -- even an empty one -- exceeded the LIN frame data limit. Nothing on the publish path checked data.size() against kLINMaxDataLen either, so an oversized payload was silently accepted and stored as a "valid" response rather than rejected. Two changes: 1. lin::safety wire format shrinks from a 10-byte header (DataID, SourceID, SequenceCounter, CRC-16, all transmitted) to a 3-byte header (1-byte SequenceCounter that wraps mod 256 + CRC-16). DataID and SourceID are no longer transmitted -- both ends of an E2E link already share an identical Config out of band, and DataID/SourceID remain bound into the CRC computation, so a receiver configured with a mismatched identity still gets a CRC error rather than silently accepting the wrong message. This leaves room for up to kLINMaxDataLen - kHeaderSize = 5 bytes of protected payload in a single LIN frame, instead of none. 2. virt::Bus::do_publish() (the sole concrete publish path, used by Bus::publish/publish_classic and transitively by slave::Node::set_response()) now rejects data.size() > kLINMaxDataLen with ErrInvalidFrame instead of silently accepting and storing it. Empty data remains a valid "clear response" signal, unaffected by this check. SAFETY_MANUAL.md §4.2's example is updated to reflect the real payload budget and to check bus->publish()'s returned error. Requirement titles/descriptions for REQ-SAFETY-001/002/003/004/005/ 006/007/010/012 are updated in both requirements/requirements.json and .fusa-reqs.json to match the new wire format; IDs are unchanged. Closes #17 Signed-off-by: Matt <47545907+SoundMatt@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The documented ASIL-B E2E-protected publish pattern (
SAFETY_MANUAL.md§4.2:
Protector::protect()output fed intoBus::publish()/slave::Node::set_response()) was unimplementable as written: the E2Eheader (
kHeaderSize = 10) alone already exceededkLINMaxDataLen(8),so every protected payload — even an empty one — exceeded the LIN
frame's data limit. Nothing on the publish path checked
data.size()against
kLINMaxDataLeneither, so an oversized payload was silentlyaccepted and stored as a "valid" response.
Fix
Shrink the E2E wire format from a 10-byte header (DataID,
SourceID, SequenceCounter, CRC-16, all transmitted) to a 3-byte
header (1-byte SequenceCounter, wraps mod 256, + CRC-16). DataID and
SourceID are no longer transmitted — both ends of an E2E link
already share an identical
Configout of band, and DataID/SourceIDremain bound into the CRC computation, so a receiver configured with
a mismatched identity still gets a CRC error rather than silently
accepting a message meant for a different logical data element. This
leaves room for up to
kLINMaxDataLen - kHeaderSize = 5bytes ofprotected payload in a single LIN frame, instead of none.
Validate publish length.
virt::Bus::do_publish()(the soleconcrete publish path, used by
Bus::publish/publish_classicandtransitively by
slave::Node::set_response()) now rejectsdata.size() > kLINMaxDataLenwithErrInvalidFrameinstead ofsilently accepting and storing it. Empty data remains a valid
"clear response" signal, unaffected by this check.
SAFETY_MANUAL.md§4.2's example is updated to state the real payloadbudget and check
bus->publish()'s returned error.Requirement titles/descriptions for
REQ-SAFETY-001/002/003/004/005/ 006/007/010/012are updated in bothrequirements/requirements.jsonand
.fusa-reqs.jsonto match the new wire format; IDs are unchangedper this repo's traceability convention.
Testing
tests/test_safety.cppfor the new 3-byte header layout;added regression tests for: header fits within
kLINMaxDataLen,counter wraparound mod 256, and DataID/SourceID mismatch surfacing as
a CRC error even though they're no longer transmitted.
tests/test_virtual.cppandtests/test_slave.cppconfirming oversizedpublish()/set_response()calls are rejected and not stored.ctest(176/176 passing).ctest(176/176 passing).Closes #17