Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY
@ 2021-01-10 12:09 Israel Rukshin
  2021-01-12  8:27 ` Christoph Hellwig
  2021-01-13 23:22 ` Sagi Grimberg
  0 siblings, 2 replies; 3+ messages in thread
From: Israel Rukshin @ 2021-01-10 12:09 UTC (permalink / raw)
  To: Linux-nvme
  Cc: Max Gurtovoy, Israel Rukshin, Nitzan Carmi, Christoph Hellwig,
	Sagi Grimberg

When setting port traddr to INADDR_ANY, the listening cm_id->device
is NULL. The associate IB device is known only when a connect request
event arrives, so checking T10-PI device capability should be done
at this stage.

Fixes: b09160c3996c ("nvmet-rdma: add metadata/T10-PI support")
Signed-off-by: Israel Rukshin <israelr@nvidia.com>
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
 drivers/nvme/target/rdma.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index bdfc22eb2a10..06b6b742bb21 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -1220,6 +1220,14 @@ nvmet_rdma_find_get_device(struct rdma_cm_id *cm_id)
 	}
 	ndev->inline_data_size = nport->inline_data_size;
 	ndev->inline_page_count = inline_page_count;
+
+	if (nport->pi_enable && !(cm_id->device->attrs.device_cap_flags &
+				  IB_DEVICE_INTEGRITY_HANDOVER)) {
+		pr_warn("T10-PI is not supported by device %s. Disabling it\n",
+			cm_id->device->name);
+		nport->pi_enable = false;
+	}
+
 	ndev->device = cm_id->device;
 	kref_init(&ndev->ref);
 
@@ -1855,14 +1863,6 @@ static int nvmet_rdma_enable_port(struct nvmet_rdma_port *port)
 		goto out_destroy_id;
 	}
 
-	if (port->nport->pi_enable &&
-	    !(cm_id->device->attrs.device_cap_flags &
-	      IB_DEVICE_INTEGRITY_HANDOVER)) {
-		pr_err("T10-PI is not supported for %pISpcs\n", addr);
-		ret = -EINVAL;
-		goto out_destroy_id;
-	}
-
 	port->cm_id = cm_id;
 	return 0;
 
-- 
2.18.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* Re: [PATCH] nvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY
  2021-01-10 12:09 [PATCH] nvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY Israel Rukshin
@ 2021-01-12  8:27 ` Christoph Hellwig
  2021-01-13 23:22 ` Sagi Grimberg
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-01-12  8:27 UTC (permalink / raw)
  To: Israel Rukshin
  Cc: Max Gurtovoy, Nitzan Carmi, Christoph Hellwig, Linux-nvme,
	Sagi Grimberg

Thanks,

applied to nvme-5.11.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* Re: [PATCH] nvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY
  2021-01-10 12:09 [PATCH] nvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY Israel Rukshin
  2021-01-12  8:27 ` Christoph Hellwig
@ 2021-01-13 23:22 ` Sagi Grimberg
  1 sibling, 0 replies; 3+ messages in thread
From: Sagi Grimberg @ 2021-01-13 23:22 UTC (permalink / raw)
  To: Israel Rukshin, Linux-nvme; +Cc: Max Gurtovoy, Nitzan Carmi, Christoph Hellwig

FWIW,

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

end of thread, other threads:[~2021-01-13 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-10 12:09 [PATCH] nvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY Israel Rukshin
2021-01-12  8:27 ` Christoph Hellwig
2021-01-13 23:22 ` Sagi Grimberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox