Repository navigation
fragroute: size ip_frag/tcp_seg fragments by packet length (OSS-Fuzz 589370950) - #1229
Merged
fklassen merged 2 commits intoNov 29, 2026
Merged
Conversation
ip_frag and tcp_seg allocated each new fragment with pkt_new(pkt->pkt_buf_size). Since 1bb3eaa pkt_new() adds PKT_BUF_SLACK on top of the length it's given, so every stacked ip_frag rule grew each fragment's buffer by 86 bytes. A long rules file multiplied by ip_chaff dup made fuzz_fragroute time out (and run out of memory), and the pkt_buf_size-sized tmp_buf VLA grew with it. Size fragments by the source packet's length instead (plus the inserted fragment header for IPv6); a fragment is never larger than its source. OSS-Fuzz 589370950 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
OSS-Fuzz 589370950:
fuzz_fragroutetimeout inip_frag_apply_ipv4(). It regressed in 4.6.2.ip_frag(IPv4 and IPv6) andtcp_segallocated each new fragment withpkt_new(pkt->pkt_buf_size). Since 1bb3eaa (#1163),pkt_new()addsPKT_BUF_SLACKon top of the length it's given, so each stackedip_fragrule made every fragment's buffer 86 bytes bigger. Thepkt_buf_size-sizedtmp_bufVLA used for overlap grew along with it. If a long rules file also multiplies the queue withip_chaff dup, the run takes minutes and exhausts memory. For example, 10×ip_chaff dupfollowed by 4000×ip_frag 8OOMs at 2.2 GB under ASan on master; with this change it finishes in 3.7 s.Fix: size each fragment by its source packet's length, plus the inserted fragment header for IPv6. A fragment is never larger than the packet it came from.
Test:
test/unit/test_fragroute.cappliesip_frag(IPv4 and IPv6, 50 rounds) andtcp_segdirectly and asserts that no fragment's buffer is larger than its source's. Without the fix the three new assertions fail (1516 → 5816 bytes after 50 rounds); with it all 7 pass.make checkand thefragroute_*test targets pass under ASan+UBSan.First PR targeting the new
4.6.5release branch.