Blame SOURCES/kvm-ne2000-fix-possible-out-of-bound-access-in-ne2000_re.patch

26ba25
From 22ab26a5dcda3ff217d543a4eff8dbad9160ce1c Mon Sep 17 00:00:00 2001
26ba25
From: Xiao Wang <jasowang@redhat.com>
26ba25
Date: Fri, 11 Jan 2019 07:58:56 +0000
26ba25
Subject: [PATCH 01/11] ne2000: fix possible out of bound access in
26ba25
 ne2000_receive
26ba25
MIME-Version: 1.0
26ba25
Content-Type: text/plain; charset=UTF-8
26ba25
Content-Transfer-Encoding: 8bit
26ba25
26ba25
RH-Author: Xiao Wang <jasowang@redhat.com>
26ba25
Message-id: <20190111075904.2030-2-jasowang@redhat.com>
26ba25
Patchwork-id: 83976
26ba25
O-Subject: [RHEL8 qemu-kvm PATCH 1/9] ne2000: fix possible out of bound access in ne2000_receive
26ba25
Bugzilla: 1636784
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
26ba25
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
26ba25
RH-Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
26ba25
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
26ba25
26ba25
In ne2000_receive(), we try to assign size_ to size which converts
26ba25
from size_t to integer. This will cause troubles when size_ is greater
26ba25
INT_MAX, this will lead a negative value in size and it can then pass
26ba25
the check of size < MIN_BUF_SIZE which may lead out of bound access of
26ba25
for both buf and buf1.
26ba25
26ba25
Fixing by converting the type of size to size_t.
26ba25
26ba25
CC: qemu-stable@nongnu.org
26ba25
Reported-by: Daniel Shapira <daniel@twistlock.com>
26ba25
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
26ba25
Signed-off-by: Jason Wang <jasowang@redhat.com>
26ba25
(cherry picked from commit fdc89e90fac40c5ca2686733df17b6423fb8d8fb)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 hw/net/ne2000.c | 4 ++--
26ba25
 1 file changed, 2 insertions(+), 2 deletions(-)
26ba25
26ba25
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
26ba25
index 3a9fc89..19fac06 100644
26ba25
--- a/hw/net/ne2000.c
26ba25
+++ b/hw/net/ne2000.c
26ba25
@@ -173,7 +173,7 @@ static int ne2000_buffer_full(NE2000State *s)
26ba25
 ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
26ba25
 {
26ba25
     NE2000State *s = qemu_get_nic_opaque(nc);
26ba25
-    int size = size_;
26ba25
+    size_t size = size_;
26ba25
     uint8_t *p;
26ba25
     unsigned int total_len, next, avail, len, index, mcast_idx;
26ba25
     uint8_t buf1[60];
26ba25
@@ -181,7 +181,7 @@ ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
26ba25
         { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
26ba25
 
26ba25
 #if defined(DEBUG_NE2000)
26ba25
-    printf("NE2000: received len=%d\n", size);
26ba25
+    printf("NE2000: received len=%zu\n", size);
26ba25
 #endif
26ba25
 
26ba25
     if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
26ba25
-- 
26ba25
1.8.3.1
26ba25