Netdev List
 help / color / mirror / Atom feed
From: zhuorao yang <alex000young@gmail.com>
To: David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH net] net: ipv4: reject invalid fragment ranges
Date: Tue,  1 Dec 2026 11:11:46 +0800	[thread overview]
Message-ID: <20261201031146.56825-1-alex000young@gmail.com> (raw)

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 <alex000young@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


                 reply	other threads:[~2026-12-01  3:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201031146.56825-1-alex000young@gmail.com \
    --to=alex000young@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox