OSDN Git Service

nvme-tcp: fence TCP socket on receive error
authorChris Leech <cleech@redhat.com>
Tue, 21 Mar 2023 16:30:25 +0000 (09:30 -0700)
committerChristoph Hellwig <hch@lst.de>
Thu, 13 Apr 2023 06:55:05 +0000 (08:55 +0200)
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>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/tcp.c

index 7723a49..273c1f2 100644 (file)
@@ -876,6 +876,9 @@ static int nvme_tcp_recv_skb(read_descriptor_t *desc, struct sk_buff *skb,
        size_t consumed = len;
        int result;
 
+       if (unlikely(!queue->rd_enabled))
+               return -EFAULT;
+
        while (len) {
                switch (nvme_tcp_recv_state(queue)) {
                case NVME_TCP_RECV_PDU: