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