Commit 337c42b1 authored by Junxian Huang's avatar Junxian Huang
Browse files

RDMA/hns: Check atomic wr length

mainline inclusion
from mainline-v6.10-rc7
commit 6afa2c0bfb8ef69f65715ae059e5bd5f9bbaf03b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBJ9LU
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git/commit/?id=6afa2c0bfb8ef69f65715ae059e5bd5f9bbaf03b



---------------------------------------------------------------------

8 bytes is the only supported length of atomic. Add this check in
set_rc_wqe(). Besides, stop processing WQEs and return from
set_rc_wqe() if there is any error.

Fixes: 384f8818 ("RDMA/hns: Add atomic support")
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
Link: https://lore.kernel.org/r/20240710133705.896445-2-huangjunxian6@hisilicon.com


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarXinghai Cen <cenxinghai@h-partners.com>
parent 961f76b2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@
/* Configure to HW for PAGE_SIZE larger than 4KB */
#define PG_SHIFT_OFFSET				(PAGE_SHIFT - 12)

#define ATOMIC_WR_LEN				8

#define HNS_ROCE_IDX_QUE_ENTRY_SZ		4
#define SRQ_DB_REG				0x230

+7 −2
Original line number Diff line number Diff line
@@ -674,11 +674,16 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp,
		     (wr->send_flags & IB_SEND_SIGNALED) ? 1 : 0);

	if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP ||
	    wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD)
	    wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD) {
		if (msg_len != ATOMIC_WR_LEN)
			return -EINVAL;
		set_atomic_seg(wr, rc_sq_wqe, valid_num_sge);
	else if (wr->opcode != IB_WR_REG_MR)
	} else if (wr->opcode != IB_WR_REG_MR) {
		ret = set_rwqe_data_seg(&qp->ibqp, wr, rc_sq_wqe,
					&curr_idx, valid_num_sge);
		if (ret)
			return ret;
	}

	if (qp->en_flags & HNS_ROCE_QP_CAP_DYNAMIC_CTX_ATTACH)
		fill_dca_fields(qp, rc_sq_wqe);