From: Changcheng Liu Date: Fri, 31 May 2019 10:32:04 +0000 (+0800) Subject: msg/async/rdma: check memory region size before tx buffer allocation X-Git-Tag: v15.1.0~1781^2~36 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e59a764dd16aa3424fba050f70343f66ab154b7c;p=ceph-ci.git msg/async/rdma: check memory region size before tx buffer allocation It'll trigger out-of-bound access problem in kernel if the required memory region size is bigger than ibv_device_attr.max_mr_size Signed-off-by: Changcheng Liu --- diff --git a/src/msg/async/rdma/Infiniband.cc b/src/msg/async/rdma/Infiniband.cc index e920d300ae3..4f7b344367a 100644 --- a/src/msg/async/rdma/Infiniband.cc +++ b/src/msg/async/rdma/Infiniband.cc @@ -943,6 +943,12 @@ void Infiniband::init() ldout(cct, 0) << __func__ << " using the max allowed send buffers: " << tx_queue_len << dendl; } + //check for the memory region size misconfiguration + if ((uint64_t)cct->_conf->ms_async_rdma_buffer_size * tx_queue_len > device->device_attr.max_mr_size) { + lderr(cct) << __func__ << " Out of max memory region size " << dendl; + ceph_abort(); + } + ldout(cct, 1) << __func__ << " device allow " << device->device_attr.max_cqe << " completion entries" << dendl;