diff mbox series

[28/32] lnet: Adjust niov checks for large MD

Message ID 1659577097-19253-29-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: Update to OpenSFS as of Aug 3 2022 | expand

Commit Message

James Simmons Aug. 4, 2022, 1:38 a.m. UTC
From: Chris Horn <chris.horn@hpe.com>

An LNet user can allocate a large contiguous MD. That MD can have >
LNET_MAX_IOV pages which causes some LNDs to assert on either niov
argument passed to lnd_recv() or the value stored in
lnet_msg::msg_niov. This is true even in cases where the actual
transfer size is <= LNET_MTU and will not exceed limits in the LNDs.

Adjust ksocklnd_send()/ksocklnd_recv() to assert on the return value
of lnet_extract_kiov().

Remove the assert on msg_niov (payload_niov) from kiblnd_send().
kiblnd_setup_rd_kiov() will already fail if we exceed ko2iblnd's
available scatter gather entries.

HPE-bug-id: LUS-10878
Fixes: 05cd1717bb ("lnet: always put a page list into struct lnet_libmd")
WC-bug-id: https://jira.whamcloud.com/browse/LU-15851
Lustre-commit: 105193b4a147257a0 ("LU-15851 lnet: Adjust niov checks for large MD")
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Reviewed-on: https://review.whamcloud.com/47319
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 1 -
 net/lnet/klnds/socklnd/socklnd_cb.c | 5 +++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
index d4d8954..30e77c0 100644
--- a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1564,7 +1564,6 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	       payload_nob, payload_niov, libcfs_idstr(target));
 
 	LASSERT(!payload_nob || payload_niov > 0);
-	LASSERT(payload_niov <= LNET_MAX_IOV);
 
 	/* Thread context */
 	LASSERT(!in_interrupt());
diff --git a/net/lnet/klnds/socklnd/socklnd_cb.c b/net/lnet/klnds/socklnd/socklnd_cb.c
index 94600f3..308d8b0 100644
--- a/net/lnet/klnds/socklnd/socklnd_cb.c
+++ b/net/lnet/klnds/socklnd/socklnd_cb.c
@@ -936,7 +936,6 @@  struct ksock_conn_cb *
 	       payload_nob, payload_niov, libcfs_idstr(target));
 
 	LASSERT(!payload_nob || payload_niov > 0);
-	LASSERT(payload_niov <= LNET_MAX_IOV);
 	LASSERT(!in_interrupt());
 
 	desc_size = offsetof(struct ksock_tx,
@@ -962,6 +961,8 @@  struct ksock_conn_cb *
 					 payload_niov, payload_kiov,
 					 payload_offset, payload_nob);
 
+	LASSERT(tx->tx_nkiov <= LNET_MAX_IOV);
+
 	if (payload_nob >= *ksocknal_tunables.ksnd_zc_min_payload)
 		tx->tx_zc_capable = 1;
 
@@ -1278,13 +1279,13 @@  struct ksock_conn_cb *
 	struct ksock_sched *sched = conn->ksnc_scheduler;
 
 	LASSERT(iov_iter_count(to) <= rlen);
-	LASSERT(to->nr_segs <= LNET_MAX_IOV);
 
 	conn->ksnc_lnet_msg = msg;
 	conn->ksnc_rx_nob_left = rlen;
 
 	conn->ksnc_rx_to = *to;
 
+	LASSERT(conn->ksnc_rx_to.nr_segs <= LNET_MAX_IOV);
 	LASSERT(conn->ksnc_rx_scheduled);
 
 	spin_lock_bh(&sched->kss_lock);