public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Chris Leech <cleech@redhat.com>
To: Sagi Grimberg <sagi@grimberg.me>, linux-nvme@lists.infradead.org
Cc: John Meneghini <jmeneghi@redhat.com>
Subject: [PATCH 1/1] nvme-tcp: fence TCP socket on transport error
Date: Mon, 20 Mar 2023 15:09:47 -0700	[thread overview]
Message-ID: <20230320220947.3244247-2-cleech@redhat.com> (raw)
In-Reply-To: <20230320220947.3244247-1-cleech@redhat.com>

Ensure that no further socket reads occur after a receive processing
error, either from io_work being re-scheduled or nvme_tcp_poll.

Failing to do so can result in unrecognised PDU payloads or TCP stream
garbage being processed as a C2H data PDU, and potentially start copying
the payload to an invalid destination after looking up a request using a
bogus command id.

Signed-off-by: Chris Leech <cleech@redhat.com>
---
 drivers/nvme/host/tcp.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 42c0598c31f2..49e8eb576527 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -888,6 +888,13 @@ static int nvme_tcp_recv_skb(read_descriptor_t *desc, struct sk_buff *skb,
 	size_t consumed = len;
 	int result;
 
+	if (!queue->rd_enabled) {
+		/* io_work or polling happening after receive error
+		 * waiting on error recovery
+		 */
+		return -EFAULT;
+	}
+
 	while (len) {
 		switch (nvme_tcp_recv_state(queue)) {
 		case NVME_TCP_RECV_PDU:
-- 
2.39.2



  reply	other threads:[~2023-03-20 22:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 22:09 [PATCH 0/1] nvme-tcp: fence TCP socket on transport error Chris Leech
2023-03-20 22:09 ` Chris Leech [this message]
2023-03-21  8:30   ` [PATCH 1/1] " Sagi Grimberg
2023-03-21 16:30     ` Chris Leech
2023-03-21 16:30 ` [PATCH v2 1/1] nvme-tcp: fence TCP socket on receive error Chris Leech
2023-03-21 20:19   ` John Meneghini
2023-03-22  7:13   ` Sagi Grimberg
2023-04-05 15:21   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230320220947.3244247-2-cleech@redhat.com \
    --to=cleech@redhat.com \
    --cc=jmeneghi@redhat.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox