Re: [PATCH rdma-rc 0/3] RDMA: Prevent RCU callbacks from outliving modules

From: Leon Romanovsky

Date: Thu Jul 09 2026 - 07:06:31 EST


On Thu, Jul 09, 2026 at 11:59:21AM +0200, Sebastian Andrzej Siewior wrote:
> On 2026-07-09 12:06:46 [+0300], Leon Romanovsky wrote:
> > ib_core, mlx5_ib, and ib_ipoib use call_rcu() with callbacks implemented by
> > their modules. Stopping callback producers does not drain callbacks already
> > queued. If module unload completes first, RCU can later invoke code that has
> > been unloaded. synchronize_rcu() and SRCU waits do not wait for queued
> > callbacks.
> >
> > IPoIB reclamation completions are signaled from inside the callbacks, so
> > they can wake teardown before a callback returns. Initialization unwind
> > also needs protection because registration can attach existing devices and
> > undo their setup on failure.
> >
> > Wait for queued callbacks after all producers have stopped.
> >
> > Reported-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> > Closes: https://lore.kernel.org/linux-rdma/20260708092316.Qb39F_B0@xxxxxxxxxxxxx/
> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
>
> Acked-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
>
> Thank you. This makes sense. drivers/infiniband/hw/hfi1 might need the
> same.

hfi1 has an rcu_barrier() call in hfi1_free_devdata():
https://elixir.bootlin.com/linux/v7.1.2/source/drivers/infiniband/hw/hfi1/init.c#L1176

Thanks