Validate input and fix return code
cover Validate input and fix return code
This series includes two patches. One to return the appropriate WC return codes and the other to validate the input during memory window bind.
Sindhu, Devale (2):
providers/irdma: Report correct WC errors providers/irdma: Validate input before memory window bind
providers/irdma/uverbs.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/2 providers/irdma: Report correct WC errors
From: "Sindhu, Devale" <[email protected]>
Return specific WC errors for certain type of error events as opposed to a generic IBV_WC_FATAL_ERR.
In particular,
Return IBV_WC_MW_BIND_ERR for memory window
related asynchronous events.
Return IBV_WC_REM_INV_REQ_ERR for errors which is detected when the remote side detects an operation outside of the established use for the transport.
Return IBV_WC_RETRY_EXC_ERR when transport retry
counter is exceeded.
--- providers/irdma/uverbs.c | 6 ++++++ 1 file changed, 6 insertions(+)
providers/irdma/uverbs.c +6 -0
@@ -556,6 +556,12 @@ static enum ibv_wc_status irdma_flush_err_to_ib_wc_status(enum irdma_flush_opcodreturn IBV_WC_LOC_LEN_ERR ;case FLUSH_GENERAL_ERR :return IBV_WC_WR_FLUSH_ERR ; +case FLUSH_MW_BIND_ERR : +return IBV_WC_MW_BIND_ERR ; +case FLUSH_REM_INV_REQ_ERR : +return IBV_WC_REM_INV_REQ_ERR ; +case FLUSH_RETRY_EXC_ERR : +return IBV_WC_RETRY_EXC_ERR ;case FLUSH_FATAL_ERR :default :return IBV_WC_FATAL_ERR ;
Signature · 1 line
2.32.0
PATCH 2/2 providers/irdma: Validate input before memory window bind
In reply to Sindhu DevaleFrom: "Sindhu, Devale" <[email protected]>
Check for a non null MR, address and length
before allowing bind operation.
Also, add check to make sure the MR and MW are in
same PD before posting a bind MW op.
--- providers/irdma/uverbs.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
providers/irdma/uverbs.c +17 -6
@@ -206,19 +206,30 @@ int irdma_ubind_mw(struct ibv_qp *qp, struct ibv_mw *mw, struct ibv_mw_bind *mw_bind) {struct ibv_mw_bind_info *bind_info = &mw_bind->bind_info; -struct verbs_mr *vmr =verbs_get_mr (bind_info->mr); - struct irdma_umr *umr = container_of(vmr, struct irdma_umr, vmr); +struct verbs_mr *vmr; +struct irdma_umr *umr;struct ibv_send_wr wr = {};struct ibv_send_wr *bad_wr;int err; -if (vmr->mr_type !=IBV_MR_TYPE_MR || mw->type !=IBV_MW_TYPE_1 ) -return ENOTSUP ; - -if (umr->acc_flags &IBV_ACCESS_ZERO_BASED ) +if (!bind_info->mr && (bind_info->addr || bind_info->length))return EINVAL ; +if (bind_info->mr) { + vmr =verbs_get_mr (bind_info->mr); + umr = container_of(vmr, struct irdma_umr, vmr); + +if (vmr->mr_type !=IBV_MR_TYPE_MR || mw->type !=IBV_MW_TYPE_1 ) +return ENOTSUP ; + +if (umr->acc_flags &IBV_ACCESS_ZERO_BASED ) +return EINVAL ; + +if (mw->pd != bind_info->mr->pd) +return EPERM ; + } + wr.opcode =IBV_WR_BIND_MW ; wr.bind_mw.bind_info = mw_bind->bind_info; wr.bind_mw.mw = mw;
Signature · 1 line
2.32.0
Quoted 6 lines · Sindhu Devale
This series includes two patches. One to return the appropriate WC return codes and the other to validate the input during memory window bind.
Sindhu, Devale (2):
providers/irdma: Report correct WC errors providers/irdma: Validate input before memory window bind
Can you please create pull request with the patches, please?
https://github.com/linux-rdma/rdma-core/pulls
Thanks
Quoted 7 lines
providers/irdma/uverbs.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)Signature · 1 line
2.32.0