๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23806

Re: [PATCH net] net: ife: reject headers that would overflow the network header offset

#23806
From: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 07:16
104 lines
11984 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 1 ยท High: 0 ยท 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).

- [Critical] The patch does not fully close the bug class it claims to
  fix.

--

net: ife: reject headers that would overflow the network header offset

This patch adds a bound check to ife_decode(). It rejects IFE frames when
the total pull plus the extra ETH_HLEN stripped by eth_type_trans() would
push the network header offset past U16_MAX. The aim is to stop the u16
network_header from being truncated, which later lets skb->data be moved
to a wild address on the forwarding path.

> diff --git a/net/ife/ife.c b/net/ife/ife.c
> index 2ddf725d3389e..272e457517360 100644
> --- a/net/ife/ife.c
> +++ b/net/ife/ife.c
> @@ -79,6 +79,14 @@ void *ife_decode(struct sk_buff *skb, u16 *metalen)
>  	if (unlikely(ifehdrln < 2))
>  		return NULL;
>  
> +	/* The caller strips one more ETH_HLEN via eth_type_trans() and
> +	 * then resets the network header, whose offset is a u16.  A
> +	 * larger pull would silently truncate the offset and leave the
> +	 * stack with a negative network offset.
> +	 */
> +	if (unlikely(skb->data - skb->head + total_pull + ETH_HLEN > U16_MAX))
> +		return NULL;

[Severity: Critical]
Is this bound tight enough? It still lets the final network header
offset be anything up to exactly U16_MAX. That leaves no room for the u16
offsets the stack computes from network_header afterwards.

After ife_decode() returns, tcf_ife_decode() in net/sched/act_ife.c does:

	skb->protocol = eth_type_trans(skb, skb->dev);
	skb_reset_network_header(skb);

So network_header can end up anywhere in the range up to 65535. Then
ip_rcv_core() in net/ipv4/ip_input.c stores into the __u16 field:

	skb->transport_header = skb->network_header + iph->ihl*4;

With network_header in [65516, 65535] and ihl=5, or a wider window when
IP options are present, this sum wraps. The result is transport_header
smaller than network_header.

On local delivery, ip_local_deliver_finish() then does:

	__skb_pull(skb, skb_network_header_len(skb));

skb_network_header_len() returns the u32 value
transport_header - network_header, which here is about 0xFFFF0014. In
__skb_pull(), skb->len wraps upward, so this check never fires:

	if (unlikely(skb->len < skb->data_len))

After that, skb->data has moved about 4 GiB forward. Isn't this the same
"negative offset pulled as an unsigned length" primitive the commit
message describes? The difference is that it shows up on the local
delivery path (ip_rcv -> ip_rcv_core -> ip_local_deliver ->
ip_local_deliver_finish) instead of neigh_resolve_output(). The L4
handlers (icmp_rcv(), udp_rcv(), tcp_v4_rcv()) would then read through
the wild skb->data with an inflated skb->len.

The sender seems to control the offset precisely. metalen is a u16 taken
from the packet. The TLV walk in tcf_ife_decode() accepts any run of
4-byte aligned unknown TLVs and only bumps the overlimit counter. That
means ifehdrln can be stepped in 4-byte increments to land inside the
20-byte IPv4 wrap window.

IPv6 has the same u16 wrap in ip6_rcv_core() in net/ipv6/ip6_input.c:

	skb->transport_header = skb->network_header + sizeof(*hdr);

This happens when network_header is above 65495. On local delivery the
pskb_pull() length check in ip6_protocol_deliver_rcu() appears to catch
it, but the stored transport offset is still bogus.

Would it be better to leave real slack below U16_MAX for the headers
derived later, or to cap the IFE metadata length / total offset at a
sane value, instead of only checking that the network header offset
fits?

> +
>  	if (unlikely(!pskb_may_pull(skb, total_pull + ETH_HLEN)))
>  		return NULL;
>

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127063006.2908187-1-bsdhenrymartin%40gmail.com
Technical Details
Message-ID: <179585016449.3135.6106864949030175850@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373040-linux-kernel-netdev=dewy.ru
References: <20261127063006.2908187-1-bsdhenrymartin@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373040-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: ife: reject headers that would overflow the
 network header offset
Date: Sat, 28 Nov 2026 07:16:04 +0000
Organization: Usenet Network
Message-ID: <179585016449.3135.6106864949030175850@kernel.org>
References: <20261127063006.2908187-1-bsdhenrymartin@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="902929"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:H3lYbtQ1CCzNV17ZBF6yDVdJpOA= sha256:DIAhxPqWIJ/uqX8kdfUHTFLDtQhC2gOwjAm2g6QCqME=
	sha1:kog+Ay0QfIkc0cJ8nn+3gNBn0Zc= sha256:qFGVQWqPo5e5WdcV1tBavcrpjwHA+MgpU8K8pPHeZXk=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id EA7E7125F72; Sat, 28 Nov 2026 10:16:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id X_GNXOO-Yqtk;
	Sat, 28 Nov 2026 10:16:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373040-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 98BB1125F6B; Sat, 28 Nov 2026 10:16:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 4FF2B2B64F; Sat, 28 Nov 2026 07:16:07 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795850167;
	b=lkc8ca1fkgwDAYgdEj/uAM+8GOcmG330u7gdVd2dgbrkpmPb9AOOtWBo1WpT6xBdaLGX
	 dmIHOmuFfXy8czG8bFq8wbJ9TixutbGi0oQo8+VrFh4eS+Hit46/F8eFKuqSLX1NqLsCp
	 J5z+k4uBhbTi+OiB30cDMp0GS2pPC7Sj1XQu8QIYLfah49XO0FZRWEDnYWLgh7b+AiRuw
	 xhTtAFAuc+7rUTTrysAxttvWW6HUfGgGWULoqjcqf0rYsTH8hgYjWtC7WAjIn6GtQ322i
	 m8I7TpOk88sZyOWL2eUcH3qjKmi244EPZ8MFllzQTeo1wIlZeoEIlSrdJ/tFNCyA+Gw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795850167;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=54W8KTLK5TfZwNOBXKWcoX2SzNwA1huYT2IQox7uzQw=;
	b=3NmE3DQN5ve5tBzcGD+1AJzzRfP0yOXdJz2C7tLKXpPU9X5DMhX8Z5Qcx3gXM5POEojB
	 e8CbPgqZSs0F3mVCnfQHx/wYu5+C6u6nIpwJtQLm4Nvca6YV7xZazqadP+W2QFA4GSd93
	 cIKTScc77sSOPY1tpY71qZeVpg+pEcDaMjw8/ptiYudgMyM6e1mLwGsUbH6pdXRwJIxPD
	 QS2TeOWlo8m3U69xjZji9xrOL4O0Q/P/VzRv3r1RRRhgrjhmX6n03O25LmSCPZFzJC7La
	 GX7+bNU/f1bFDwn/Vi0DUcnC5w9j6bgtUIDghyJpoeFxsMXo7FQi6/WrSpZ0dau455A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="g2/NUCQC";
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id DF946606A32A;
	Sat, 28 Nov 2026 07:16:06 +0000 (UTC)
X-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=g2/NUCQC
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795850166;
	b=5PI1CDgHZrfFt31YzS5etKqeHBICDs6UBesJsHg2GrooVVXHRKXImqcMZl2aLGKdPJ56
	 +ryROMbU7Al2ig4iM8rXuZnDBjw/HLXg6QYfStnA3TrtRqm7mZwyZUTo3TTbF4uAfA6BH
	 Vz7MRNECDNtg+rFnqVRoU0S0vvDb6LNYAiscVS+g0O3cikel2g/3r2sKEGnU9VmO6vqqD
	 t6SmzTnsUJUdjD0eTD1VZUhk539yXduc0utZDB+Ki9yPGW4O5NYBGeUfJOVKE3dFs8CvS
	 XSCR+MEK/CZPevdwCShulYWEzvDx5jiRb4YNKe+A4QvEr4sV4Ntlo6vypgBdjP6T+Pg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795850166;
	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=54W8KTLK5TfZwNOBXKWcoX2SzNwA1huYT2IQox7uzQw=;
	b=bgtVc5/TwwNTWdd7Tc3T6DUVqE2LORuUYO+F/3CD/Iog375JbbeeWDypkQnRAjsjuUM2
	 NJoEhnjwfCP6fEUBmw6rDLzaCFyIZ034ffGgJyuwHMjbRYS20lhW9RLfIcmxxb1eT1Uj3
	 wllUtyHaBVDtD/bMuedrRnC++A9lvRt65j4+x5rt8zjQEHPeHOTojvgLJopPtz6+kpTpx
	 rjjABqo2qRCj1qNQPi7zo58C86OZi0O8FgN9/fDZX/quva0BEyGHrwOu2Keiz2+m2Rgx7
	 Y6xgBFJrOaNEypZLSpaZlOrP2uZU7us9HuCo4jsz/xW94Sugdj7Xbmi04rRBhb4cCCA==
X-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="g2/NUCQC";
	arc=none smtp.remote-ip=100.103.45.18
X-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 0969D606A31C;
	Sat, 28 Nov 2026 07:16:05 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01AB21F00897;
	Sat, 28 Nov 2026 07:16:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795850165;
	bh=54W8KTLK5TfZwNOBXKWcoX2SzNwA1huYT2IQox7uzQw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=g2/NUCQCaaCOwM4InyuvCtBdKkzBTCLrVF4mhjcJgAHrs0PLZiWf3iwg/oaP1YpAa
	 uhT2hi/XoUHSA1mZ7ty45SFT6s2rgHzjdx9K/E0KpkQ2R6wkz6FK1NxNyvNA7jFpB2
	 FvRJcRA4g897QzJd/ix1xdGdom6/NKVJpeqThOXtDEc3Us0CIUZrdoec9lc11+zTap
	 f086PKP9V8GHIrgnnLsSo+F6yWNrmb5T/XiZ2Ede1i+m1A/FdDWrWAH2VWQmM36c5o
	 HHS6q3X2TpbrRYRemxtJsxf4DtWgwtYj7npiOlRpfkOskqI9F2E7g8k25ShEOiIZhU
	 XJQplnXOHo4pw==
X-Cc: yotam.gi@gmail.com, jhs@mojatatu.com, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 victor@mojatatu.com, netdev@vger.kernel.org, stable@vger.kernel.org
X-In-Reply-To: <20261127063006.2908187-1-bsdhenrymartin@gmail.com>
X-sashiko-severity: Critical
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list