kernel_optimize_test/include/rdma
Mike Marciniszyn 54a485e9ec IB/rdmavt: Fix RQ counting issues causing use of an invalid RWQE
The lookaside count is improperly initialized to the size of the
Receive Queue with the additional +1.  In the traces below, the
RQ size is 384, so the count was set to 385.

The lookaside count is then rarely refreshed.  Note the high and
incorrect count in the trace below:

rvt_get_rwqe: [hfi1_0] wqe ffffc900078e9008 wr_id 55c7206d75a0 qpn c
	qpt 2 pid 3018 num_sge 1 head 1 tail 0, count 385
rvt_get_rwqe: (hfi1_rc_rcv+0x4eb/0x1480 [hfi1] <- rvt_get_rwqe) ret=0x1

The head,tail indicate there is only one RWQE posted although the count
says 385 and we correctly return the element 0.

The next call to rvt_get_rwqe with the decremented count:

rvt_get_rwqe: [hfi1_0] wqe ffffc900078e9058 wr_id 0 qpn c
	qpt 2 pid 3018 num_sge 0 head 1 tail 1, count 384
rvt_get_rwqe: (hfi1_rc_rcv+0x4eb/0x1480 [hfi1] <- rvt_get_rwqe) ret=0x1

Note that the RQ is empty (head == tail) yet we return the RWQE at tail 1,
which is not valid because of the bogus high count.

Best case, the RWQE has never been posted and the rc logic sees an RWQE
that is too small (all zeros) and puts the QP into an error state.

In the worst case, a server slow at posting receive buffers might fool
rvt_get_rwqe() into fetching an old RWQE and corrupt memory.

Fix by deleting the faulty initialization code and creating an
inline to fetch the posted count and convert all callers to use
new inline.

Fixes: f592ae3c99 ("IB/rdmavt: Fracture single lock used for posting and processing RWQEs")
Link: https://lore.kernel.org/r/20200728183848.22226.29132.stgit@awfm-01.aw.intel.com
Reported-by: Zhaojuan Guo <zguo@redhat.com>
Cc: <stable@vger.kernel.org> # 5.4.x
Reviewed-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Tested-by: Honggang Li <honli@redhat.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
2020-07-29 15:54:36 -03:00
..
ib_addr.h
ib_cache.h RDMA/core: Add helper function to retrieve driver gid context from gid attr 2020-02-19 16:54:25 -04:00
ib_cm.h RDMA/cm: Send and receive ECE parameter over the wire 2020-05-27 16:05:05 -03:00
ib_hdrs.h
ib_mad.h RDMA/mad: Remove snoop interface 2020-05-06 11:50:22 -03:00
ib_marshall.h
ib_pack.h
ib_pma.h
ib_sa.h
ib_smi.h
ib_umem_odp.h IB: Allow calls to ib_umem_get from kernel ULPs 2020-01-16 16:14:28 +02:00
ib_umem.h IB: Allow calls to ib_umem_get from kernel ULPs 2020-01-16 16:14:28 +02:00
ib_verbs.h dynamic_debug: add an option to enable dynamic debug for modules only 2020-06-08 11:05:56 -07:00
ib.h RDMA: Make most headers compile stand alone 2019-07-25 13:58:47 -03:00
iba.h RDMA/cm: Add SET/GET implementations to hide IBA wire format 2020-01-25 15:05:59 -04:00
ibta_vol1_c12.h RDMA/cm: Add Enhanced Connection Establishment (ECE) bits 2020-05-27 16:05:05 -03:00
iw_cm.h
iw_portmap.h RDMA: Make most headers compile stand alone 2019-07-25 13:58:47 -03:00
lag.h RDMA/core: Add LAG functionality 2020-05-02 20:19:54 -03:00
mr_pool.h Linux 5.2-rc6 2019-06-28 21:18:23 -03:00
opa_addr.h
opa_port_info.h IB/ipoib: Increase ipoib Datagram mode MTU's upper limit 2020-05-21 11:23:55 -03:00
opa_smi.h
opa_vnic.h IB/{rdmavt, hfi1}: Implement creation of accelerated UD QPs 2020-05-21 11:23:54 -03:00
rdma_cm_ib.h
rdma_cm.h RDMA/cma: Provide ECE reject reason 2020-05-27 16:05:05 -03:00
rdma_counter.h RDMA/core: Make rdma_counter.h compile stand alone 2019-07-09 09:44:47 -03:00
rdma_netlink.h RDMA/core: Support netlink commands in non init_net net namespaces 2019-07-25 14:12:41 -03:00
rdma_vt.h IB/{rdmavt, hfi1, qib}: Add a counter for credit waits 2019-09-13 16:59:55 -03:00
rdmavt_cq.h RDMA: Make most headers compile stand alone 2019-07-25 13:58:47 -03:00
rdmavt_mr.h RDMA: Replace zero-length array with flexible-array member 2020-02-20 13:33:51 -04:00
rdmavt_qp.h IB/rdmavt: Fix RQ counting issues causing use of an invalid RWQE 2020-07-29 15:54:36 -03:00
restrack.h RDMA/nldev: Provide MR statistics 2019-10-22 15:33:31 -03:00
rw.h Linux 5.2-rc6 2019-06-28 21:18:23 -03:00
signature.h RDMA: Make most headers compile stand alone 2019-07-25 13:58:47 -03:00
tid_rdma_defs.h
uverbs_ioctl.h RDMA/core: Use offsetofend() instead of open coding 2020-05-29 15:27:04 -03:00
uverbs_named_ioctl.h RDMA/core: Make the entire API tree static 2020-01-30 16:28:52 -04:00
uverbs_std_types.h RDMA 5.8 merge window pull request 2020-06-05 14:05:57 -07:00
uverbs_types.h RDMA/core: Allow the ioctl layer to abort a fully created uobject 2020-05-21 20:10:46 -03:00