Re: [PATCH] RDMA/cma: Fix listener leak in rdma_cma_listen_on_all() failure

From: Jason Gunthorpe
Date: Thu Sep 16 2021 - 09:57:23 EST


On Wed, Sep 15, 2021 at 02:17:56AM +0300, Leon Romanovsky wrote:

> > +static void cma_cancel_listens(struct rdma_id_private *id_priv)
> > +{
> > + /*
> > + * During _destroy_id() it is not possible for this value to transition
> > + * from empty to !empty, test it outside to lock to avoid taking a
> > + * global lock on every destroy. Only listen all cases will have
> > + * something to do
> > + */
> > + if (list_empty(&id_priv->list))
> > + return;
>
> IMHO, it is better do not do such check outside of the lock without real
> gain. It is too subtle to rely on _destroy_id() behaviour.

This arrangement would have solved the syzkaller bugs that are
triggering due to the other logic in _destroy_id() being too subtle
already :\

But it can't be done because priv->list is a total mess

Jason