Subject: [PATCH 07/10] rtl8139: switch to use qemu_receive_packet() for loopback

From: Alexander Bulekov <[email-masked]>
Date: Fri, 26 Feb 2021 13:47:53 -0500

This patch switches to use qemu_receive_packet() which can detect
reentrancy and return early.

This is intended to address CVE-2021-3416.

Cc: Prasad J Pandit <[email-masked]>
Cc: [email-masked]
Buglink: https://bugs.launchpad.net/qemu/+bug/1910826
Reviewed-by: Philippe Mathieu-Daudé <[email-masked]
Signed-off-by: Alexander Bulekov <[email-masked]>
Signed-off-by: Jason Wang <[email-masked]>

Upstream-Status: Backport [5311fb805a4403bba024e83886fa0e7572265de4]
CVE: CVE-2021-3416

Signed-off-by: Sakib Sajal <[email-masked]>
---
 hw/net/rtl8139.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: qemu-4.2.0/hw/net/rtl8139.c
===================================================================
--- qemu-4.2.0.orig/hw/net/rtl8139.c
+++ qemu-4.2.0/hw/net/rtl8139.c
@@ -1793,7 +1793,7 @@ static void rtl8139_transfer_frame(RTL81
         }
 
         DPRINTF("+++ transmit loopback mode\n");
-        rtl8139_do_receive(qemu_get_queue(s->nic), buf, size, do_interrupt);
+        qemu_receive_packet(qemu_get_queue(s->nic), buf, size);
 
         if (iov) {
             g_free(buf2);