mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: netdev-bot+sashiko@kernel.org
Cc: fangxy@xiaopeng.com, pablo@netfilter.org, phil@nwl.cc,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	liuwb@xiaopeng.com, razor@blackwall.org
Subject: Re: [PATCH] netfilter: xt_policy: add NULL check for skb_dst() in output policy match
Date: Thu, 29 Oct 2026 23:20:08 +0100	[thread overview]
Message-ID: <auPGmOxutnhGGBdK@strlen.de> (raw)
In-Reply-To: <auOiJdDR7tkMzYAf@strlen.de>

Florian Westphal <fw@strlen.de> wrote:

[ CC Nik ]

> netdev-bot+sashiko@kernel.org <netdev-bot+sashiko@kernel.org> wrote:
> > Is this statement accurate? There seems to be a reachable path through
> > br_netfilter on a bridge port that has vlan_tunnel enabled.
> > 
> > net/bridge/br_vlan_tunnel.c:br_handle_egress_vlan_tunnel() {
> >     ...
> > 	tunnel_id = READ_ONCE(vlan->tinfo.tunnel_id);
> > 	if (!tunnel_id || unlikely(!skb_vlan_tag_present(skb)))
> > 		return 0;
> > 
> > 	skb_dst_drop(skb);
> >     ...
> > 	tunnel_dst = rcu_dereference(vlan->tinfo.tunnel_dst);
> > 	if (tunnel_dst && dst_hold_safe(&tunnel_dst->dst))
> > 		skb_dst_set(skb, &tunnel_dst->dst);
> > 
> > 	return 0;
> > }

Hmm, Nik can you please have a look?  Its strange that we don't return
an error. dst was dropped, tunnel dst disappeared, hwaccel tag was
cleared.

Should this return 0 only if skb_dst_set() was called?

Afaics then callers would toss the skb and we won't pass this
to inet netfilter hooks.

The original code had an unconditional skb_dst_set(),
assuming tunnel_dst is always there.

That changed with
cfc579f9d89a ("net: bridge: fix vlan tunnel dst refcnt when egressing")
fixup.

I'll quote more from report verbatim below for context.

> > So a forwarder can read the old non-zero tunnel_id and then find
> > tunnel_dst NULL, or holding a dst that dst_hold_safe() rejects. The skb
> > then goes on like this:
> > 
> > __br_forward()
> >   br_handle_vlan()
> >     br_handle_egress_vlan_tunnel()   <- dst dropped, none attached
> >   NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, ...)
> >     br_nf_forward()
> >       br_nf_forward_ip()
> >         NF_HOOK(pf, NF_INET_FORWARD, ...)
> >           ipt_do_table() / ip6t_do_table()
> >             policy_mt()
> >               match_policy_out()     <- dst == NULL
> > 
> > br_nf_post_routing() does the same for POSTROUTING, and
> > policy_mt_check_hooks() allows --dir out in both hooks.
> > 
> > The trigger needs a VLAN-filtering bridge with a vlan_tunnel port,
> > bridge-nf-call-iptables (or ip6tables) enabled, a "-m policy --dir out"
> > rule in FORWARD or POSTROUTING, and a tunnel mapping delete racing with
> > forwarded traffic. Given that, the pre-patch code would oops in softirq
> > context.
> > 
> > Could the commit message describe this path, so the change is not taken
> > as purely defensive?

      reply	other threads:[~2026-10-29 22:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 12:53 Fang Xieyan
2026-10-26 13:14 ` Florian Westphal
2026-10-26 15:34 ` Fang Xieyan
2026-10-29 18:55 ` netdev-bot+sashiko
2026-10-29 19:44   ` Florian Westphal
2026-10-29 22:20     ` Florian Westphal [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=auPGmOxutnhGGBdK@strlen.de \
    --to=fw@strlen.de \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fangxy@xiaopeng.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuwb@xiaopeng.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=razor@blackwall.org \
    /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®