From 3f80976445f7e9662b81d11db6136efe5d501bb4 Mon Sep 17 00:00:00 2001 From: Alexey Lyashkov Date: Tue, 19 Nov 2019 17:00:42 +0300 Subject: [PATCH] LU-12981 lnet: Check MTU accurately The existing check for MTU lacks checking for the KIOV/IOV cases, and false positive triggered for very large incomming buffer. Cray-bug-id: LUS-7948 Signed-off-by: Alexey Lyashkov Change-Id: Id3497e5f63470c24b2e51703fc564b02c9516aa6 Reviewed-on: https://review.whamcloud.com/36796 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Serguei Smirnov Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin --- lnet/lnet/lib-md.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lnet/lnet/lib-md.c b/lnet/lnet/lib-md.c index 99b1305..53a8557 100644 --- a/lnet/lnet/lib-md.c +++ b/lnet/lnet/lib-md.c @@ -330,10 +330,6 @@ lnet_md_validate(struct lnet_md *umd) CERROR("Invalid option: too many fragments %u, %d max\n", umd->length, LNET_MAX_IOV); return -EINVAL; - } else if (umd->length > LNET_MTU) { - CERROR("Invalid length: too big fragment size %u, %d max\n", - umd->length, LNET_MTU); - return -EINVAL; } return 0; @@ -467,6 +463,13 @@ LNetMDBind(struct lnet_md umd, enum lnet_unlink unlink, if (rc != 0) goto out_free; + if (md->md_length > LNET_MTU) { + CERROR("Invalid length: too big transfer size %u, %d max\n", + md->md_length, LNET_MTU); + rc = -EINVAL; + goto out_free; + } + cpt = lnet_res_lock_current(); rc = lnet_md_link(md, umd.eq_handle, cpt); -- 1.8.3.1