From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EEB52EE26D; Thu, 3 Jul 2025 14:57:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751554639; cv=none; b=tsLarzH2V9H3cOhdoM1H0xCMKCB272ODSONm7aPKLBX6QocLzGBLnJVsRgpk9NNLNTAlDseKwSP91NSSMvnn/9Kll00b28692S7Z4VShOx4PbqwpMt31ph2luDO4iL6qhgrWoPQTbR8gnRP9BNwLRuJBRmBMxVMHbwJXms/rC/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751554639; c=relaxed/simple; bh=s1muRZmQee3zmuZuMRItZiE2Drc0gQSELYGFQ/cEVn8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XFR2PqkuZ5GcLSY8KXsLIG3QNEWPkxSEPQ5mAX1KxmCEZqPk9Ma04atxe8rdtjtzY9I90axeo5OizXA+hU6CKlXJkY8a+i0o9/rJdb2uN2dxMDVS7A047X/lj6eeCi6tUGlLxQ8/1a599N8nEMkgNWHOD2yDVyPdupW9LMj8fJE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GHk8PzHk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GHk8PzHk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFE23C4CEE3; Thu, 3 Jul 2025 14:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1751554639; bh=s1muRZmQee3zmuZuMRItZiE2Drc0gQSELYGFQ/cEVn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GHk8PzHk7PvEoSiEq8J03zZJ2Prbim/9gc0K1Zclnj08f4D0TYiFxDDHy/W8qv41L aog6uZ56BPqoc4EtCSjHaAJhQVN7IQ5mK/UXKeXWrsnE77VljBTu2ssBbN+X9XGtNl MBUjpTu4sDA1nMVwylVKxrmzho+CInVYk5/yOgKQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hannes Reinecke , Sagi Grimberg , Christoph Hellwig , Sasha Levin Subject: [PATCH 6.15 034/263] nvme-tcp: sanitize request list handling Date: Thu, 3 Jul 2025 16:39:14 +0200 Message-ID: <20250703144005.665160725@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250703144004.276210867@linuxfoundation.org> References: <20250703144004.276210867@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hannes Reinecke [ Upstream commit 0bf04c874fcb1ae46a863034296e4b33d8fbd66c ] Validate the request in nvme_tcp_handle_r2t() to ensure it's not part of any list, otherwise a malicious R2T PDU might inject a loop in request list processing. Signed-off-by: Hannes Reinecke Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/tcp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 9f4f6464dee04..b882ee6ef40f6 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -452,7 +452,8 @@ nvme_tcp_fetch_request(struct nvme_tcp_queue *queue) return NULL; } - list_del(&req->entry); + list_del_init(&req->entry); + init_llist_node(&req->lentry); return req; } @@ -560,6 +561,8 @@ static int nvme_tcp_init_request(struct blk_mq_tag_set *set, req->queue = queue; nvme_req(rq)->ctrl = &ctrl->ctrl; nvme_req(rq)->cmd = &pdu->cmd; + init_llist_node(&req->lentry); + INIT_LIST_HEAD(&req->entry); return 0; } @@ -764,6 +767,14 @@ static int nvme_tcp_handle_r2t(struct nvme_tcp_queue *queue, return -EPROTO; } + if (llist_on_list(&req->lentry) || + !list_empty(&req->entry)) { + dev_err(queue->ctrl->ctrl.device, + "req %d unexpected r2t while processing request\n", + rq->tag); + return -EPROTO; + } + req->pdu_len = 0; req->h2cdata_left = r2t_length; req->h2cdata_offset = r2t_offset; @@ -2641,6 +2652,8 @@ static void nvme_tcp_submit_async_event(struct nvme_ctrl *arg) ctrl->async_req.offset = 0; ctrl->async_req.curr_bio = NULL; ctrl->async_req.data_len = 0; + init_llist_node(&ctrl->async_req.lentry); + INIT_LIST_HEAD(&ctrl->async_req.entry); nvme_tcp_queue_request(&ctrl->async_req, true, true); } -- 2.39.5