|
|
bf445db |
From: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
bf445db |
Date: Fri, 20 Nov 2015 11:50:31 +0530
|
|
|
bf445db |
Subject: [PATCH] net: pcnet: add check to validate receive data
|
|
|
bf445db |
size(CVE-2015-7504)
|
|
|
bf445db |
|
|
|
bf445db |
In loopback mode, pcnet_receive routine appends CRC code to the
|
|
|
bf445db |
receive buffer. If the data size given is same as the buffer size,
|
|
|
bf445db |
the appended CRC code overwrites 4 bytes after s->buffer. Added a
|
|
|
bf445db |
check to avoid that.
|
|
|
bf445db |
|
|
|
bf445db |
Reported by: Qinghao Tang <luodalongde@gmail.com>
|
|
|
bf445db |
Cc: qemu-stable@nongnu.org
|
|
|
bf445db |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
bf445db |
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
bf445db |
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
|
|
bf445db |
|
|
|
bf445db |
(cherry picked from commit 837f21aacf5a714c23ddaadbbc5212f9b661e3f7)
|
|
|
bf445db |
---
|
|
|
bf445db |
hw/net/pcnet.c | 8 +++++---
|
|
|
bf445db |
1 file changed, 5 insertions(+), 3 deletions(-)
|
|
|
bf445db |
|
|
|
bf445db |
diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
|
|
|
bf445db |
index 68b9981..03a56b2 100644
|
|
|
bf445db |
--- a/hw/net/pcnet.c
|
|
|
bf445db |
+++ b/hw/net/pcnet.c
|
|
|
bf445db |
@@ -1094,7 +1094,7 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
|
|
|
bf445db |
uint32_t fcs = ~0;
|
|
|
bf445db |
uint8_t *p = src;
|
|
|
bf445db |
|
|
|
bf445db |
- while (p != &src[size-4])
|
|
|
bf445db |
+ while (p != &src[size])
|
|
|
bf445db |
CRC(fcs, *p++);
|
|
|
bf445db |
crc_err = (*(uint32_t *)p != htonl(fcs));
|
|
|
bf445db |
}
|
|
|
bf445db |
@@ -1243,8 +1243,10 @@ static void pcnet_transmit(PCNetState *s)
|
|
|
bf445db |
bcnt = 4096 - GET_FIELD(tmd.length, TMDL, BCNT);
|
|
|
bf445db |
|
|
|
bf445db |
/* if multi-tmd packet outsizes s->buffer then skip it silently.
|
|
|
bf445db |
- Note: this is not what real hw does */
|
|
|
bf445db |
- if (s->xmit_pos + bcnt > sizeof(s->buffer)) {
|
|
|
bf445db |
+ * Note: this is not what real hw does.
|
|
|
bf445db |
+ * Last four bytes of s->buffer are used to store CRC FCS code.
|
|
|
bf445db |
+ */
|
|
|
bf445db |
+ if (s->xmit_pos + bcnt > sizeof(s->buffer) - 4) {
|
|
|
bf445db |
s->xmit_pos = -1;
|
|
|
bf445db |
goto txdone;
|
|
|
bf445db |
}
|