提交 d314c14e 编写于 作者: S Sagi Grimberg 提交者: Zheng Zengkai

nvme-rdma: fix in-casule data send for chained sgls

stable inclusion
from stable-5.10.43
commit df7c913f90c3dcda988a254141bf01eb3bb6f123
bugzilla: 109284
CVE: NA

--------------------------------

[ Upstream commit 12b2aaad ]

We have only 2 inline sg entries and we allow 4 sg entries for the send
wr sge. Larger sgls entries will be chained. However when we build
in-capsule send wr sge, we iterate without taking into account that the
sgl may be chained and still fit in-capsule (which can happen if the sgl
is bigger than 2, but lower-equal to 4).

Fix in-capsule data mapping to correctly iterate chained sgls.

Fixes: 38e18002 ("nvme-rdma: Avoid preallocating big SGL for data")
Reported-by: NWalker, Benjamin <benjamin.walker@intel.com>
Signed-off-by: NSagi Grimberg <sagi@grimberg.me>
Reviewed-by: NMax Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 36ddcae8
...@@ -1327,16 +1327,17 @@ static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue, ...@@ -1327,16 +1327,17 @@ static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue,
int count) int count)
{ {
struct nvme_sgl_desc *sg = &c->common.dptr.sgl; struct nvme_sgl_desc *sg = &c->common.dptr.sgl;
struct scatterlist *sgl = req->data_sgl.sg_table.sgl;
struct ib_sge *sge = &req->sge[1]; struct ib_sge *sge = &req->sge[1];
struct scatterlist *sgl;
u32 len = 0; u32 len = 0;
int i; int i;
for (i = 0; i < count; i++, sgl++, sge++) { for_each_sg(req->data_sgl.sg_table.sgl, sgl, count, i) {
sge->addr = sg_dma_address(sgl); sge->addr = sg_dma_address(sgl);
sge->length = sg_dma_len(sgl); sge->length = sg_dma_len(sgl);
sge->lkey = queue->device->pd->local_dma_lkey; sge->lkey = queue->device->pd->local_dma_lkey;
len += sge->length; len += sge->length;
sge++;
} }
sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册