linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rdma-core 0/2] Validate input and fix return code
@ 2021-11-29 22:54 Sindhu Devale
  2021-11-29 22:54 ` [PATCH rdma-core 1/2] providers/irdma: Report correct WC errors Sindhu Devale
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sindhu Devale @ 2021-11-29 22:54 UTC (permalink / raw)
  To: jgg, leon, tatyana.e.nikolova
  Cc: linux-rdma, shiraz.saleem, mustafa.ismail, 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

 providers/irdma/uverbs.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH rdma-core 1/2] providers/irdma: Report correct WC errors
  2021-11-29 22:54 [PATCH rdma-core 0/2] Validate input and fix return code Sindhu Devale
@ 2021-11-29 22:54 ` Sindhu Devale
  2021-11-29 22:54 ` [PATCH rdma-core 2/2] providers/irdma: Validate input before memory window bind Sindhu Devale
  2021-11-30 12:21 ` [PATCH rdma-core 0/2] Validate input and fix return code Leon Romanovsky
  2 siblings, 0 replies; 4+ messages in thread
From: Sindhu Devale @ 2021-11-29 22:54 UTC (permalink / raw)
  To: jgg, leon, tatyana.e.nikolova
  Cc: linux-rdma, shiraz.saleem, mustafa.ismail, Sindhu, Devale

From: "Sindhu, Devale" <sindhu.devale@intel.com>

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.

Fixes: 14a0fc824f16 ("rdma-core/irdma: Implement device supported verb APIs")
Signed-off-by: Sindhu, Devale <sindhu.devale@intel.com>
---
 providers/irdma/uverbs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/providers/irdma/uverbs.c b/providers/irdma/uverbs.c
index edd8821f..c8222d14 100644
--- a/providers/irdma/uverbs.c
+++ b/providers/irdma/uverbs.c
@@ -556,6 +556,12 @@ static enum ibv_wc_status irdma_flush_err_to_ib_wc_status(enum irdma_flush_opcod
 		return 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;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH rdma-core 2/2] providers/irdma: Validate input before memory window bind
  2021-11-29 22:54 [PATCH rdma-core 0/2] Validate input and fix return code Sindhu Devale
  2021-11-29 22:54 ` [PATCH rdma-core 1/2] providers/irdma: Report correct WC errors Sindhu Devale
@ 2021-11-29 22:54 ` Sindhu Devale
  2021-11-30 12:21 ` [PATCH rdma-core 0/2] Validate input and fix return code Leon Romanovsky
  2 siblings, 0 replies; 4+ messages in thread
From: Sindhu Devale @ 2021-11-29 22:54 UTC (permalink / raw)
  To: jgg, leon, tatyana.e.nikolova
  Cc: linux-rdma, shiraz.saleem, mustafa.ismail, Sindhu, Devale

From: "Sindhu, Devale" <sindhu.devale@intel.com>

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.

Fixes: 14a0fc824f16 ("rdma-core/irdma: Implement device supported verb APIs")
Signed-off-by: Sindhu, Devale <sindhu.devale@intel.com>
---
 providers/irdma/uverbs.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/providers/irdma/uverbs.c b/providers/irdma/uverbs.c
index c8222d14..dc7cf41a 100644
--- a/providers/irdma/uverbs.c
+++ b/providers/irdma/uverbs.c
@@ -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;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH rdma-core 0/2] Validate input and fix return code
  2021-11-29 22:54 [PATCH rdma-core 0/2] Validate input and fix return code Sindhu Devale
  2021-11-29 22:54 ` [PATCH rdma-core 1/2] providers/irdma: Report correct WC errors Sindhu Devale
  2021-11-29 22:54 ` [PATCH rdma-core 2/2] providers/irdma: Validate input before memory window bind Sindhu Devale
@ 2021-11-30 12:21 ` Leon Romanovsky
  2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2021-11-30 12:21 UTC (permalink / raw)
  To: Sindhu Devale
  Cc: jgg, tatyana.e.nikolova, linux-rdma, shiraz.saleem,
	mustafa.ismail

On Mon, Nov 29, 2021 at 04:54:44PM -0600, Sindhu Devale wrote:
> 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

> 
>  providers/irdma/uverbs.c | 29 +++++++++++++++++++++++------
>  1 file changed, 23 insertions(+), 6 deletions(-)
> 
> -- 
> 2.32.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-30 12:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-29 22:54 [PATCH rdma-core 0/2] Validate input and fix return code Sindhu Devale
2021-11-29 22:54 ` [PATCH rdma-core 1/2] providers/irdma: Report correct WC errors Sindhu Devale
2021-11-29 22:54 ` [PATCH rdma-core 2/2] providers/irdma: Validate input before memory window bind Sindhu Devale
2021-11-30 12:21 ` [PATCH rdma-core 0/2] Validate input and fix return code Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).