yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
1072c8
From 1e01e2f96fd5e903394eab59365d5363394c8b18 Mon Sep 17 00:00:00 2001
1072c8
From: Jon Maloy <jmaloy@redhat.com>
1072c8
Date: Tue, 13 Apr 2021 18:59:12 -0400
1072c8
Subject: [PATCH 3/5] net: forbid the reentrant RX
1072c8
1072c8
RH-Author: Jon Maloy <jmaloy@redhat.com>
1072c8
Message-id: <20210413185912.3811035-2-jmaloy@redhat.com>
1072c8
Patchwork-id: 101467
1072c8
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 1/1] net: forbid the reentrant RX
1072c8
Bugzilla: 1859175
1072c8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
1072c8
RH-Acked-by: Thomas Huth <thuth@redhat.com>
1072c8
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
1072c8
1072c8
From: Jason Wang <jasowang@redhat.com>
1072c8
1072c8
The memory API allows DMA into NIC's MMIO area. This means the NIC's
1072c8
RX routine must be reentrant. Instead of auditing all the NIC, we can
1072c8
simply detect the reentrancy and return early. The queue->delivering
1072c8
is set and cleared by qemu_net_queue_deliver() for other queue helpers
1072c8
to know whether the delivering in on going (NIC's receive is being
1072c8
called). We can check it and return early in qemu_net_queue_flush() to
1072c8
forbid reentrant RX.
1072c8
1072c8
Signed-off-by: Jason Wang <jasowang@redhat.com>
1072c8
1072c8
(cherry picked from commit 22dc8663d9fc7baa22100544c600b6285a63c7a3)
1072c8
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
1072c8
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
1072c8
---
1072c8
 net/queue.c | 3 +++
1072c8
 1 file changed, 3 insertions(+)
1072c8
1072c8
diff --git a/net/queue.c b/net/queue.c
1072c8
index 61276ca4be..c679d79f4b 100644
1072c8
--- a/net/queue.c
1072c8
+++ b/net/queue.c
1072c8
@@ -250,6 +250,9 @@ void qemu_net_queue_purge(NetQueue *queue, NetClientState *from)
1072c8
 
1072c8
 bool qemu_net_queue_flush(NetQueue *queue)
1072c8
 {
1072c8
+    if (queue->delivering)
1072c8
+        return false;
1072c8
+
1072c8
     while (!QTAILQ_EMPTY(&queue->packets)) {
1072c8
         NetPacket *packet;
1072c8
         int ret;
1072c8
-- 
1072c8
2.27.0
1072c8