]> git.baikalelectronics.ru Git - kernel.git/commit
RDMA/cma: Protect cma dev list with lock
authorParav Pandit <parav@mellanox.com>
Thu, 30 Aug 2018 05:35:19 +0000 (08:35 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 6 Sep 2018 19:01:59 +0000 (13:01 -0600)
commit6ee91824d6a2af53e433b95c5dcd8135f46ec310
treefe1fb0ea23827207ef93717c4f572a7386781cc5
parentf00c975276d81a02500be4122d664e7a48430c72
RDMA/cma: Protect cma dev list with lock

When AF_IB addresses are used during rdma_resolve_addr() a lock is not
held. A cma device can get removed while list traversal is in progress
which may lead to crash. ie

        CPU0                                     CPU1
        ====                                     ====
rdma_resolve_addr()
 cma_resolve_ib_dev()
  list_for_each()                         cma_remove_one()
    cur_dev->device                        mutex_lock(&lock)
                                            list_del();
                                           mutex_unlock(&lock);
                                           cma_process_remove();

Therefore, hold a lock while traversing the list which avoids such
situation.

Cc: <stable@vger.kernel.org> # 3.10
Fixes: 750bb5fed64c ("RDMA/cma: Add support for AF_IB to rdma_resolve_addr()")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/cma.c