🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14566

Re: [PATCH] xfrm: avoid stale tunnel pointers in deferred input callbacks

#14566
From: Victor Nogueira
Date: Wed, 11 Nov 2026 14:01
80 lines
14180 bytes
Hi!

On 11/11/2026 06:46, Jun Yao wrote:
> IP-TFS input can be deferred while its reordering queue waits for a missing
> sequence number. The VTI receive callback stores a pointer to the tunnel in
> skb->cb, and the device can be removed and freed before the callback runs.
> 
> Keep only scalar tunnel metadata in an skb extension. The VTI callbacks
> look up the device by ifindex under RCU and check its link configuration
> before using its private data. If the VTI no longer exists, drop the
> deferred packet. Use the same metadata to preserve tunnel mark handling
> and IPv6 tunnel detection, and clear it when a new XFRM receive path starts
> and after the callback completes.
> 
> Signed-off-by: Jun Yao <yaojun8558363@gmail.com>
> 
> ---
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 6787fcf6a..f97412b95 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -5044,6 +5044,7 @@ enum skb_ext_id {
>   #endif
>   #ifdef CONFIG_XFRM
>   	SKB_EXT_SEC_PATH,
> +	SKB_EXT_XFRM_TUNNEL,
>   #endif
>   #if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
>   	TC_SKB_EXT,
> diff --git a/include/net/xfrm.h b/include/net/xfrm.h
> index 445223a8d..defdd4088 100644
> --- a/include/net/xfrm.h
> +++ b/include/net/xfrm.h
> [...]
>   
> -#define XFRM_TUNNEL_SKB_CB(__skb) ((struct xfrm_tunnel_skb_cb *)&((__skb)->cb[0]))
> +static inline struct xfrm_tunnel_info *
> +xfrm_tunnel_info_add(struct sk_buff *skb)
> +{
> +	return skb_ext_add(skb, SKB_EXT_XFRM_TUNNEL);
> +}
> +
> +static inline const struct xfrm_tunnel_info *
> +xfrm_tunnel_info(const struct sk_buff *skb)
> +{
> +	return skb_ext_find(skb, SKB_EXT_XFRM_TUNNEL);
> +}
> +
> +static inline void xfrm_tunnel_info_clear(struct sk_buff *skb)
> +{
> +	skb_ext_del(skb, SKB_EXT_XFRM_TUNNEL);
> +}

The above lines are causing build failures when XFRM is not enabled:

In file included from net/core/sock.c:134:
./include/net/xfrm.h: In function ‘xfrm_tunnel_info_add’:
./include/net/xfrm.h:777:33: error: ‘SKB_EXT_XFRM_TUNNEL’ undeclared 
(first use in this function); did you mean ‘DST_XFRM_TUNNEL’?
   777 |         return skb_ext_add(skb, SKB_EXT_XFRM_TUNNEL);
       |                                 ^~~~~~~~~~~~~~~~~~~
       |                                 DST_XFRM_TUNNEL
./include/net/xfrm.h:777:33: note: each undeclared identifier is 
reported only once for each function it appears in
./include/net/xfrm.h: In function ‘xfrm_tunnel_info’:
./include/net/xfrm.h:783:34: error: ‘SKB_EXT_XFRM_TUNNEL’ undeclared 
(first use in this function); did you mean ‘DST_XFRM_TUNNEL’?
   783 |         return skb_ext_find(skb, SKB_EXT_XFRM_TUNNEL);
       |                                  ^~~~~~~~~~~~~~~~~~~
       |                                  DST_XFRM_TUNNEL
./include/net/xfrm.h: In function ‘xfrm_tunnel_info_clear’:
./include/net/xfrm.h:788:26: error: ‘SKB_EXT_XFRM_TUNNEL’ undeclared 
(first use in this function); did you mean ‘DST_XFRM_TUNNEL’?
   788 |         skb_ext_del(skb, SKB_EXT_XFRM_TUNNEL);
       |                          ^~~~~~~~~~~~~~~~~~~
       |                          DST_XFRM_TUNNEL

---
pw-bot: cr
Technical Details
Message-ID: <0c970ddc-4cfc-4ee8-b0b9-6107a8804267@mojatatu.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361096-linux-kernel-netdev=dewy.ru
References: <20261111094629.230568-1-yaojun8558363@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361096-linux-kernel-netdev=dewy.ru
From: victor@mojatatu.com (Victor Nogueira)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] xfrm: avoid stale tunnel pointers in deferred input
 callbacks
Date: Wed, 11 Nov 2026 11:01:42 -0300
Organization: Usenet Network
Message-ID: <0c970ddc-4cfc-4ee8-b0b9-6107a8804267@mojatatu.com>
References: <20261111094629.230568-1-yaojun8558363@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="869556"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:/5M9ghT4hdAweS+8PT72jaYQv+s= sha256:KjE4P+4e7YJSbCesqS0dWxl1rMepHFanAE+dFEzGlQo=
	sha1:U/YgwQe6xYs0EIn3TU05zMDxhxg= sha256:3Y7oO7OxlCKJTCpJ0rDnyd3cZNfZOVuWaurppjD2xnE=
Content-Language: en-US
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 0ED2D113F0E; Wed, 11 Nov 2026 17:25:17 +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.249,
	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 (1024-bit key)
	header.d=mojatatu.com
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 1xPMo8YCIVpw;
	Wed, 11 Nov 2026 17:25:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-361096-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 2E413113EF8; Wed, 11 Nov 2026 17:25:03 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 94A9DE6119; Wed, 11 Nov 2026 14:01:56 +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=1794405712;
	b=XUPlUnH2SlqedcxS78/EE1VxXC8VgilHfJ+f+v+TIUO3+tntFH4NqQyivnCamEmNAEwu
	 HJH9raOmToazXfyYeRxsWXyNYJjzfowoEISD/UheZ489JxXEcZvAMnpY/1x4w6ACWbNLV
	 ByZMjHKNAB9+iHvbo5t3cW9UxiLiKpYMuCHOa2SbbCDANBdQai7DMcUu4T0SNXzPtEbJl
	 Jpdw1peGC/C8glHuKoXcNWm3FhvlvayJJvdqGUmNbrjle80i7gi1Zp06rVB/LidWKK+Mj
	 cVwzzE/PGx1ddNd2JUVOlPaHA4RxZabREjPjGztwdXXUse6R3aT5sGo63kBoZ59JrjA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794405712;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:Message-ID:Date:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:User-Agent:Subject:To:Cc:References:
	 Content-Language:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=O8NgyjtDYz4pyha39rltZunf2bBWHEXRkohajtNJskA=;
	b=hL3n68UC8Aum0SEPhRmLSrz5IwJ6p6zhbmwb8Ni/P5b93X+n/v1g8HP9vDwRprv9/iOE
	 WcZTRc8/S99fcd9m6sl1Tte/JIfVV8rpFZLALXsxIAb5FYc+QE9kMGqzspnblfE1bSb1D
	 qMsO3vv0Mr+ASHJNYIUZoX0IEEdPXe6cj0VfFTBthHs7WsEFwukDslVOss0iN4Y6dZS/s
	 1/SUg9YSx9j1iCdEOzzrjxacInMRHI6t9iI0nQG8946HB7xucUnBCIqmEej7nnlzjK9KP
	 hdZqJXMLUXEBT+ww8lV0gEEnBYSI528WI+/IeOhVqx2i4ZRWySjbhYlI5Yl0hLSunoQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=Wl5idHGG;
	dmarc=none header.from=mojatatu.com;
	spf=none smtp.mailfrom=mojatatu.com;
	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 79873606A33A;
	Wed, 11 Nov 2026 14:01:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=Wl5idHGG
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.54
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794405711;
	b=v8obBMQqTsh2F/68L7QmEPRwziAHsdBKd6OYcpozu64kAf8vtWNVsdqQCVM78TNpzJV+
	 Hgp0GKIbVhLbBNSjZ7ukXekHUC+OWcGyZEsEuA/HKFcYxUxMT5/nAychOhl5r11jSXziV
	 RvQV0mlUM2ACb66z2oNSVH+gmhszCQ9kbw1emnh/cyFscrLIQp4XkyOh0cMldtU4ZU1rk
	 WXY6RxBrswCAIgQ/xyTdxec0XtmS3c7kMmKlHKAzBerchREZjuVAWPdRsgRMe5EhKL/Bs
	 U854shyXcHCpgOzAsg5CvPoQBEJ3DBmJNPkiYS11iRqwoTAQo0/SpW93aDHlAvrJM4Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794405711;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:
	 Content-Language:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=O8NgyjtDYz4pyha39rltZunf2bBWHEXRkohajtNJskA=;
	b=YXomNpDuDOoTJCFZY9UhCLauAVeKIcJeeX6lSS8CalN77CEF+uXs4H2rvGWBg+4d5oIM
	 yty6B4Za5RLxzGjZ2GILniJVGXKmyLv86Xh/eCteqeFiNPZFuT1YsramkgNTbkHSMWBBi
	 zVzeRt72QQCBd+iBdviSYhJpQMol/ADX4+e5UGh48LM8h9vBFYRxYdtbmUXlYgSqa977/
	 L2zOnnvaWrV9T06W4I20W/OSJbHvDRjNsjHhqxPG7P0QgDO9yzxgpwp5klFBAd2UhfChT
	 yaJBI1M+8OIczZGNAa1aeZm++DyEZpNZlspglQEqNVwFeojLBFgBnQIxrGdKWgB8mXw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=mojatatu.com;
	spf=none smtp.mailfrom=mojatatu.com;
	dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=Wl5idHGG;
	arc=none smtp.remote-ip=74.125.82.54
X-Received: from mail-dl1-f54.google.com (mail-dl1-f54.google.com [74.125.82.54])
	(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 35875606A32A
	for <netdev@vger.kernel.org>; Wed, 11 Nov 2026 14:01:50 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 35875606A32A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com
X-Received: by mail-dl1-f54.google.com with SMTP id a92af1059eb24-1b3acec6677so4906535c88.1
        for <netdev@vger.kernel.org>; Wed, 11 Nov 2026 06:01:50 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=mojatatu.com; s=google; t=1794405710; x=1795010510; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:user-agent:mime-version
         :date:message-id:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=O8NgyjtDYz4pyha39rltZunf2bBWHEXRkohajtNJskA=;
        b=Wl5idHGG8+6GNQnjX94s0EZTSeshK00S72EEWd+SxHRyCQwBWnP8p+VmT0VkT1q31x
         Tdo1IFOqKdaT3o9I+rw5p40TBXTbPCOMWdKAlgJBNKNy6R6EFWfN7Ra9O//tp7AOpuwK
         7IGP9NhjK7O4hh4C5alKlt7KTJArDAT9AveXM=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794405710; x=1795010510;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:user-agent:mime-version
         :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=O8NgyjtDYz4pyha39rltZunf2bBWHEXRkohajtNJskA=;
        b=GgmVWC4SxuXCe1PYTCUDsM7kvvVmB2bIVgTofjYkGA5u9HXXfZbl5SJmmTzcPBQE3v
         4OTpdweeMQsE82j9y21N0JTmalalP9uwGQRMgBL02em6YZxUG4aPVAIe9zWMo9u9SSjq
         CP8YFQLrmG90tTIjRsA+cqBihTbdNsX+SjWEx0z39o6eCAJpn50gOPDyYWVetgPJNdWu
         iN3N3oiuR1AT5NBv3tLK4WUlRjuvisxCT1Hqt3pjiaElouixolneLQVEmAzQUYV0ml5e
         ahmZFzaI8jVSAZXkCn6i3mRlj1nvf236c7InAjnU6II1+P1+dOGDKl7JUgZ45jW5Bzhy
         n3EQ==
X-Forwarded-Encrypted: i=1; AL+hErHEHlHILRC8yM8BCVcRMB5/JsZCixoQAyDj5mTTy8f2qczqnIW4fw0LYI/F4MejoIZDGrr0Hlw=@vger.kernel.org
X-Gm-Message-State: APuU4Z8nRFZsQnhlGlhPshchoIc9+TB3HNhj6OwcXW8VOhy90BxbCSn1
	48ZB+pimraufVU+TbxARSoRcM52/QH4WqTHtRaDqbVpAr4RLn4+CdL5U3hJ7EQr55g==
X-Gm-Gg: AYBFou0JfEAElXE7Yp7dIbnb8dDnLKJzx2xrm0z3KkDsEo8T/AiaFVbRMNO8rrQ++3j
	vFO/aItLUvAxwbzgLhI8BURlu/1V6OrOAiAu0EWuRmiMuevECmEXM0HAj2KLIt9KTrk+scIpLaB
	1+ps9wPUraSyXSlOUQrGC3yD+y1RIaJxV+G8014OdNZ0/hYyIGxA2bExDos4KbVbhceDZxuCpmk
	ppuhKHFADoI8tw3sXaYzJtBnAfXoHwr2xLCvh0ldojCII2VDf0rFK58J4u/tKBniqVLAwVBWh7W
	NeVfI3gMOOyG+FUJyI7OEn/iKgnvVOM67Zh44MhXj3X60pKsqDC5uzI2wDI+goFFCI1K8QO7iZ6
	KIMelnJebMH/4m1XMq0wYDE8wdsYeqMxxEr1rm2/8tDJFjqF6Hcgd89CTOrYyOubwoOBignBtMG
	4NlREqaqauHh/NOFCkg7NhH48sxHaES/S/eHT3xuhnAR99Nxwy2wyDJTDNUZOoikfVQqzOIxhVS
	amT3crKCSzcj9G0eC1qOc2lm8k0RQmYLWH+YRUGdMizwQbKvWio9G+vC7pGSohKnCcGH9nllRQo
	eR5KpXTKSQv2hj5f+hU3Km4dDV+lPlB3WFDrL+0=
X-Received: by 2002:a05:701a:ca05:b0:1a2:fa1d:1de5 with SMTP id a92af1059eb24-1b3c2154fc8mr1737384c88.20.1794405709684;
        Wed, 11 Nov 2026 06:01:49 -0800 (PST)
X-Received: from ?IPV6:2804:14d:5c54:4d67::1c9d? ([2804:14d:5c54:4d67::1c9d])
        by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b3b5b2eeffsm16836234c88.9.2026.11.11.06.01.44
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Wed, 11 Nov 2026 06:01:48 -0800 (PST)
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-User-Agent: Mozilla Thunderbird
X-Cc: linux-kernel@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
 dsahern@kernel.org, idosch@nvidia.com
X-In-Reply-To: <20261111094629.230568-1-yaojun8558363@gmail.com>