]> git.proxmox.com Git - pve-qemu-kvm.git/commitdiff
added ne2000 patch
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 22 Oct 2015 10:10:17 +0000 (12:10 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 22 Oct 2015 10:23:19 +0000 (12:23 +0200)
debian/patches/net-add-checks-to-validate-ring-buffer-pointers.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/net-add-checks-to-validate-ring-buffer-pointers.patch b/debian/patches/net-add-checks-to-validate-ring-buffer-pointers.patch
new file mode 100644 (file)
index 0000000..8714382
--- /dev/null
@@ -0,0 +1,71 @@
+From 7aa2bcad0ca837dd6d4bf4fa38a80314b4a6b755 Mon Sep 17 00:00:00 2001
+From: P J P <pjp@fedoraproject.org>
+Date: Tue, 15 Sep 2015 16:40:49 +0530
+Subject: [PATCH] net: add checks to validate ring buffer pointers
+
+Ne2000 NIC uses ring buffer of NE2000_MEM_SIZE(49152)
+bytes to process network packets. While receiving packets
+via ne2000_receive() routine, a local 'index' variable
+could exceed the ring buffer size, which could lead to a
+memory buffer overflow. Added other checks at initialisation.
+
+Reported-by: Qinghao Tang <luodalongde@gmail.com>
+Signed-off-by: P J P <pjp@fedoraproject.org>
+Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
+(cherry picked from commit 9bbdbc66e5765068dce76e9269dce4547afd8ad4)
+Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
+---
+ hw/net/ne2000.c |   19 +++++++++++++++----
+ 1 files changed, 15 insertions(+), 4 deletions(-)
+
+diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
+index 3492db3..9278571 100644
+--- a/hw/net/ne2000.c
++++ b/hw/net/ne2000.c
+@@ -230,6 +230,9 @@ ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
+     }
+     index = s->curpag << 8;
++    if (index >= NE2000_PMEM_END) {
++        index = s->start;
++    }
+     /* 4 bytes for header */
+     total_len = size + 4;
+     /* address for next packet (4 bytes for CRC) */
+@@ -315,13 +318,19 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+         offset = addr | (page << 4);
+         switch(offset) {
+         case EN0_STARTPG:
+-            s->start = val << 8;
++            if (val << 8 <= NE2000_PMEM_END) {
++                s->start = val << 8;
++            }
+             break;
+         case EN0_STOPPG:
+-            s->stop = val << 8;
++            if (val << 8 <= NE2000_PMEM_END) {
++                s->stop = val << 8;
++            }
+             break;
+         case EN0_BOUNDARY:
+-            s->boundary = val;
++            if (val << 8 < NE2000_PMEM_END) {
++                s->boundary = val;
++            }
+             break;
+         case EN0_IMR:
+             s->imr = val;
+@@ -362,7 +371,9 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+             s->phys[offset - EN1_PHYS] = val;
+             break;
+         case EN1_CURPAG:
+-            s->curpag = val;
++            if (val << 8 < NE2000_PMEM_END) {
++                s->curpag = val;
++            }
+             break;
+         case EN1_MULT ... EN1_MULT + 7:
+             s->mult[offset - EN1_MULT] = val;
+-- 
+1.7.0.4
+
index 54d052193febd0d90bfe58e76fd14c9fa9c25864..e3b6c8bc7fcb8f6354f93ef7944da05dd25a8131 100644 (file)
@@ -38,3 +38,4 @@ virtio-balloon-dimmfix3.patch
 add-qmp-get-link-status.patch
 virtio-scsi_fix_assert.patch
 0001-fdc-force-the-fifo-access-to-be-in-bounds-of-the-all.patch
+net-add-checks-to-validate-ring-buffer-pointers.patch