Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvmet-rdma: Don't use the inline buffer in order to avoid allocation for small reads

Under extreme conditions this might cause data corruptions. By doing that
we we repost the buffer and then post this buffer for the device to send.
If we happen to use shared receive queues the device might write to the
buffer before it sends it (there is no ordering between send and recv
queues). Without SRQs we probably won't get that if the host doesn't
mis-behave and send more than we allowed it, but relying on that is not
really a good idea.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>

+4 -9
+4 -9
drivers/nvme/target/rdma.c
··· 616 616 if (!len) 617 617 return 0; 618 618 619 - /* use the already allocated data buffer if possible */ 620 - if (len <= NVMET_RDMA_INLINE_DATA_SIZE && rsp->queue->host_qid) { 621 - nvmet_rdma_use_inline_sg(rsp, len, 0); 622 - } else { 623 - status = nvmet_rdma_alloc_sgl(&rsp->req.sg, &rsp->req.sg_cnt, 624 - len); 625 - if (status) 626 - return status; 627 - } 619 + status = nvmet_rdma_alloc_sgl(&rsp->req.sg, &rsp->req.sg_cnt, 620 + len); 621 + if (status) 622 + return status; 628 623 629 624 ret = rdma_rw_ctx_init(&rsp->rw, cm_id->qp, cm_id->port_num, 630 625 rsp->req.sg, rsp->req.sg_cnt, 0, addr, key,