Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The patch does not close the bug it says it fixes. -- net: ipv4: reject invalid fragment ranges This patch adds an end <= offset check to inet_frag_queue_insert(). The check rejects invalid fragment ranges that nf_ct_frag6_queue() can produce when payload_len underflows below the extension header length. The goal is to keep the rbtree ordered, which avoids the inet_frag_reasm_prepare() WARN_ON() and the one-byte out-of-bounds write in nf_ct_frag6_reasm().
> diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c > index f330d0a398233..9f3b632f57536 100644 > --- a/net/ipv4/inet_fragment.c > +++ b/net/ipv4/inet_fragment.c > @@ -444,6 +444,9 @@ int inet_frag_queue_insert(struct inet_frag_queue *q, struct sk_buff *skb, > { > struct sk_buff *last = q->fragments_tail; > > + if (end <= offset) > + return IPFRAG_OVERLAP; > +
[Severity: High] Does this check fully close the one-byte out-of-bounds write in nf_ct_frag6_reasm() that the commit message describes? It catches the case where payload_len underflows. But nf_ct_frag6_queue() still takes end from payload_len and never checks it against the bytes the skb actually holds: net/ipv6/netfilter/nf_conntrack_reasm.c:nf_ct_frag6_queue() { ... end = offset + (payload_len - ((u8 *)(fhdr + 1) - (u8 *)(ipv6_hdr(skb) + 1))); ... if (pskb_trim_rcsum(skb, end - offset)) { ... } pskb_trim_rcsum() returns 0 and does nothing when len >= skb->len. An skb that holds less data than its payload_len claims is therefore queued with the range [offset, end), even though its skb->len is smaller and can be 0. In the act_ct path, defragmentation runs first: tcf_ct_act()->tcf_ct_handle_fragments()->nf_ct_handle_fragments()-> nf_ct_frag6_gather() nf_ct_skb_network_trim() only runs after that, and it hits the same early return. Nothing rejects these short skbs before they reach the defrag queue. The native ip6_frag_queue() path is not affected, because ip6_rcv_core() has already checked skb->len against payload_len. inet_frag_queue_insert() detects overlaps with the real last->len and frag_run_len, not the claimed end. Consider this sequence of fragments, all with the same frag id, saddr and daddr: 1) Fragment Z has an IPv6 header and a fragment header with nexthdr set to NEXTHDR_NONE, frag_off 0 and IP6_MF set. Its payload_len is 16 and it carries no data (48 bytes total). ipv6frag_thdr_truncated() returns false, because ipv6_skip_exthdr() returns -1 on NEXTHDR_NONE. end is 8, but skb->len is 0 after pskb_pull(), so pskb_trim_rcsum(skb, 8) does nothing. The new end <= offset check passes. fragrun_create() makes a run with frag_run_len 0, and fq->nhoffset is set to 6. 2) Fragment D has offset 0, IP6_MF set, and 8 bytes of data behind about 1KB of hop-by-hop and destination options headers, so nhoff is about 1064. In inet_frag_queue_insert(): else if (FRAG_CB(last)->ip_defrag_offset + last->len < end) { ... if (offset == FRAG_CB(last)->ip_defrag_offset + last->len) fragrun_append_to_last(q, skb); Since 0 + 0 < 8, D takes the tail branch. offset == 0, so D is appended instead of returning IPFRAG_DUP or IPFRAG_OVERLAP. Then nf_ct_frag6_queue() overwrites nhoffset with D's value: if (offset == 0) { fq->nhoffset = nhoff; 3) The last fragment covers [8, 16). meat reaches 16, which equals q.len, so nf_ct_frag6_reasm() runs. The head is rb_first, which is Z at offset 0, so the WARN_ON() in inet_frag_reasm_prepare() never fires. But nhoffset came from D: skb_network_header(skb)[fq->nhoffset] = skb_transport_header(skb)[0]; Wouldn't this write an attacker-chosen byte about 1KB past the end of Z's 48-byte header area? That would land in the tailroom, in skb_shared_info, or past the allocation. The end <= offset check never fires here, because end (8) is greater than offset (0). An exact claimed-vs-real length check probably can't go into the shared helper, since lowpan_frag_queue() passes end = d_size (the whole datagram size). Would it work better to validate in nf_ct_frag6_queue() or nf_ct_frag6_gather()? Some options: - reject a payload_len that is smaller than the extension header length - reject skb->len < end - offset after pskb_pull() - have act_ct check and trim the skb against payload_len before defragmentation The check added here could stay as hardening.
> /* The reassembled skb keeps the first fragment's secpath. */ > if (last && !secpath_equal(last, skb)) > return IPFRAG_MIXED_SECPATH;
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com