public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Jiri Pirko <jiri@resnulli.us>,
	linux-rdma@vger.kernel.org, leon@kernel.org, msanalla@nvidia.com,
	maorg@nvidia.com, parav@nvidia.com, mbloch@nvidia.com,
	markzhang@nvidia.com, marco.crivellari@suse.com,
	roman.gushchin@linux.dev, wangliang74@huawei.com,
	yanjun.zhu@linux.dev
Subject: Re: [PATCH] RDMA/core: Fix stale RoCE GIDs during netdev events at registration
Date: Tue, 27 Jan 2026 12:00:00 -0400	[thread overview]
Message-ID: <20260127160000.GG1641016@ziepe.ca> (raw)
In-Reply-To: <21d63279-79a2-47aa-b305-30a55b8f40f4@I-love.SAKURA.ne.jp>

On Tue, Jan 27, 2026 at 08:14:58PM +0900, Tetsuo Handa wrote:
> On 2026/01/27 18:38, Jiri Pirko wrote:
> > From: Jiri Pirko <jiri@nvidia.com>
> > 
> > RoCE GID entries become stale when netdev properties change during the
> > IB device registration window. This is reproducible with a udev rule
> > that sets a MAC address when a VF netdev appears:
> > 
> >   ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth4", \
> >     RUN+="/sbin/ip link set eth4 address 88:22:33:44:55:66"
> > 
> > After VF creation, show_gids displays GIDs derived from the original
> > random MAC rather than the configured one.
> > 
> > The root cause is a race between netdev event processing and device
> > registration:
> > 
> >   CPU 0 (driver)                    CPU 1 (udev/workqueue)
> >   ──────────────                    ──────────────────────
> >   ib_register_device()
> >     ib_cache_setup_one()
> >       gid_table_setup_one()
> >         _gid_table_setup_one()
> >           ← GID table allocated
> >         rdma_roce_rescan_device()
> >           ← GIDs populated with
> >             OLD MAC
> >                                     ip link set eth4 addr NEW_MAC
> >                                     NETDEV_CHANGEADDR queued
> >                                     netdevice_event_work_handler()
> >                                       ib_enum_all_roce_netdevs()
> >                                         ← Iterates DEVICE_REGISTERED
> >                                         ← Device NOT marked yet, SKIP!
> >     enable_device_and_get()
> >       xa_set_mark(DEVICE_REGISTERED)
> >           ← Too late, event was lost
> > 
> > The netdev event handler uses ib_enum_all_roce_netdevs() which only
> > iterates devices marked DEVICE_REGISTERED. However, this mark is set
> > late in the registration process, after the GID cache is already
> > populated. Events arriving in this window are silently dropped.
> > 
> > Fix this by introducing a new xarray mark DEVICE_GID_UPDATES that is
> > set immediately after the GID table is allocated and initialized. Use
> > the new mark in ib_enum_all_roce_netdevs() function to iterate devices
> > instead of DEVICE_REGISTERED.
> > 
> > This is safe because:
> > - After _gid_table_setup_one(), all required structures exist (port_data,
> >   immutable, cache.gid)
> > - The GID table mutex serializes concurrent access between the initial
> >   rescan and event handlers
> > - Event handlers correctly update stale GIDs even when racing with rescan
> > - The mark is cleared in ib_cache_cleanup_one() before teardown
> > 
> > This also fixes similar races for IP address events (inetaddr_event,
> > inet6addr_event) which use the same enumeration path.
> > 
> > Fixes: 0df91bb67334 ("RDMA/devices: Use xarray to store the client_data")
> > Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> 
> I was thinking making the NETDEV_UNREGISTER event handler valid until
> wait_for_completion(&device->unreg_completion) in disable_device() returns
> ( https://lkml.kernel.org/r/b4a09ad8-97cc-4fe1-b02a-6192248694a8@I-love.SAKURA.ne.jp ).
> 
> Since your patch includes what I was trying to address, you can add
> 
> Reported-by: syzbot+881d65229ca4f9ae8c84@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=881d65229ca4f9ae8c84
> 
> lines.

Can we feed it to syzkaller please and see if it does actually clear
it's repo? That particular bug already has 5 patches claiming to fix
it.

It has become some kind of catch all of all kinds of refcounting errors

[  247.188486][ T6052] unregister_netdevice: waiting for vcan0 to become free. Usage count = 2

Does this actually change the refcounting around that could fix that?
Looked like no?

Jason

  parent reply	other threads:[~2026-01-27 16:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27  9:38 [PATCH] RDMA/core: Fix stale RoCE GIDs during netdev events at registration Jiri Pirko
2026-01-27 11:14 ` Tetsuo Handa
2026-01-27 11:58   ` Jiri Pirko
2026-01-27 16:00   ` Jason Gunthorpe [this message]
2026-01-27 21:17     ` Yanjun.Zhu
2026-01-27 22:16       ` Tetsuo Handa
2026-01-27 22:54         ` Yanjun.Zhu
2026-01-28  4:52           ` Tetsuo Handa
2026-01-28  8:26             ` Tetsuo Handa
2026-01-28 13:40               ` Jiri Pirko
2026-01-29  6:06                 ` Tetsuo Handa
2026-01-29 12:38                   ` Jiri Pirko
2026-01-29 13:48                     ` Tetsuo Handa
2026-01-29 14:58                       ` Jiri Pirko
2026-02-02 14:20                         ` Tetsuo Handa
2026-02-02 23:51                           ` Jason Gunthorpe
2026-02-03  3:52                             ` Tetsuo Handa
2026-02-10  8:58                               ` Jiri Pirko
2026-02-10 10:22                                 ` Tetsuo Handa
2026-02-10 15:42                                   ` Jason Gunthorpe
2026-02-11  1:30                                     ` Tetsuo Handa
2026-02-03  9:07                             ` Jiri Pirko
2026-01-28 13:43             ` Jiri Pirko
2026-02-24  8:59 ` Leon Romanovsky

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=20260127160000.GG1641016@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=jiri@resnulli.us \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maorg@nvidia.com \
    --cc=marco.crivellari@suse.com \
    --cc=markzhang@nvidia.com \
    --cc=mbloch@nvidia.com \
    --cc=msanalla@nvidia.com \
    --cc=parav@nvidia.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=roman.gushchin@linux.dev \
    --cc=wangliang74@huawei.com \
    --cc=yanjun.zhu@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