Skip to contentSkip to conversation

hw/net/tulip: Fix DMA reentrancy issue with stack overflow (CVE-2022-2962)

PATCH In review Thomas Huth 2 participants 2 messages Aug 27, 2022 – Sep 9, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/net/tulip: Fix DMA reentrancy issue with stack overflow (CVE-2022-2962)

The Tulip NIC can be used to trigger an endless recursion when its descriptors are set up to its own MMIO address space. Fix it by limiting the DMA accesses to normal memory.

Fixes: CVE-2022-2962
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1171

---
 hw/net/tulip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/tulip.c +2 -2
index 097e905bec..b9e42c322a 100644
@@ -70,7 +70,7 @@ static const VMStateDescription vmstate_pci_tulip = {
 static void tulip_desc_read(TULIPState *s, hwaddr p,
         struct tulip_descriptor *desc)
 {
-    const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
+    const MemTxAttrs attrs = { .memory = true };
 
     if (s->csr[0] & CSR0_DBO) {
         ldl_be_pci_dma(&s->dev, p, &desc->status, attrs);
@@ -88,7 +88,7 @@ static void tulip_desc_read(TULIPState *s, hwaddr p,
 static void tulip_desc_write(TULIPState *s, hwaddr p,
         struct tulip_descriptor *desc)
 {
-    const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
+    const MemTxAttrs attrs = { .memory = true };
 
     if (s->csr[0] & CSR0_DBO) {
         stl_be_pci_dma(&s->dev, p, desc->status, attrs);
Signature · 1 line
2.31.1
#1 lore raw
Quoted 8 lines · Thomas Huth

The Tulip NIC can be used to trigger an endless recursion when its descriptors are set up to its own MMIO address space. Fix it by limiting the DMA accesses to normal memory.

Fixes: CVE-2022-2962
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1171

Zheyu has posted a similar path which has been merged:

commit 36a894aeb64a2e02871016da1c37d4a4ca109182

Author: Zheyu Ma <[email protected]>
Date:   Sun Aug 21 20:43:43 2022 +0800

net: tulip: Restrict DMA engine to memories

Thanks

Quoted 29 lines
---
 hw/net/tulip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/tulip.c +2 -3
index 097e905bec..b9e42c322a 100644
@@ -70,7 +70,7 @@ static const VMStateDescription vmstate_pci_tulip = {
 static void tulip_desc_read(TULIPState *s, hwaddr p,
         struct tulip_descriptor *desc)
 {
-    const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
+    const MemTxAttrs attrs = { .memory = true };
 
     if (s->csr[0] & CSR0_DBO) {
         ldl_be_pci_dma(&s->dev, p, &desc->status, attrs);
@@ -88,7 +88,7 @@ static void tulip_desc_read(TULIPState *s, hwaddr p,
 static void tulip_desc_write(TULIPState *s, hwaddr p,
         struct tulip_descriptor *desc)
 {
-    const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
+    const MemTxAttrs attrs = { .memory = true };
 
     if (s->csr[0] & CSR0_DBO) {
         stl_be_pci_dma(&s->dev, p, desc->status, attrs);
--

2.31.1