mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Victor Nogueira <victor@mojatatu.com>
To: Jun Yao <yaojun8558363@gmail.com>, netdev@vger.kernel.org
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
Subject: Re: [PATCH] xfrm: avoid stale tunnel pointers in deferred input callbacks
Date: Wed, 11 Nov 2026 11:01:42 -0300	[thread overview]
Message-ID: <0c970ddc-4cfc-4ee8-b0b9-6107a8804267@mojatatu.com> (raw)
In-Reply-To: <20261111094629.230568-1-yaojun8558363@gmail.com>

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

      parent reply	other threads:[~2026-11-11 14:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  9:46 Jun Yao
2026-11-11  9:52 ` netdev-bot+sinfo
2026-11-11 14:01 ` Victor Nogueira [this message]

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=0c970ddc-4cfc-4ee8-b0b9-6107a8804267@mojatatu.com \
    --to=victor@mojatatu.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=steffen.klassert@secunet.com \
    --cc=yaojun8558363@gmail.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

all inboxes | Powered by JetHome®