fix(mesh): drop oversized RX packets instead of asserting#10432
fix(mesh): drop oversized RX packets instead of asserting#10432DatanoiseTV wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the LoRa RX path in RadioLibInterface::handleReceiveInterrupt() by replacing an assert()-based bound check with a runtime length guard, avoiding panic-resets (and avoiding unchecked copies in NDEBUG builds) when an incoming packet’s encrypted payload is larger than the destination buffer.
Changes:
- Replaced the
assert(payloadLen <= sizeof(mp->encrypted.bytes))with a runtime size check. - On oversized RX payloads: log a warning, release the allocated packet, increment
rxBad, log RX airtime, and return early.
handleReceiveInterrupt bounded the encrypted-payload memcpy with an assert, which a future modem with a longer max payload would turn into a panic-reset on a malformed (or simply larger) air packet. Replace with a runtime length check that releases the pool entry, bumps rxBad, and returns. assert() also vanishes in NDEBUG builds, so there was no actual bound check in release.
5303074 to
277817b
Compare
|
Good catch — fixed in 277817b. The outer else branch increments |
| packetPool.release(mp); | ||
| // The outer else branch already incremented rxGood for this packet; | ||
| // undo that and reclassify as rxBad so num_packets_rx isn't double-counted. | ||
| rxGood--; |
There was a problem hiding this comment.
These statistics are really about whether it was correctly decoded when receiving over the air, which is the case (the CRC must have passed if you reach here), hence "rxGood" is still correct.
There was a problem hiding this comment.
i'm with @GUVWAF here. don't touch the RX statistics at all, just make it fail gracefully instead of asserting. Also aomething to note: this was in place originally as a 'safeguard' against people stuffing too much into a meshpacket, so more of a sanity check. Arguably a happy path decision.
caveman99
left a comment
There was a problem hiding this comment.
Please have a look at the failing tests. Can Probably ignore the 502 but the rest is of importance.
|
Tested this on a Nordic nRF54L15-DK with EBYTE E22-900M30S (SX1262)
LGTM as a port-side reviewer. Tested-by: cvaldess |
handleReceiveInterrupt bounded the encrypted-payload memcpy with an
assert, which a future modem with a longer max payload would turn into
a panic-reset on a malformed (or simply larger) air packet. Replace
with a runtime length check that releases the pool entry, bumps rxBad,
and returns. assert() also vanishes in NDEBUG builds, so there was no
actual bound check in release.
Split out from #10424 per @thebentern's request — single-concern PR.
Build verification
pio run -e t-deck-tftsucceeds, no new warnings.Attestations
t-deck-tftonly.