From e59a764dd16aa3424fba050f70343f66ab154b7c Mon Sep 17 00:00:00 2001 From: Changcheng Liu Date: Fri, 31 May 2019 18:32:04 +0800 Subject: [PATCH] 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 --- src/msg/async/rdma/Infiniband.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/msg/async/rdma/Infiniband.cc b/src/msg/async/rdma/Infiniband.cc index e920d300ae39b..4f7b344367a35 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; -- 2.39.5