Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From fdc89e90fac40c5ca2686733df17b6423fb8d8fb Mon Sep 17 00:00:00 2001 |
| 2 | From: Jason Wang <jasowang@redhat.com> |
| 3 | Date: Wed, 30 May 2018 13:08:15 +0800 |
| 4 | Subject: [PATCH] ne2000: fix possible out of bound access in ne2000_receive |
| 5 | |
| 6 | In ne2000_receive(), we try to assign size_ to size which converts |
| 7 | from size_t to integer. This will cause troubles when size_ is greater |
| 8 | INT_MAX, this will lead a negative value in size and it can then pass |
| 9 | the check of size < MIN_BUF_SIZE which may lead out of bound access of |
| 10 | for both buf and buf1. |
| 11 | |
| 12 | Fixing by converting the type of size to size_t. |
| 13 | |
| 14 | CC: qemu-stable@nongnu.org |
| 15 | Reported-by: Daniel Shapira <daniel@twistlock.com> |
| 16 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> |
| 17 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
| 18 | |
| 19 | Upstream-Status: Backport [https://git.qemu.org/?p=qemu.git;a=commitdiff |
| 20 | ;h=fdc89e90fac40c5ca2686733df17b6423fb8d8fb#patch1] |
| 21 | |
| 22 | CVE: CVE-2018-10839 |
| 23 | |
| 24 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
| 25 | --- |
| 26 | hw/net/ne2000.c | 4 ++-- |
| 27 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 28 | |
| 29 | diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c |
| 30 | index 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 | -- |
| 52 | 1.8.3.1 |