mirror of https://github.com/proxmox/mirror_qemu
net: add checks to validate ring buffer pointers(CVE-2015-5279)
Ne2000 NIC uses ring buffer of NE2000_MEM_SIZE(49152) bytes to process network packets. While receiving packets via ne2000_receive() routine, a local 'index' variable could exceed the ring buffer size, which could lead to a memory buffer overflow. Added other checks at initialisation. Reported-by: Qinghao Tang <luodalongde@gmail.com> Signed-off-by: P J P <pjp@fedoraproject.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>master
parent
b947ac2bf2
commit
9bbdbc66e5
|
@ -221,6 +221,9 @@ ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
|
||||||
}
|
}
|
||||||
|
|
||||||
index = s->curpag << 8;
|
index = s->curpag << 8;
|
||||||
|
if (index >= NE2000_PMEM_END) {
|
||||||
|
index = s->start;
|
||||||
|
}
|
||||||
/* 4 bytes for header */
|
/* 4 bytes for header */
|
||||||
total_len = size + 4;
|
total_len = size + 4;
|
||||||
/* address for next packet (4 bytes for CRC) */
|
/* address for next packet (4 bytes for CRC) */
|
||||||
|
@ -306,13 +309,19 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
|
||||||
offset = addr | (page << 4);
|
offset = addr | (page << 4);
|
||||||
switch(offset) {
|
switch(offset) {
|
||||||
case EN0_STARTPG:
|
case EN0_STARTPG:
|
||||||
s->start = val << 8;
|
if (val << 8 <= NE2000_PMEM_END) {
|
||||||
|
s->start = val << 8;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case EN0_STOPPG:
|
case EN0_STOPPG:
|
||||||
s->stop = val << 8;
|
if (val << 8 <= NE2000_PMEM_END) {
|
||||||
|
s->stop = val << 8;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case EN0_BOUNDARY:
|
case EN0_BOUNDARY:
|
||||||
s->boundary = val;
|
if (val << 8 < NE2000_PMEM_END) {
|
||||||
|
s->boundary = val;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case EN0_IMR:
|
case EN0_IMR:
|
||||||
s->imr = val;
|
s->imr = val;
|
||||||
|
@ -353,7 +362,9 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
|
||||||
s->phys[offset - EN1_PHYS] = val;
|
s->phys[offset - EN1_PHYS] = val;
|
||||||
break;
|
break;
|
||||||
case EN1_CURPAG:
|
case EN1_CURPAG:
|
||||||
s->curpag = val;
|
if (val << 8 < NE2000_PMEM_END) {
|
||||||
|
s->curpag = val;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case EN1_MULT ... EN1_MULT + 7:
|
case EN1_MULT ... EN1_MULT + 7:
|
||||||
s->mult[offset - EN1_MULT] = val;
|
s->mult[offset - EN1_MULT] = val;
|
||||||
|
|
Loading…
Reference in New Issue