54cb130
From: Prasad J Pandit <pjp@fedoraproject.org>
54cb130
Date: Wed, 24 Feb 2016 11:41:33 +0530
54cb130
Subject: [PATCH] net: ne2000: check ring buffer control registers
54cb130
54cb130
Ne2000 NIC uses ring buffer of NE2000_MEM_SIZE(49152)
54cb130
bytes to process network packets. Registers PSTART & PSTOP
54cb130
define ring buffer size & location. Setting these registers
54cb130
to invalid values could lead to infinite loop or OOB r/w
54cb130
access issues. Add check to avoid it.
54cb130
54cb130
Reported-by: Yang Hongke <yanghongke@huawei.com>
54cb130
Tested-by: Yang Hongke <yanghongke@huawei.com>
54cb130
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
54cb130
Signed-off-by: Jason Wang <jasowang@redhat.com>
54cb130
(cherry picked from commit 415ab35a441eca767d033a2702223e785b9d5190)
54cb130
---
54cb130
 hw/net/ne2000.c | 4 ++++
54cb130
 1 file changed, 4 insertions(+)
54cb130
54cb130
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
54cb130
index a3dffff..995115e 100644
54cb130
--- a/hw/net/ne2000.c
54cb130
+++ b/hw/net/ne2000.c
54cb130
@@ -154,6 +154,10 @@ static int ne2000_buffer_full(NE2000State *s)
54cb130
 {
54cb130
     int avail, index, boundary;
54cb130
 
54cb130
+    if (s->stop <= s->start) {
54cb130
+        return 1;
54cb130
+    }
54cb130
+
54cb130
     index = s->curpag << 8;
54cb130
     boundary = s->boundary << 8;
54cb130
     if (index < boundary)