]> www.infradead.org Git - users/jedix/linux-maple.git/commit
RDMA/cma: Protect RMW with qp_mutex
authorHåkon Bugge <haakon.bugge@oracle.com>
Tue, 22 Jun 2021 13:39:57 +0000 (15:39 +0200)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 24 Jun 2021 18:29:53 +0000 (15:29 -0300)
commitca0c448d2b9f43e3175835d536853854ef544e22
treebb0ae9c2a205174f29c7d968e1cfe32aca84b924
parentdc70f7c3ed34b081c02a611591c5079c53b771b8
RDMA/cma: Protect RMW with qp_mutex

The struct rdma_id_private contains three bit-fields, tos_set,
timeout_set, and min_rnr_timer_set. These are set by accessor functions
without any synchronization. If two or all accessor functions are invoked
in close proximity in time, there will be Read-Modify-Write from several
contexts to the same variable, and the result will be intermittent.

Fixed by protecting the bit-fields by the qp_mutex in the accessor
functions.

The consumer of timeout_set and min_rnr_timer_set is in
rdma_init_qp_attr(), which is called with qp_mutex held for connected
QPs. Explicit locking is added for the consumers of tos and tos_set.

This commit depends on ("RDMA/cma: Remove unnecessary INIT->INIT
transition"), since the call to rdma_init_qp_attr() from
cma_init_conn_qp() does not hold the qp_mutex.

Fixes: 2c1619edef61 ("IB/cma: Define option to set ack timeout and pack tos_set")
Fixes: 3aeffc46afde ("IB/cma: Introduce rdma_set_min_rnr_timer()")
Link: https://lore.kernel.org/r/1624369197-24578-3-git-send-email-haakon.bugge@oracle.com
Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/cma.c