From: netdev-bot+sashiko@kernel.org
To: jhs@mojatatu.com
Cc: netdev@vger.kernel.org, daniel@iogearbox.net,
john.fastabend@gmail.com, sdf@fomichev.me, martin.lau@linux.dev,
ast@kernel.org, andrii@kernel.org, eddyz87@gmail.com,
memxor@gmail.com, song@kernel.org, yonghong.song@linux.dev,
jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, bpf@vger.kernel.org,
jiri@resnulli.us, victor@mojatatu.com, sashiko-bot@kernel.org
Subject: Re: [PATCH net-next v4 1/4] net: xfrm: interface: restore dst_orig on every xfrm interface
Date: Thu, 19 Nov 2026 20:02:40 +0000 [thread overview]
Message-ID: <179511856062.3136.18243971639206515341@kernel.org> (raw)
In-Reply-To: <CORE-9NOG.v4.r0.20261116135311-1@mojatatu.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This commit fixes real, user-visible bugs but carries no Fixes:
tag.
- [Low] The commit message does not mention that the old per-cpu design
leaked a route reference, and that this patch fixes the leak.
--
net: xfrm: interface: restore dst_orig on every xfrm interface
This commit makes xfrmi_xmit2() restore dst_orig from the xfrm metadata
in both the collect_md arm and the configured if_id arm. It takes its own
reference with dst_clone() and drops the metadata dst from the slot
first. It also switches bpf_skb_set_xfrm_info() from a shared per-cpu
metadata dst to a per-skb one and removes xfrm_bpf_md_dst.
> net: xfrm: interface: restore dst_orig on every xfrm interface
[ ... ]
> The same slot overwrite is in the unstable helper a tc-bpf program uses to
> attach that metadata: bpf_skb_set_xfrm_info() records the route as dst_orig
> and installs a per-cpu metadata dst over it. The per-cpu dst is shared by
> every invocation of the program, so the restore cannot keep anything in it.
>
> The Fix:
> Restore dst_orig in both arms of xfrmi_xmit2(), taking a reference with
> dst_clone() so the metadata dst keeps its own, and empty the counted slot
> with skb_dst_drop() before the route is installed. The helper allocates a
> metadata dst per skb instead of a per-cpu one, so the route it records
> belongs to that skb and is released with it; the per-cpu allocation is no
> longer used and goes away.
[Severity: Low]
Should the commit message also say that the per-cpu design leaked the
route reference, and that this change fixes the leak?
Before this patch, bpf_skb_set_xfrm_info() moved the skb's reference on
the route into the shared per-cpu xfrm_md_info:
skb_dst_force(skb);
info->dst_orig = skb_dst(skb);
dst_hold((struct dst_entry *)md_dst);
skb_dst_set(skb, (struct dst_entry *)md_dst);
Only the collect_md arm of xfrmi_xmit2() returned that reference, by
clearing md_info->dst_orig. Some packets never reach that arm:
TC_ACT_SHOT, a redirect to a non-xfrm device, an xfrm interface with a
configured if_id, or any drop before xmit. For those packets, the next
helper call on the same CPU overwrote info->dst_orig without calling
dst_release().
xfrm_bpf_md_dst is never freed, so metadata_dst_free_percpu() never runs
for it. The route therefore leaks, along with the net_device reference it
holds. That can leave the device stuck in "unregister_netdevice: waiting
for <dev> to become free".
With the per-skb metadata dst, the route is released when the metadata
dst is destroyed:
dst_destroy()
metadata_dst_free()
dst_release(md_dst->u.xfrm_info.dst_orig);
At the moment the message only says the per-cpu allocation goes away.
Could it mention the leak as well?
[ ... ]
> Reviewed-by: Victor Nogueira <victor@mojatatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
[Severity: Low]
Should this patch have a Fixes: tag?
These three pieces all appear to come from the same commit:
- the per-cpu metadata dst in bpf_skb_set_xfrm_info()
- the xfrm_bpf_md_dst pointer in net/core/filter.c
- the collect_md-only dst_orig restore in xfrmi_xmit2()
That commit is:
Fixes: 94151f5aa966 ("xfrm: interface: Add unstable helpers for setting/getting XFRM metadata from TC-BPF")
The configured if_id drop and the clone sharing problem date back to
that commit as well. The slot overwrite started to warn, or panic with
panic_on_warn, only after a890348adcc9 ("net: Add skb_dst_check_unset")
added this check:
DEBUG_NET_WARN_ON_ONCE((skb->_skb_refdst & SKB_DST_PTRMASK) &&
!(skb->_skb_refdst & SKB_DST_NOREF));
The message says the tc-bpf case needs no other patch from the series.
Without the tag, stable tooling can't tell how far back the fix applies.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/CORE-9NOG.v4.r0.20261116135311%40mojatatu.com
next prev parent reply other threads:[~2026-11-19 20:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 19:01 [PATCH net-next v4 0/4] net: drop the stale dst when steering to another device Jamal Hadi Salim
2026-11-16 19:01 ` [PATCH net-next v4 1/4] net: xfrm: interface: restore dst_orig on every xfrm interface Jamal Hadi Salim
2026-11-17 19:02 ` sashiko-bot
2026-11-19 20:02 ` netdev-bot+sashiko [this message]
2026-11-16 19:01 ` [PATCH net-next v4 2/4] net: dst: keep the LWT metadata of a dropped route Jamal Hadi Salim
2026-11-19 20:02 ` netdev-bot+sashiko
2026-11-16 19:01 ` [PATCH net-next v4 3/4] netfilter: nft_fwd_netdev: drop the stale dst when steering to a device Jamal Hadi Salim
2026-11-17 19:02 ` sashiko-bot
2026-11-19 20:02 ` netdev-bot+sashiko
2026-11-16 19:01 ` [PATCH net-next v4 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop Jamal Hadi Salim
2026-11-16 20:46 ` Alexei Starovoitov
2026-11-16 22:06 ` Jamal Hadi Salim
2026-11-17 4:50 ` Alexei Starovoitov
2026-11-17 13:15 ` Jamal Hadi Salim
2026-11-17 14:00 ` Jamal Hadi Salim
2026-11-17 19:02 ` sashiko-bot
2026-11-19 20:02 ` netdev-bot+sashiko
2026-11-19 20:29 ` Jamal Hadi Salim
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=179511856062.3136.18243971639206515341@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sashiko-bot@kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=victor@mojatatu.com \
--cc=yonghong.song@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