72 lines
2.1 KiB
Diff
72 lines
2.1 KiB
Diff
From bf83e26f55bd16f06df86b1bfc1a9c4708c9d11e Mon Sep 17 00:00:00 2001
|
|
From: Jon Maloy <jmaloy@redhat.com>
|
|
Date: Thu, 21 Oct 2021 12:10:47 -0400
|
|
Subject: [PATCH 1/2] e1000: fix tx re-entrancy problem
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Jon Maloy <jmaloy@redhat.com>
|
|
RH-MergeRequest: 54: e1000: fix tx re-entrancy problem
|
|
RH-Commit: [1/1] 0aa00b3d9db1c318bf133e1f073e289ef4fb1cfa (jmaloy/qemu-kvm)
|
|
RH-Bugzilla: 1930092
|
|
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
RH-Acked-by: Jason Wang <None>
|
|
|
|
The fact that the MMIO handler is not re-entrant causes an infinite
|
|
loop under certain conditions:
|
|
|
|
Guest write to TDT -> Loopback -> RX (DMA to TDT) -> TX
|
|
|
|
We now eliminate the effect of this problem locally in e1000, by adding
|
|
a boolean in struct E1000State indicating when the TX side is busy. This
|
|
will cause any entering new call to return early instead of interfering
|
|
with the ongoing work, and eliminates any risk of looping.
|
|
|
|
This is intended to address CVE-2021-20257.
|
|
|
|
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
|
(cherry picked from commit 25ddb946e6301f42cff3094ea1c25fb78813e7e9)
|
|
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
---
|
|
hw/net/e1000.c | 7 +++++++
|
|
1 file changed, 7 insertions(+)
|
|
|
|
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
|
|
index c2877978d9..282d01e374 100644
|
|
--- a/hw/net/e1000.c
|
|
+++ b/hw/net/e1000.c
|
|
@@ -107,6 +107,7 @@ struct E1000State_st {
|
|
e1000x_txd_props props;
|
|
e1000x_txd_props tso_props;
|
|
uint16_t tso_frames;
|
|
+ bool busy;
|
|
} tx;
|
|
|
|
struct {
|
|
@@ -763,6 +764,11 @@ start_xmit(E1000State *s)
|
|
return;
|
|
}
|
|
|
|
+ if (s->tx.busy) {
|
|
+ return;
|
|
+ }
|
|
+ s->tx.busy = true;
|
|
+
|
|
while (s->mac_reg[TDH] != s->mac_reg[TDT]) {
|
|
base = tx_desc_base(s) +
|
|
sizeof(struct e1000_tx_desc) * s->mac_reg[TDH];
|
|
@@ -789,6 +795,7 @@ start_xmit(E1000State *s)
|
|
break;
|
|
}
|
|
}
|
|
+ s->tx.busy = false;
|
|
set_ics(s, 0, cause);
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|