๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25467

Re: [PATCH net v2] vrf: pull the full IPv4 header on xmit

#25467
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 20:45
108 lines
11670 bytes
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 fix is incomplete because the new IHL length check assumes
  the IPv4 header always starts ETH_HLEN bytes into the frame.

--

vrf: pull the full IPv4 header on xmit

This patch adds a check to vrf_process_v4_outbound(). The check drops IPv4
frames sent on a VRF device if ihl < 5, or if fewer than ihl * 4 header
bytes are present. The goal is to stop an skb->len underflow in
xfrm4_transport_output() that makes ESP walk off the end of the
scatterlist.

> diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
> index 79d433f49f803..d90b7e8fb158f 100644
> --- a/drivers/net/vrf.c
> +++ b/drivers/net/vrf.c
> @@ -499,6 +499,10 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
>  	if (!pskb_may_pull(skb, ETH_HLEN + sizeof(struct iphdr)))
>  		goto err;
>  
> +	if (ip_hdr(skb)->ihl < 5 ||
> +	    !pskb_may_pull(skb, ETH_HLEN + ip_hdr(skb)->ihl * 4))
> +		goto err;
> +

[Severity: High]

Is ETH_HLEN the right starting point for this length? ip_hdr() is read at
skb->network_header, but the pull length here is counted from skb->data
with a fixed ETH_HLEN. Later in the same function, the actual network
offset is stripped:

	/* strip the ethernet header added for pass through VRF device */
	__skb_pull(skb, skb_network_offset(skb));

Can vrf_xmit() get frames where skb_network_offset() is larger than
ETH_HLEN? This path looks like it can produce one:

1. An NBMA ipgre device (no remote, so header_ops is &ipgre_header_ops)
   has hard_header_len = tunnel->hlen + sizeof(*iph), which is at least
   24 bytes.

2. packet_snd() on a SOCK_RAW socket bound to that device sets
   reserve = hard_header_len. The network header therefore starts 24 or
   more bytes into the frame.

3. A tc clsact egress "mirred egress redirect dev vrf0" on the GRE device
   goes through tcf_mirred_to_dev(). The VRF device uses ether_setup(), so
   expects_nh is false. at_nh is also false, so the skb is passed on
   unchanged:

	expects_nh = want_ingress || !m_mac_header_xmit;
	at_nh = skb->data == skb_network_header(skb);
	if (at_nh != expects_nh) {

The GRE ingress side looks similar. __ipgre_rcv() calls
skb_pop_mac_header(), and mirred then pushes the outer IP + GRE mac_len
before the skb reaches the VRF device.

Take a network offset of 24, ihl = 15 and a frame length of 74 to 83:

  ETH_HLEN + ihl * 4 = 14 + 60 = 74, so the new check passes
  __skb_pull(skb, 24) leaves skb->len at 50..59, which is less than 60

If the route lookup returns a transport-mode ESP xfrm dst,
xfrm4_transport_output() runs this without checking the length itself:

	__skb_pull(skb, ihl);

Wouldn't skb->len then wrap the same way as in the oops in the commit
message?

If the skb is non-linear, could that __skb_pull() hit the
skb->len < skb->data_len BUG() instead?

The existing 20-byte check just above makes the same ETH_HLEN assumption.
Would checks relative to the network header be more robust, for example:

	if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
		goto err;

	if (ip_hdr(skb)->ihl < 5 ||
	    !pskb_network_may_pull(skb, ip_hdr(skb)->ihl * 4))
		goto err;

Every step above (GRE link, tc clsact/mirred, VRF, xfrm SA and policy,
AF_PACKET) can be set up inside an unprivileged user + net namespace. That
is the same privilege the reproducer in the commit message needs.

>  	ip4h = ip_hdr(skb);
>  
>  	memset(&fl4, 0, sizeof(fl4));

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130204412.632027-1-xmei5%40asu.edu
Technical Details
Message-ID: <179615792219.3146.18277936289940113941@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375355-linux-kernel-netdev=dewy.ru
References: <20261130204412.632027-1-xmei5@asu.edu>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375355-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] vrf: pull the full IPv4 header on xmit
Date: Tue, 01 Dec 2026 20:45:22 +0000
Organization: Usenet Network
Message-ID: <179615792219.3146.18277936289940113941@kernel.org>
References: <20261130204412.632027-1-xmei5@asu.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="1816043"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rVeKg1sU9XcYnAGXOZsXXiLd5HY= sha256:775C4sjQ4EIvl/yMFylheb0pHnp9+XNppMkCbIQPMLE= sha1:7nA0ntzykhtd87VVbkmJ8YhZROI= sha256:qw0lqQLdZxilQX1c3wSOCvSfqT5AYwHr4/SHAySreFs=
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 AAD0B117499; Tue,  1 Dec 2026 23:45:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[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, URIBL_BLOCKED=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 DzNSoTAXUNbm; Tue,  1 Dec 2026 23:45:37 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-375355-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 92AF611747B; Tue,  1 Dec 2026 23:45:26 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 08B6C602DBA; Tue,  1 Dec 2026 20:45:26 +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=1796157925; b=pDdb6GDfJZ7Fmwsu8E18gt+tyUi/Ivj/1oHuCZhPZvzYVgCLXv1azgrWIuGoKGVg41Dh WG9hMOosf6KR3HddZrK8P38gIKwz7NTUPX7XlUo/UHBH9plXdbpolwOXt0XGY1KLjiVW8 VlVMm6XV9dm9lrzF8w+XMU3gp/X7nBd45/941ACWrreLRiM8jzZAYpWWeUaF/0lnU3G9o VhT9rGNEejtMZbGpa0oulKEf8y9bj0tRPxO00xy9DzM3QL1/kNREHEPvTBXD1F1Kyxvsv 16r0TJbqyybOE5iJ1JBMzwP+z/9NcwTrhR8Fai8vIc7FFVmkJmA/6CmPtYjtrITLnKA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796157925; 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=0AaJduEZ7wfJaY5Vq7wb6cI/XnyhI/Ovesz8EZooNYA=; b=GUuIC9wbqxrNumsKEni7srRP1KiAz0Crk3gGAzvcDh9LHHXbZxiuiTgfOnlPUw4PsgYV dmYad35l001o03I+ltSzCBxuMRm08eYGTdQhVyISwxIcAwEhsajiQOqP9JBhufq8VjVlC okxPcZazpUAdBRuWHmQWVYs7UPExTVqHW8IDY64xKqMnnZESEBMEzu8aPjjlVKMkz+3j0 vtm1HXksE4oQ3RVzF5Ef6vlW9d8cSTV3i0w3K3rdANhI0prLRGifrLwfWuM/wcnp1D6ZP ZpyU8xtU3ymnNKupMWtCl5Nnr8xS+ZGTD6kwRl4GlkE/M7/eTUtRYEUSu5+LMTalDGw==
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=YzzOt8hL; 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 282CD606A331; Tue,  1 Dec 2026 20:45:25 +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=YzzOt8hL
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=1796157924; b=M4E52rC/rwqJnL5NZK8wehegYDx6g8FIHrQrsP8YVz9kYcWHwZXggckNwLvQLQjA2KIy cZJgPnBbfRBn76ksVs1A/yO17IKsrosr+DxePkjDyn6lAXfoBVdsjKRwZ75s5TyJwGxp8 5acvbkshBZvyl+zngeHWfEB49HzTqzFrdDuLXlhquHnCfdKthm9iu0lFPMz1ftqyHl6FL ZBZkCTPb7O3S3Q05wow31ZVsV+ROCRPwWckaXDJ3+p9Bi4g1L7ggZZI3e+SpZfiyQKyQ4 pujzF6uUG3HgCYtesSWItBHhPy1nCMSTxId0lhZ2V4fEYNNHdQNNVUKehj7nJ/uMgGQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796157924; 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=0AaJduEZ7wfJaY5Vq7wb6cI/XnyhI/Ovesz8EZooNYA=; b=oTE1bWWrMMKjYHytkubMQDUUgdd0h86tG4uZ+HG71xeHWcrVX1ckTrkWrMwMNsmZx7Xx Am8L/UUX0IcOCxM9lfP8diJAbPz5fqWytDe8xuE8srO/r8rv5LedJp2dVPAdQ0aSS1LhR 3UVHku3yGlNBgaUIpERwIEi7PksUH3I5BdP4jcZtNq2uss1oEnggoXkPfz2eRg59twrNx 5JK/70TPl/GNyuW0pjGOoQgDftmRn+gaI6BWoUB5GiOfL4QFeo98hLNVHtVunvDXOdmSq CyNbypeY/G+aBYBAYoCKuv/qQqMjUWLUCWfNUaZrLdLQyx43Z3eLITzF/82fi2CaT0A==
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=YzzOt8hL; 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 466DF606A320; Tue,  1 Dec 2026 20:45:24 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6B211F0089A; Tue,  1 Dec 2026 20:45:22 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796157923; bh=0AaJduEZ7wfJaY5Vq7wb6cI/XnyhI/Ovesz8EZooNYA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=YzzOt8hLv5/7r+SIVL6HtgRe/x+Ofxh0P3RlxjrKIEDxxsm+PRJ1HLOJd6PuatEuj wM1ONXw2i7BSuGmavo9Ifwjknq31K8YX3VT4uTWcQzrN5Mr92uvYhXf54IaccZdezd EtU23R/CZ/deN7B+cYTkSIKUDEVkQLRcsIBeHllztpbTsMYVE6Jh6H93WFaZ2Jvl71 FxDh+171rmOOmQejfKwvj1sCTSCGsK9zzCVYw0joMKLlhW86QPoHgm2snKH02BGcsy eizxpq2tS6GBDwIorrBo6NoGvY7Pz3XRNOcU4Ugi29FBA+ZvR+0bZrdtP4m4Ib/KL1 2q6HhRgeko+pA==
X-Cc: dsahern@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, co+bfd69dd4e073f1e9@bugs.sh
X-In-Reply-To: <20261130204412.632027-1-xmei5@asu.edu>
X-sashiko-severity: High
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