From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796321687; b=DVVWNMhRUl/GOezDBIz9Yi2b7f3g/ZkTqto0Oxvr/1Y5jHl0/qR45eZKQapWN7plZ33Y wkv1T1iYxsVNle4TsLzfxoZPU41Dpxcbhs66hMVR4feMYyQI49fgKoHtxYYFfuHjsqDy3 1eRM/IYDhoc4szU0k29unNpj2ufLQ+76jhZk0HHDu5a8QW/tplywjZOOyNeiBiAVWC9rW H6fslmU9nPw5h6bO4qDC0K8LSJwP206ZUSZDReU6X7u+j5gEfxumgc9S0mnz5hHIxQeJO buFRIpF+XC4+rNiVZzyhZqhB7agRI7zp8e2pJeEbixu2LbwGsMt6jXLZaLfWMUgxDUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796321687; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=zc9whdgBuIVSBKJ0qDvTj/p8PsuRJ2lIJWKPNas73bo=; b=Fh0mcDOjB0fMDShEKJ+BjcNl+b1OEHzyXrEd1gh8TIl56bcNlfCgb4zvOI2PCJqFyHPg fAvC1plJHm1oKLoxDD9N/xDM4YyEKw/9AJOXj8rd7RaA8uNj16InNzI6NWkoG6inGNk/M QDwYwhLj75rBHoLlpMRxtZUCDkHn/t/l7VW+SE5EOmOpIxgqbSv5U9TZEiIGxC9Wl/KDG WySazLwNW6Z0AeymgkEn6hG5mG3pZ3tuTmj9IteARWN+8mbIASMjC3RvZaMUEZB8GAEIY ztE7Irt5iCQ0LIF/fLREIJB8Pq9OTjn6jHz5wmfSVPMPKvaN4skxkShFjYJRhpY/Ujg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jupOBKY9; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 819A2606A32D for ; Thu, 3 Dec 2026 18:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jupOBKY9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C7191F00893; Thu, 3 Dec 2026 18:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796321686; bh=zc9whdgBuIVSBKJ0qDvTj/p8PsuRJ2lIJWKPNas73bo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=jupOBKY9c0+uPoe6DaO1uWRIQvPx1EgENNBMCcvSza7v11shA6AilPdgdOp0TDMrh 4RaFMFa8OSOl0tUG1yE8LXjuTkExI/KC/Gzv6LCcdWyI1VwxZ1LuYwwKy9Q3a7V1Kq j1HQooY15hOT5LsukKUlVODXVwKTdz+Incy6hxy44Tkpb8dqDnXH6UZ+8HaCkn/bfu 5vjBoj57x0tl+hfZbpqZ4/1FFQ7CNaKvWFvtZhnzX3QH4S6dJ+NTttrCJRbCF3nhaI VMZvGf1vQRG/QRk510sepa4RKHhqSIuii6rY8ipTQ5YKf3bZ+9fCefAX7tOUHS3Iy4 LfWQe6Mzmb1+Q== Subject: Re: [PATCH net] net: ipv4: reject invalid fragment ranges From: netdev-bot+sashiko@kernel.org To: alex000young@gmail.com Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, netdev@vger.kernel.org Date: Thu, 03 Dec 2026 18:14:45 +0000 Message-ID: <179632168593.3146.17576515938905468722@kernel.org> In-Reply-To: <20261201031146.56825-1-alex000young@gmail.com> References: <20261201031146.56825-1-alex000young@gmail.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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/20261201031146.56825-1-alex000young%40gmail.com