blob: 7e1e442a41b3dec1698dad1f01a7c69f7cdabd9d [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From fdc89e90fac40c5ca2686733df17b6423fb8d8fb Mon Sep 17 00:00:00 2001
2From: Jason Wang <jasowang@redhat.com>
3Date: Wed, 30 May 2018 13:08:15 +0800
4Subject: [PATCH] ne2000: fix possible out of bound access in ne2000_receive
5
6In ne2000_receive(), we try to assign size_ to size which converts
7from size_t to integer. This will cause troubles when size_ is greater
8INT_MAX, this will lead a negative value in size and it can then pass
9the check of size < MIN_BUF_SIZE which may lead out of bound access of
10for both buf and buf1.
11
12Fixing by converting the type of size to size_t.
13
14CC: qemu-stable@nongnu.org
15Reported-by: Daniel Shapira <daniel@twistlock.com>
16Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
17Signed-off-by: Jason Wang <jasowang@redhat.com>
18
19Upstream-Status: Backport [https://git.qemu.org/?p=qemu.git;a=commitdiff
20;h=fdc89e90fac40c5ca2686733df17b6423fb8d8fb#patch1]
21
22CVE: CVE-2018-10839
23
24Signed-off-by: Changqing Li <changqing.li@windriver.com>
25---
26 hw/net/ne2000.c | 4 ++--
27 1 file changed, 2 insertions(+), 2 deletions(-)
28
29diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
30index 07d79e3..869518e 100644
31--- a/hw/net/ne2000.c
32+++ b/hw/net/ne2000.c
33@@ -174,7 +174,7 @@ static int ne2000_buffer_full(NE2000State *s)
34 ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
35 {
36 NE2000State *s = qemu_get_nic_opaque(nc);
37- int size = size_;
38+ size_t size = size_;
39 uint8_t *p;
40 unsigned int total_len, next, avail, len, index, mcast_idx;
41 uint8_t buf1[60];
42@@ -182,7 +182,7 @@ ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
43 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
44
45 #if defined(DEBUG_NE2000)
46- printf("NE2000: received len=%d\n", size);
47+ printf("NE2000: received len=%zu\n", size);
48 #endif
49
50 if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
51--
521.8.3.1