🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6298

Re: [PATCH net v3] seg6: Fix unset mac header in SRv6 End.DT VRF decapsulation

#6298
From: Hangbin Liu
Date: Thu, 22 Oct 2026 05:19
90 lines
12343 bytes
On Wed, Oct 21, 2026 at 10:47:38AM +0800, Boyan Liu wrote:
> SRv6 End.DT4/End.DT6 VRF decapsulation unsets the mac header in
> end_dt_vrf_rcv() so that the VRF device can rebuild it for packet
> sniffers. The VRF rx handler only performs the rebuild when a
> sniffer is actually attached to the VRF device (ptype_all
> non-empty); otherwise the packet continues up the stack with
> mac_header == 0xffff.
> 
> Every other receive path delivers packets with a valid mac header:
> NIC drivers set it in eth_type_trans(), and tunnels without an L2
> header (ipip, sit, gre, tun) reset it to the network header after
> decapsulation. skb_mac_header() even warns on the unset state with
> DEBUG_NET_WARN_ON_ONCE().
> 
> If the decapsulated packet is an unexpected UDP GSO packet,
> udp_queue_rcv_skb() re-segments it after restoring skb->data to the
> mac header with __skb_push(skb, -skb_mac_offset(skb)). With the mac
> header unset, skb_mac_offset() returns a large positive value,
> which the unsigned __skb_push() argument turns into a huge length:
> skb->data moves far outside the buffer and skb->len is corrupted,
> so segmentation reads out of bounds:
> 
>     BUG: KASAN: slab-out-of-bounds in inet_gso_segment (net/ipv4/af_inet.c:1383)
>     Read of size 1 at addr ffff88800da7ffff by task exploit/149
>     Call Trace:
>      inet_gso_segment (net/ipv4/af_inet.c:1383)
>      skb_mac_gso_segment (net/core/gso.c:53)
>      __skb_gso_segment (net/core/gso.c:124)
>      udp_queue_rcv_skb (net/ipv4/udp.c:2476 net/ipv4/udp.c:2466)
>      udp_unicast_rcv_skb (net/ipv4/udp.c:2620)
>      ip_local_deliver (net/ipv4/ip_input.c:262)
>      seg6_local_input_core (net/ipv6/seg6_local.c:1640)
>      lwtunnel_input (net/core/lwtunnel.c:465)
>      ipv6_rcv (net/ipv6/ip6_input.c:351)
> 
> Restore a valid mac header once the VRF rx handler returns: point
> it at the network header, and reset mac_len, which still holds the
> ingress frame's L2 header length. The sniffer rebuild happens
> inside the handler while the header is still unset, so tap behavior
> is unchanged; when no rebuild happened, the packet now carries the
> same mac header state as any packet received on an L3 device.
> 
> Fixes: 664d6f86868b ("seg6: add support for the SRv6 End.DT4 behavior")
> Cc: stable@vger.kernel.org
> Reported-by: co+98d7de09cd94fec5@bugs.sh
> Signed-off-by: Boyan Liu <yymhvert@gmail.com>
> ---
> v3:
> - Also reset skb->mac_len with skb_reset_mac_len(), as suggested by
>   Andrea Mayer: it still held the ingress frame's L2 header length.
> v2: https://lore.kernel.org/netdev/20261017120144.3059-1-yymhvert@gmail.com/
> - Move the fix from the UDP GSO path to seg6local.
> - Restore the mac header after the VRF rx handler returns, preserving
>   the VRF sniffer behavior.
> - Verify the original reproducer, datagram delivery, and VRF sniffer
>   output under QEMU.
> v1: https://lore.kernel.org/netdev/20261010073015.7665-1-yymhvert@gmail.com/
> 
>  net/ipv6/seg6_local.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index 7b5212220185..4ef9d32907e5 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -1113,6 +1113,16 @@ static struct sk_buff *end_dt_vrf_rcv(struct sk_buff *skb, u16 family,
>  		/* the skb buffer was consumed by the handler */
>  		return NULL;
>  
> +	/* the VRF device had its chance to rebuild the mac header for
> +	 * sniffers; restore a valid one pointing at the network header,
> +	 * like any L3 device without an L2 header, before the packet
> +	 * continues up the stack.
> +	 */
> +	if (!skb_mac_header_was_set(skb)) {
> +		skb_reset_mac_header(skb);
> +		skb_reset_mac_len(skb);
> +	}
> +
>  	/* when a packet is received by a VRF or by one of its slaves, the
>  	 * master device reference is set into the skb.
>  	 */
> -- 
> 2.43.0
> 

Thanks for the fix.

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID: <atmczawXBSexpfPw@fedora>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350383-linux-kernel-netdev=dewy.ru
References: <20261021024738.17266-1-yymhvert@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350383-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3] seg6: Fix unset mac header in SRv6 End.DT VRF
 decapsulation
Date: Thu, 22 Oct 2026 13:19:09 +0800
Organization: Usenet Network
Message-ID: <atmczawXBSexpfPw@fedora>
References: <20261021024738.17266-1-yymhvert@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="134701"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:MejfBQ/sR1e6P01yX0YhDWYGxeQ= sha256:Ma8dmCznaSeWgf15qZxInKBjVrF1oA7ItX1BnKBBwLA=
	sha1:36UqkLy9N4RcKZKDD3Mvygy2xOs= sha256:y1wD+idrMTzvOf0FoEcHMuMu7J6nzdWC3T4bs011rkc=
Content-Disposition: inline
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 297F31111AA; Thu, 22 Oct 2026 08:19:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	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 (1024-bit key)
	header.d=linux.dev
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 gHLU7eQSOE2w;
	Thu, 22 Oct 2026 08:19:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350383-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id ECE0A10D9AF; Thu, 22 Oct 2026 08:19:41 +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 63ADF38A00; Thu, 22 Oct 2026 05:19:30 +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=1792646370;
	b=NRTc4PWilN532ok1bRSSoHl0cDgea0kZUnpy0fLnwODM+nFQNCc19gWgU4ayYU4mGAdT
	 LgyyhqZ/DLWBLX9wlCPl9FwfHPpbXsJLjcjZI/bvjSJzKujUKzByvMjr43DIvlT5IzrHV
	 RV8zC0zyEqDcGejaVT/MRxM2TZS7f5rIgOhP8c2P1+tuwyGr+eLrb6IN3DHTI6xIQobzv
	 kD4oUne3+s1FTzQN5NsVjB72skjKUfDUnjBaPvHh7t415jgLNRpnWrXTOnkIaJKRDQ1qt
	 Mbj3Yb0SKkqp59Gmy+46xed4EWU7/I7L4QGWzg1PxmRk5/DdpT3uf4JR6K56lhEPtBA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792646370;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=ClJ0+mcbYLWCO6jCQUFPvJuHbyK+fvSWo7IOSpnbA+o=;
	b=0J0HtSK8EuojcXqEmU8kTExSbbnQs5Ykgafwc/D/gCRZg90ddIZ4/puHkHNpvpHM2kvq
	 L2L49b/HDO76lIfxw4IVzr4Xjf0NdzMr3mkUNwWu+pembw56Lok1XmvuBzqx3dSIdLqH/
	 a0AuuQzxaIioHDlTeP+nKCxM2+D6TH4eEL1lzg1EFXl2hTlT+hYAZFbThIb1zN2UPgGrH
	 mGIUcetmsRNDtBPb0EGN7lwzN0CLJTI8Pd59Fc4ejwXggPdioAJTMuIhwkmFv92ezm7LZ
	 S/o+127+8DBOYm90X0hHZYQTnjKC4AImL80XBYiP0S+CHh46dpjPBwOCdwslp8A+PvQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=VgYMGP8E;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 36E83606A327;
	Thu, 22 Oct 2026 05:19:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=VgYMGP8E
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.94
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792646369;
	b=FzmK6RB/tV65xs695lQBZyhaFG9i9qJ2yyv4z9BxP2PRKh8NVK3dp7v7399EmVTseWC0
	 SiCU7+Wt6Rk5gDzXZVV5bMVHYcMLV5EXMhzLreoBxWNLvr49w2bWTXbw4b90NcXRIbMDR
	 7ZGsyi0Tjneqk0iRBxYBuJplJ328fkGgurBPw2B/a+xu2/gZNKsfmG0nxDMdzZ67LMlAk
	 bb1KTH3b/lE6/chfBiUr9UEztY86hAk+7l67WnCMWj4+Izkl0BZZVkHJE5EjnQhWsYyTB
	 JKgOIm9+lf4P9j2btHu0Y4+1Yk1wH2UwPYJKtR/Kt/bnaczdCOcAu8NmbzxyIlAbedQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792646369;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=ClJ0+mcbYLWCO6jCQUFPvJuHbyK+fvSWo7IOSpnbA+o=;
	b=NBlwnkf2RGN5vF1w9JIVARJb4WMbLYYknrsHLRG4w4Z3w2yET5jHA4WzxkcyVEAledv7
	 28EM+Zj4lJU4F/7l8DeHPU23gjVsDOfz3blIH1I5H4lbv+T/yGIV0INtHG2h27PuhalyU
	 InghcVkwIV9IpkT8zdKaqQO8lqShO2Thi6iqiaQdzRxCXBJWe2aQ6QZA+Tu92oIFmGcnS
	 waYFcPRckImmJ8WQAzD2yGEcRyopyrzrmnq6Z1bi/fY/+vtxCtXW0Lls0X4NXBcWFrrUg
	 AY8ysdKZxIy/ki/+52bI65ZRpUAPNUL9aL8yJ/hwXfWsffCH1BbbQOMHcux4hA4mVlQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=VgYMGP8E;
	arc=none smtp.remote-ip=95.215.58.94
X-Received: from mta1.migadu.com (out-94.mta1.migadu.com [95.215.58.94])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09704606A31D
	for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 05:19:27 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 09704606A31D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=RHVFBTbh8FahNaw5EWUek8qDsF+0xAqaAJBJ+B7LQbA=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1792646366; v=1; x=1793251166;
 b=VgYMGP8Eru0vGOlKUhCo/dh0h5L7Q56p9YixEMyBhb90zgBQ4YddKpjUGjoGo7sazo9OvfM7
 pvPOo9azFeQHu/KU+TSJcEO1bhlkt8fqtDon8rdneC3/mQJfIqB9GcLigT9kyDzPZ0Hugf5AjOB
 Z38rQrpI6aJM0LiHU7XtlRkQ=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta12.migadu.com with ESMTPS id 5914cadf4b4e6497;
	Thu, 22 Oct 2026 05:19:25 +0000
X-Mizu-Trace-ID: 5914cadf4b4e6497
X-Migadu-Flow: FLOW_OUT
X-Cc: Andrea Mayer <andrea.mayer@uniroma2.it>,
	David Ahern <dsahern@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	co+98d7de09cd94fec5@bugs.sh
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
X-In-Reply-To: <20261021024738.17266-1-yymhvert@gmail.com>