inet_frag_queue_insert() assumes offset is smaller than end when it inserts a fragment into the interval tree. nf_ct_frag6_queue() can violate that assumption for an unclipped IPv6 skb: payload_len minus the extension header length underflows, leaving end smaller than offset. The invalid range then enters the left subtree and breaks the rbtree ordering. Reassembly can select a non-first fragment as the head, triggering inet_frag_reasm_prepare()'s WARN_ON(). On current mainline, the misplaced head also reaches the conditional one-byte out-of-bounds write in nf_ct_frag6_reasm(). Reject end <= offset in the shared insertion helper before inserting the range. Fixes: c23f35d19db3 ("net: IP defrag: encapsulate rbtree defrag code into callable functions") Signed-off-by: zhuorao yang <alex…@gmail.com> --- Vulnerability report Affected versions: Linux 7.4.0-rc5 at fe6ff8d5d675c01793b9f051d16055dd4aa75244; the rbtree form dates to v5.1. Trigger conditions: CONFIG_USER_NS and CONFIG_NET_ACT_CT. A local user can create a user and network namespace, configure tc ingress ct processing, and send the malformed IPv6 fragments. The same path is reachable from network traffic when such pre-L3 conntrack defragmentation is deployed. Reproducer status: A QEMU/KASAN reproduction on 7.4.0-rc5 reaches inet_frag_queue_insert(offset=8, end=0), triggers the inet_frag_reasm_prepare() WARN_ON(), and reports a one-byte KASAN write in nf_ct_frag6_gather(). The fixed kernel completes the same test without the warning or KASAN report. Reproducer material is available to maintainers on request. Reproducer material is intentionally withheld from this public message. AI assistance: DeepSeek identified the issue and drafted the patch. The submitter reviewed the code and certified the Developer Certificate of Origin. net/ipv4/inet_fragment.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index f330d0a39823..9f3b632f5753 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; + /* The reassembled skb keeps the first fragment's secpath. */ if (last && !secpath_equal(last, skb)) return IPFRAG_MIXED_SECPATH;
-- 2.56.0