Blame 0007-net-ne2000-fix-bounds-check-in-ioport-operations.patch

b24b7f
From: Prasad J Pandit <pjp@fedoraproject.org>
b24b7f
Date: Thu, 31 Dec 2015 17:05:27 +0530
b24b7f
Subject: [PATCH] net: ne2000: fix bounds check in ioport operations
b24b7f
b24b7f
While doing ioport r/w operations, ne2000 device emulation suffers
b24b7f
from OOB r/w errors. Update respective array bounds check to avoid
b24b7f
OOB access.
b24b7f
b24b7f
Reported-by: Ling Liu <liuling-it@360.cn>
b24b7f
Cc: qemu-stable@nongnu.org
b24b7f
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
b24b7f
Signed-off-by: Jason Wang <jasowang@redhat.com>
b24b7f
(cherry picked from commit aa7f9966dfdff500bbbf1956d9e115b1fa8987a6)
b24b7f
---
b24b7f
 hw/net/ne2000.c | 10 ++++++----
b24b7f
 1 file changed, 6 insertions(+), 4 deletions(-)
b24b7f
b24b7f
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
b24b7f
index 010f9ef..a3dffff 100644
b24b7f
--- a/hw/net/ne2000.c
b24b7f
+++ b/hw/net/ne2000.c
b24b7f
@@ -467,8 +467,9 @@ static inline void ne2000_mem_writel(NE2000State *s, uint32_t addr,
b24b7f
                                      uint32_t val)
b24b7f
 {
b24b7f
     addr &= ~1; /* XXX: check exact behaviour if not even */
b24b7f
-    if (addr < 32 ||
b24b7f
-        (addr >= NE2000_PMEM_START && addr < NE2000_MEM_SIZE)) {
b24b7f
+    if (addr < 32
b24b7f
+        || (addr >= NE2000_PMEM_START
b24b7f
+            && addr + sizeof(uint32_t) <= NE2000_MEM_SIZE)) {
b24b7f
         stl_le_p(s->mem + addr, val);
b24b7f
     }
b24b7f
 }
b24b7f
@@ -497,8 +498,9 @@ static inline uint32_t ne2000_mem_readw(NE2000State *s, uint32_t addr)
b24b7f
 static inline uint32_t ne2000_mem_readl(NE2000State *s, uint32_t addr)
b24b7f
 {
b24b7f
     addr &= ~1; /* XXX: check exact behaviour if not even */
b24b7f
-    if (addr < 32 ||
b24b7f
-        (addr >= NE2000_PMEM_START && addr < NE2000_MEM_SIZE)) {
b24b7f
+    if (addr < 32
b24b7f
+        || (addr >= NE2000_PMEM_START
b24b7f
+            && addr + sizeof(uint32_t) <= NE2000_MEM_SIZE)) {
b24b7f
         return ldl_le_p(s->mem + addr);
b24b7f
     } else {
b24b7f
         return 0xffffffff;