Subject: [PATCH 05/10] sungem: switch to use qemu_receive_packet() for loopback

From: Jason Wang <[email-masked]>
Date: Wed, 24 Feb 2021 13:14:35 +0800

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]
Reviewed-by: Mark Cave-Ayland <[email-masked]>
Reviewed-by: Philippe Mathieu-Daudé <[email-masked]>
Reviewed-by: Alistair Francis <[email-masked]>
Signed-off-by: Jason Wang <[email-masked]>

Upstream-Status: Backport [8c92060d3c0248bd4d515719a35922cd2391b9b4]
CVE: CVE-2021-3416

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

Index: qemu-4.2.0/hw/net/sungem.c
===================================================================
--- qemu-4.2.0.orig/hw/net/sungem.c
+++ qemu-4.2.0/hw/net/sungem.c
@@ -305,7 +305,7 @@ static void sungem_send_packet(SunGEMSta
     NetClientState *nc = qemu_get_queue(s->nic);
 
     if (s->macregs[MAC_XIFCFG >> 2] & MAC_XIFCFG_LBCK) {
-        nc->info->receive(nc, buf, size);
+        qemu_receive_packet(nc, buf, size);
     } else {
         qemu_send_packet(nc, buf, size);
     }