Netdev List
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Julius Bairaktaris <julius@bairaktaris.de>,
	Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>
Cc: netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Willem de Bruijn" <willemb@google.com>,
	"Simon Horman" <horms@kernel.org>,
	"Alvin Šipraga" <alvin.sipraga@analog.com>
Subject: Re: [PATCH net] net: dsa: do not run queued FDB events after the port left the bridge
Date: Mon, 30 Nov 2026 13:05:39 +0100	[thread overview]
Message-ID: <dfe749f5-83de-4802-bcff-7517ea6b7283@redhat.com> (raw)
In-Reply-To: <20261121185821.1471559-1-julius@bairaktaris.de>

On 11/21/26 19:58, Julius Bairaktaris wrote:
> FDB events reach DSA from the atomic switchdev notifier and are handled
> from dsa_owq. The work builds the dsa_db from dp->bridge, which
> dsa_port_bridge_destroy() clears and frees when the port leaves the
> bridge or fails to join it.
> 
> When switchdev_bridge_port_offload() fails in the FDB replay of
> dsa_port_bridge_join(), because dsa_user_fdb_event() could not allocate
> its work item, the entries replayed before the failure are still
> queued. The rollback clears dp->bridge, and the queued work dereferences
> it:
> 
>    KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
>    Workqueue: dsa_ordered dsa_user_switchdev_event_work
>    RIP: 0010:dsa_port_bridge_host_fdb_add+0x141/0x5c0
> 
> A bridge leave has the same problem for an event that the notifier
> queues after dsa_port_pre_bridge_leave() flushed the workqueue: nothing
> orders the dp->bridge check in dsa_user_fdb_event() against the clear,
> and on a switch unbind the work can also run after dsa_user_destroy()
> freed the port's net_device. The notifier and the taggers read
> dp->bridge->dev and ->num without locks while the bridge is freed.
> 
> Clear dp->bridge, wait for those readers with synchronize_net(), flush
> the workqueue, and only then free the bridge. The work reads dp->bridge
> once and drops the event when the port has left; the FDB helpers take
> the bridge from it. The join rollback destroys the bridge before it
> tells the switches that the port left, as dsa_port_bridge_leave() does,
> so a dropped event programs nothing after that.
> dsa_port_bridge_dev_get() and dsa_port_bridge_num_get() read the pointer
> once, and dsa_port_bridge_create() publishes it with
> smp_store_release(), so a reader that sees it also sees its fields.

It's totally unclear to me in-flight notifications can't acquire a
reference to the bridge.

/P


      reply	other threads:[~2026-11-30 12:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 18:58 [PATCH net] net: dsa: do not run queued FDB events after the port left the bridge Julius Bairaktaris
2026-11-30 12:05 ` Paolo Abeni [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=dfe749f5-83de-4802-bcff-7517ea6b7283@redhat.com \
    --to=pabeni@redhat.com \
    --cc=alvin.sipraga@analog.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=julius@bairaktaris.de \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=willemb@google.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