RDMA/cma: Fix deadlock on &lock in rdma_cma_listen_on_all() error unwind
authorJason Gunthorpe <jgg@nvidia.com>
Wed, 18 Nov 2020 13:33:23 +0000 (09:33 -0400)
committerJason Gunthorpe <jgg@nvidia.com>
Wed, 25 Nov 2020 15:07:01 +0000 (11:07 -0400)
commitdd37d2f59eb839d51b988f6668ce5f0d533b23fd
treee304d513f07dd8061673ba680ebaa89865b995c6
parent6f6e2dcbb82b9b2ea304fe32635789fedd4e9868
RDMA/cma: Fix deadlock on &lock in rdma_cma_listen_on_all() error unwind

rdma_detroy_id() cannot be called under &lock - we must instead keep the
error'd ID around until &lock can be released, then destroy it.

This is complicated by the usual way listen IDs are destroyed through
cma_process_remove() which can run at any time and will asynchronously
destroy the same ID.

Remove the ID from visiblity of cma_process_remove() before going down the
destroy path outside the locking.

Fixes: c80a0c52d85c ("RDMA/cma: Add missing error handling of listen_id")
Link: https://lore.kernel.org/r/20201118133756.GK244516@ziepe.ca
Reported-by: syzbot+1bc48bf7f78253f664a9@syzkaller.appspotmail.com
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/cma.c