All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] net: forbid the reentrant RX
@ 2020-07-22  8:57 Jason Wang
  2020-07-22  8:57 ` [PATCH 2/2] e1000e: make TX reentrant Jason Wang
  2020-07-28  4:00 ` [PATCH 1/2] net: forbid the reentrant RX Jason Wang
  0 siblings, 2 replies; 13+ messages in thread
From: Jason Wang @ 2020-07-22  8:57 UTC (permalink / raw)
  To: jasowang, qemu-devel
  Cc: dmitry.fleytman, mst, liq3ea, liq3ea, alxndr, stefanha, pbonzini

The memory API allows DMA into NIC's MMIO area. This means the NIC's
RX routine must be reentrant. Instead of auditing all the NIC, we can
simply detect the reentrancy and return early. The queue->delivering
is set and cleared by qemu_net_queue_deliver() for other queue helpers
to know whether the delivering in on going (NIC's receive is being
called). We can check it and return early in qemu_net_queue_flush() to
forbid reentrant RX.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net/queue.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/queue.c b/net/queue.c
index 0164727e39..19e32c80fd 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -250,6 +250,9 @@ void qemu_net_queue_purge(NetQueue *queue, NetClientState *from)
 
 bool qemu_net_queue_flush(NetQueue *queue)
 {
+    if (queue->delivering)
+        return false;
+
     while (!QTAILQ_EMPTY(&queue->packets)) {
         NetPacket *packet;
         int ret;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-09-03  4:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22  8:57 [PATCH 1/2] net: forbid the reentrant RX Jason Wang
2020-07-22  8:57 ` [PATCH 2/2] e1000e: make TX reentrant Jason Wang
2020-07-22 11:24   ` Li Qiang
2020-07-23  2:22     ` Jason Wang
2020-07-22 12:53   ` Michael Tokarev
2020-07-23  2:25     ` Jason Wang
2020-07-23 12:01       ` Stefan Hajnoczi
2020-07-23 10:36   ` Peter Maydell
2020-07-24  4:00     ` Jason Wang
2020-07-28  4:00 ` [PATCH 1/2] net: forbid the reentrant RX Jason Wang
2020-09-02 15:56   ` Alexander Bulekov
2020-09-03  3:56     ` Jason Wang
2020-09-03  4:02       ` Alexander Bulekov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.