BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jakub Sitnicki" <jakub@cloudflare.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v3 1/2] net: lwtunnel: Drop skb metadata before LWT encapsulation
Date: Sat, 20 Jun 2026 17:09:50 +0000	[thread overview]
Message-ID: <20260620170951.580641F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260619-bpf-lwt-drop-skb-metadata-v3-1-71d6a33ab76b@cloudflare.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling `skb_metadata_clear(skb)` on a potentially cloned SKB modifies the shared `skb_shinfo` structure without exclusive access, leading to a data race and silent data corruption for other clones.
--

commit a6915ae09d5ba82236d77c5574df958bccb552d5
Author: Jakub Sitnicki <jakub@cloudflare.com>

net: lwtunnel: Drop skb metadata before LWT encapsulation

This commit clears skb metadata before lwt encapsulation across all dispatch
helpers. It prevents non-bpf lwt encapsulations from overwriting metadata in
the headroom and stops bpf lwt xmit from triggering warnings due to metadata
position during skb_data_move().

> diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c
> index f9d76d85d04fd..b01a395d9a966 100644
> --- a/net/core/lwtunnel.c
> +++ b/net/core/lwtunnel.c
> @@ -350,6 +350,8 @@ int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb)
>  	rcu_read_lock();
>  	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
>  	if (likely(ops && ops->output)) {
> +		/* Encap pushes outer headers over the metadata; drop it. */
> +		skb_metadata_clear(skb);

[Severity: High]
Does calling skb_metadata_clear() here modify the shared skb_shinfo
structure without ensuring exclusive access?

Since skb_metadata_clear() modifies skb_shinfo(skb)->meta_len, if the
buffer is cloned (for instance, via tc mirred or multicast forwarding),
this might cause a data race and corrupt the metadata for other clones still
processing the packet.

Should we unshare the skb first to safely modify the shared info?

>  		dev_xmit_recursion_inc();
>  		ret = ops->output(net, sk, skb);
>  		dev_xmit_recursion_dec();

[ ... ]

> @@ -404,6 +406,8 @@ int lwtunnel_xmit(struct sk_buff *skb)
>  	rcu_read_lock();
>  	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
>  	if (likely(ops && ops->xmit)) {
> +		/* Encap pushes outer headers over the metadata; drop it. */
> +		skb_metadata_clear(skb);

[Severity: High]
Could this similarly corrupt shared metadata if the buffer is cloned?

>  		dev_xmit_recursion_inc();
>  		ret = ops->xmit(skb);
>  		dev_xmit_recursion_dec();

[ ... ]

> @@ -455,6 +459,8 @@ int lwtunnel_input(struct sk_buff *skb)
>  	rcu_read_lock();
>  	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
>  	if (likely(ops && ops->input)) {
> +		/* Encap pushes outer headers over the metadata; drop it. */
> +		skb_metadata_clear(skb);

[Severity: High]
Could this also lead to a data race by modifying skb_shinfo on a potentially
shared buffer before handing it to ops->input()?

>  		dev_xmit_recursion_inc();
>  		ret = ops->input(skb);
>  		dev_xmit_recursion_dec();

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260619-bpf-lwt-drop-skb-metadata-v3-0-71d6a33ab76b@cloudflare.com?part=1

  reply	other threads:[~2026-06-20 17:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-19 17:09 [PATCH net v3 0/2] Drop skb metadata before LWT encapsulation Jakub Sitnicki
2026-06-19 17:09 ` [PATCH net v3 1/2] net: lwtunnel: " Jakub Sitnicki
2026-06-20 17:09   ` sashiko-bot [this message]
2026-06-19 17:09 ` [PATCH net v3 2/2] selftests/bpf: Add LWT encap tests for skb metadata Jakub Sitnicki
2026-06-20 17:09   ` sashiko-bot

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=20260620170951.580641F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jakub@cloudflare.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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