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 3/4] netfilter: nft_fwd_netdev: drop the stale dst when steering to a device
Date: Thu, 19 Nov 2026 20:02:44 +0000 [thread overview]
Message-ID: <179511856420.3136.2766397873785932023@kernel.org> (raw)
In-Reply-To: <CORE-9NOG.v4.r0.20261116135311-3@mojatatu.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] nft_fwd_neigh_eval() (net/netfilter/nft_fwd_netdev.c:164-167)
now calls skb_dst_drop_keep_metadata() before the packet is sent to…
- [Low] This patch fixes a user-visible bug: a frame parked on the
configured device's incomplete neighbour is later sent on that device…
--
netfilter: nft_fwd_netdev: drop the stale dst when steering to a device
This patch releases the skb dst in nft_fwd_neigh_eval() before switching
skb->dev and calling neigh_xmit(). Without it, a packet parked on an
incomplete neighbour is later rebuilt from the routed device's neighbour.
The release uses skb_dst_drop_keep_metadata(), so LWT encap parameters
move onto a metadata dst. If that allocation fails, the packet is dropped.
Link: https://lore.kernel.org/netdev/QDISC-6HS9.v3.r0.20261103062649-2@mojatatu.com/
Link: https://lore.kernel.org/netdev/avTfQjFQYR2NNdRg@chamomile/
> Reported-by: Sashiko (nipa) <sashiko-bot@kernel.org>
> Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-6HS9.v3.r0.20261103062649-2@mojatatu.com
> Link: https://lore.kernel.org/netdev/QDISC-6HS9.v3.r0.20261103062649-2@mojatatu.com/
> Link: https://lore.kernel.org/netdev/avTfQjFQYR2NNdRg@chamomile/
> Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
> Reviewed-by: Victor Nogueira <victor@mojatatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
[Severity: Low]
Should this have a Fixes: tag? The skb->dev switch and the neigh_xmit()
call in nft_fwd_neigh_eval(), which run with the stale dst still attached,
come from:
Fixes: d32de98ea70f ("netfilter: nft_fwd_netdev: allow to forward packets via neighbour layer")
The bug can be seen in neigh_update_process_arp_queue(). It looks the
neighbour up again from skb_dst(skb) using dst_neigh_lookup_skb(), while
skb->dev is already the configured device.
The commit message also doesn't list the in-series prerequisites:
- It won't build without "net: dst: keep the LWT metadata of a dropped
route", which adds skb_dst_drop_keep_metadata().
- According to "net: xfrm: interface: restore dst_orig on every xfrm
interface", the netdev egress fwd to an xfrm interface path hits a
skb_dst_set() WARN in xfrmi_xmit2() unless that commit is also present.
With CONFIG_DEBUG_NET=y and panic_on_warn, that WARN becomes a panic.
Could these dependencies be noted, so a stable backport doesn't take this
patch without them?
> diff --git a/net/netfilter/nft_fwd_netdev.c b/net/netfilter/nft_fwd_netdev.c
> index 7447da931a957..f486c7be385cf 100644
> --- a/net/netfilter/nft_fwd_netdev.c
> +++ b/net/netfilter/nft_fwd_netdev.c
[ ... ]
> @@ -160,6 +161,11 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,
> goto out;
> }
>
> + if (!skb_dst_drop_keep_metadata(skb)) {
^^^^
[Severity: Medium]
Can this give an NBMA tunnel a metadata_dst that it then reads as a
struct rtable?
When the route carries an LWT encap (LWTUNNEL_ENCAP_IP, LWTUNNEL_ENCAP_IP6
or LWTUNNEL_ENCAP_XFRM), skb_dst_drop_keep_metadata() replaces the rtable
with a metadata_dst built on dst_blackhole_ops.
The configured device can be an NBMA tunnel: ipip or gre with no remote,
or ip6tnl with raddr :: and no collect_md. In that case the packet reaches
the tunnel like this:
nft_fwd_neigh_eval()
neigh_xmit()
neigh_direct_output()
dev_queue_xmit()
ip_tunnel_xmit() / ip6_tnl_xmit()
ip_tunnel_xmit() takes the md branch only when tun_info is AF_INET with a
nonzero key.u.ipv4.dst. For any other IPv4 payload it falls back to this:
net/ipv4/ip_tunnel.c:ip_tunnel_xmit() {
...
} else if (payload_protocol == htons(ETH_P_IP)) {
rt = skb_rtable(skb);
dst = rt_nexthop(rt, inner_iph->daddr);
...
}
Two configurations reach that fallback. One is encap ip6 on an IPv4
route. The other is encap ip with no dst, which ip_tun_build_state()
accepts because LWTUNNEL_IP_DST is optional.
In its NBMA IPv4-payload branch, ip6_tnl_xmit() never checks tun_info:
net/ipv6/ip6_tunnel.c:ip6_tnl_xmit() {
...
const struct rtable *rt = skb_rtable(skb);
if (!rt)
goto tx_err_link_failure;
if (rt->rt_gw_family == AF_INET6)
memcpy(&fl6->daddr, &rt->rt_gw6, sizeof(fl6->daddr));
...
}
On 64-bit, rt_gw_family overlays the first octet of the tunnel key's IPv4
source address, and rt_gw6 starts at key.u.ipv4.dst.
Take "encap ip id 42 src 10.20.0.2 dst 192.0.2.9" on the routed device and
a fwd rule to an NBMA ip6tnl. The leading 10 equals AF_INET6, so the
payload would be encapsulated towards c000:209::, an address built from
the key bytes.
For METADATA_XFRM, rt_gw_family overlays the low byte of the dst_orig
pointer, so the result depends on allocation alignment, not on a check.
All reads stay inside the metadata_dst allocation. The result is a wrong
outer destination, not an out-of-bounds access. Before this patch, the
same configuration gave the tunnel a real rtable.
The commit message mentions this case:
The release here can leave one behind as well, when the parameters a
route carries are not usable for the payload. The cast is repaired
separately.
However, no patch in this series seems to touch net/ipv4/ or net/ipv6/.
Should the skb_rtable() fix go in before this patch, or with it, so the
fwd path doesn't add a new way to reach the cast?
> + verdict = NF_DROP;
> + goto out;
> + }
> +
> local_bh_disable();
> if (nf_dev_xmit_recursion()) {
> local_bh_enable();
--
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
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 [this message]
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=179511856420.3136.2766397873785932023@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