Netdev List
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Yuan Tan <yuantan098@gmail.com>
Cc: Nikolay Aleksandrov <razor@blackwall.org>,
	Ren Wei <n05ec@lzu.edu.cn>,
	bridge@lists.linux.dev, netdev@vger.kernel.org,
	idosch@nvidia.com, davem@davemloft.net, yifanwucs@gmail.com,
	tomapufckgml@gmail.com, bird@lzu.edu.cn, tonanli66@gmail.com
Subject: Re: [PATCH net 1/1] net: bridge: guard local finish against missing port
Date: Tue, 12 May 2026 11:45:30 +0200	[thread overview]
Message-ID: <agL2up-rblE9Y6yP@strlen.de> (raw)
In-Reply-To: <CAPuPA7+jMHLjpY-RWK6-EQqs-NjrGUmanuPVVTDZJv1yeRk1oA@mail.gmail.com>

Yuan Tan <yuantan098@gmail.com> wrote:
> > >>> The bridge local receive path may be deferred by netfilter and resumed
> > >>> later. By the time br_handle_local_finish() runs, skb->dev may still be
> > >>> valid while its bridge port association has already been removed.
> > >>>
> > >>> br_handle_local_finish() unconditionally looks up the bridge port from
> > >>> skb->dev and dereferences it for source learning. If the port is no
> > >>> longer attached to the bridge, the lookup returns NULL and the deferred
> > >>> local receive path can no longer rely on the port state being present.
> > You should update the Fixes: tag but also wait 24h before re-posting another
> > patch version.
> 
> Ok we will send the v2 with fix tag f350a0a87374 after 24h

Would you mind exploring an alternative fix for this?

As nfnetlink_queue'd skbs leave rcu read locked section, great
care has to be taken on reinject.

Either bridge could call nf_queue_nf_hook_drop() on bridge
port removal, or nfqnl_reinject() could revalidate that skb->dev
is part of a bridge and munge verdict to NF_DROP in case
the assocication was removed while packet was out.

static bool nfqnl_bridge_port_removed(const struct nf_queue_entry *e)
{
	return e->state.pf == NFPROTO_BRIDGE &&
		!br_port_get_rcu(e->skb->dev) == NULL;
}

static void nfqnl_reinject(struct nf_queue_entry *entry, unsigned int verdict)
{
        const struct nf_ct_hook *ct_hook;

        if (verdict == NF_ACCEPT ||
            verdict == NF_REPEAT ||
            verdict == NF_STOP) {
                unsigned int ct_verdict = verdict;

		....

		if (nfqnl_bridge_port_removed(entry))
			verdict = NF_DROP;

Its more work, but it places the extra checks to where
they are really needed.

Also see related bug fix:  At this time, entire bridge device can go
away while packet is out.

https://patchwork.ozlabs.org/project/netfilter-devel/patch/ca7ee343bbcb44905e1f5b853df2f3a5b7d40548.1778493188.git.royenheart@gmail.com/

      reply	other threads:[~2026-05-12  9:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1778504155.git.tonanli66@gmail.com>
2026-05-12  4:31 ` [PATCH net 1/1] net: bridge: guard local finish against missing port Ren Wei
2026-05-12  8:29   ` Nikolay Aleksandrov
2026-05-12  8:57     ` Yuan Tan
2026-05-12  9:03       ` Nikolay Aleksandrov
2026-05-12  9:24         ` Yuan Tan
2026-05-12  9:45           ` 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=agL2up-rblE9Y6yP@strlen.de \
    --to=fw@strlen.de \
    --cc=bird@lzu.edu.cn \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=idosch@nvidia.com \
    --cc=n05ec@lzu.edu.cn \
    --cc=netdev@vger.kernel.org \
    --cc=razor@blackwall.org \
    --cc=tomapufckgml@gmail.com \
    --cc=tonanli66@gmail.com \
    --cc=yifanwucs@gmail.com \
    --cc=yuantan098@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