]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/0001-net-pcnet-add-check-to-validate-receive-data-size-CV.patch
Two more fixes
[pve-qemu-kvm.git] / debian / patches / 0001-net-pcnet-add-check-to-validate-receive-data-size-CV.patch
CommitLineData
053c5c6c
WB
1From 6314c83ae14ee32835668e38bb55f4b93b800736 Mon Sep 17 00:00:00 2001
2From: Prasad J Pandit <pjp@fedoraproject.org>
3Date: Mon, 30 Nov 2015 15:38:22 +0800
4Subject: [PATCH 1/2] net: pcnet: add check to validate receive data
5 size(CVE-2015-7504)
6
7In loopback mode, pcnet_receive routine appends CRC code to the
8receive buffer. If the data size given is same as the buffer size,
9the appended CRC code overwrites 4 bytes after s->buffer. Added a
10check to avoid that.
11
12Reported by: Qinghao Tang <luodalongde@gmail.com>
13Cc: qemu-stable@nongnu.org
14Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
15Signed-off-by: Jason Wang <jasowang@redhat.com>
16---
17 hw/net/pcnet.c | 8 +++++---
18 1 file changed, 5 insertions(+), 3 deletions(-)
19
20diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
21index 0eb3cc4..309c40b 100644
22--- a/hw/net/pcnet.c
23+++ b/hw/net/pcnet.c
24@@ -1084,7 +1084,7 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
25 uint32_t fcs = ~0;
26 uint8_t *p = src;
27
28- while (p != &src[size-4])
29+ while (p != &src[size])
30 CRC(fcs, *p++);
31 crc_err = (*(uint32_t *)p != htonl(fcs));
32 }
33@@ -1233,8 +1233,10 @@ static void pcnet_transmit(PCNetState *s)
34 bcnt = 4096 - GET_FIELD(tmd.length, TMDL, BCNT);
35
36 /* if multi-tmd packet outsizes s->buffer then skip it silently.
37- Note: this is not what real hw does */
38- if (s->xmit_pos + bcnt > sizeof(s->buffer)) {
39+ * Note: this is not what real hw does.
40+ * Last four bytes of s->buffer are used to store CRC FCS code.
41+ */
42+ if (s->xmit_pos + bcnt > sizeof(s->buffer) - 4) {
43 s->xmit_pos = -1;
44 goto txdone;
45 }
46--
472.1.4
48