Skip to content

Commit db1191a

Browse files
sagigrimberggregkh
authored andcommitted
nvme-tcp: fix H2CData PDU send accounting (again)
commit 25e1f67 upstream. We should not access request members after the last send, even to determine if indeed it was the last data payload send. The reason is that a completion could have arrived and trigger a new execution of the request which overridden these members. This was fixed by commit 825619b ("nvme-tcp: fix possible use-after-completion"). Commit e371af0 broke that assumption again to address cases where multiple r2t pdus are sent per request. To fix it, we need to record the request data_sent and data_len and after the payload network send we reference these counters to determine weather we should advance the request iterator. Fixes: e371af0 ("nvme-tcp: fix incorrect h2cdata pdu offset accounting") Reported-by: Keith Busch <kbusch@kernel.org> Cc: stable@vger.kernel.org # 5.10+ Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5043fbd commit db1191a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎drivers/nvme/host/tcp.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,12 +910,14 @@ static void nvme_tcp_fail_request(struct nvme_tcp_request *req)
910910
static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
911911
{
912912
struct nvme_tcp_queue *queue = req->queue;
913+
int req_data_len = req->data_len;
913914

914915
while (true) {
915916
struct page *page = nvme_tcp_req_cur_page(req);
916917
size_t offset = nvme_tcp_req_cur_offset(req);
917918
size_t len = nvme_tcp_req_cur_length(req);
918919
bool last = nvme_tcp_pdu_last_send(req, len);
920+
int req_data_sent = req->data_sent;
919921
int ret, flags = MSG_DONTWAIT;
920922

921923
if (last && !queue->data_digest && !nvme_tcp_queue_more(queue))
@@ -942,7 +944,7 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
942944
* in the request where we don't want to modify it as we may
943945
* compete with the RX path completing the request.
944946
*/
945-
if (req->data_sent + ret < req->data_len)
947+
if (req_data_sent + ret < req_data_len)
946948
nvme_tcp_advance_req(req, ret);
947949

948950
/* fully successful last send in current PDU */

0 commit comments

Comments
 (0)