97f3bec
From: Prasad J Pandit <address@hidden>
97f3bec
97f3bec
Ne2000 NIC uses ring buffer of NE2000_MEM_SIZE(49152)
97f3bec
bytes to process network packets. Registers PSTART & PSTOP
97f3bec
define ring buffer size & location. Setting these registers
97f3bec
to invalid values could lead to infinite loop or OOB r/w
97f3bec
access issues. Add check to avoid it.
97f3bec
97f3bec
Reported-by: Yang Hongke <address@hidden>
97f3bec
Signed-off-by: Prasad J Pandit <address@hidden>
97f3bec
---
97f3bec
 hw/net/ne2000.c | 4 ++++
97f3bec
 1 file changed, 4 insertions(+)
97f3bec
97f3bec
Update per review:
97f3bec
  -> https://lists.gnu.org/archive/html/qemu-devel/2016-02/msg05522.html
97f3bec
97f3bec
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
97f3bec
index b032212..ced4666 100644
97f3bec
--- a/tools/qemu-xen/hw/net/ne2000.c
97f3bec
+++ b/tools/qemu-xen/hw/net/ne2000.c
97f3bec
@@ -154,6 +154,10 @@ static int ne2000_buffer_full(NE2000State *s)
97f3bec
 {
97f3bec
     int avail, index, boundary;
97f3bec
 
97f3bec
+    if (s->stop <= s->start) {
97f3bec
+        return 1;
97f3bec
+    }
97f3bec
+
97f3bec
     index = s->curpag << 8;
97f3bec
     boundary = s->boundary << 8;
97f3bec
     if (index < boundary)
97f3bec
-- 
97f3bec
2.5.0