Skip to content

Commit b4fb4cc

Browse files
paravmellanoxjgunthorpe
authored andcommitted
RDMA/cma: Fix unbalanced cm_id reference count during address resolve
Below commit missed the AF_IB and loopback code flow in rdma_resolve_addr(). This leads to an unbalanced cm_id refcount in cma_work_handler() which puts the refcount which was not incremented prior to queuing the work. A call trace is observed with such code flow: BUG: unable to handle kernel NULL pointer dereference at (null) [<ffffffff96b67e16>] __mutex_lock_slowpath+0x166/0x1d0 [<ffffffff96b6715f>] mutex_lock+0x1f/0x2f [<ffffffffc0beabb5>] cma_work_handler+0x25/0xa0 [<ffffffff964b9ebf>] process_one_work+0x17f/0x440 [<ffffffff964baf56>] worker_thread+0x126/0x3c0 Hence, hold the cm_id reference when scheduling the resolve work item. Fixes: 722c7b2 ("RDMA/{cma, core}: Avoid callback on rdma_addr_cancel()") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Parav Pandit <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 36798d5 commit b4fb4cc

File tree

1 file changed

+2
-0
lines changed
  • drivers/infiniband/core

1 file changed

+2
-0
lines changed

drivers/infiniband/core/cma.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,6 +3148,7 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv)
31483148
rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid);
31493149
rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid);
31503150

3151+
atomic_inc(&id_priv->refcount);
31513152
cma_init_resolve_addr_work(work, id_priv);
31523153
queue_work(cma_wq, &work->work);
31533154
return 0;
@@ -3174,6 +3175,7 @@ static int cma_resolve_ib_addr(struct rdma_id_private *id_priv)
31743175
rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, (union ib_gid *)
31753176
&(((struct sockaddr_ib *) &id_priv->id.route.addr.dst_addr)->sib_addr));
31763177

3178+
atomic_inc(&id_priv->refcount);
31773179
cma_init_resolve_addr_work(work, id_priv);
31783180
queue_work(cma_wq, &work->work);
31793181
return 0;

0 commit comments

Comments
 (0)