[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 4/6] usb: check RNDIS buffer offsets & length
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PULL 4/6] usb: check RNDIS buffer offsets & length |
Date: |
Tue, 23 Feb 2016 11:54:56 +0100 |
From: Prasad J Pandit <address@hidden>
When processing remote NDIS control message packets,
the USB Net device emulator uses a fixed length(4096) data buffer.
The incoming informationBufferOffset & Length combination could
overflow and cross that range. Check control message buffer
offsets and length to avoid it.
Reported-by: Qinghao Tang <address@hidden>
Signed-off-by: Prasad J Pandit <address@hidden>
Message-id: address@hidden
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/dev-network.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 5dc4538..c6abd38 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -916,8 +916,9 @@ static int rndis_query_response(USBNetState *s,
bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8;
buflen = le32_to_cpu(buf->InformationBufferLength);
- if (bufoffs + buflen > length)
+ if (buflen > length || bufoffs >= length || bufoffs + buflen > length) {
return USB_RET_STALL;
+ }
infobuflen = ndis_query(s, le32_to_cpu(buf->OID),
bufoffs + (uint8_t *) buf, buflen, infobuf,
@@ -962,8 +963,9 @@ static int rndis_set_response(USBNetState *s,
bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8;
buflen = le32_to_cpu(buf->InformationBufferLength);
- if (bufoffs + buflen > length)
+ if (buflen > length || bufoffs >= length || bufoffs + buflen > length) {
return USB_RET_STALL;
+ }
ret = ndis_set(s, le32_to_cpu(buf->OID),
bufoffs + (uint8_t *) buf, buflen);
@@ -1213,8 +1215,9 @@ static void usb_net_handle_dataout(USBNetState *s,
USBPacket *p)
if (le32_to_cpu(msg->MessageType) == RNDIS_PACKET_MSG) {
uint32_t offs = 8 + le32_to_cpu(msg->DataOffset);
uint32_t size = le32_to_cpu(msg->DataLength);
- if (offs + size <= len)
+ if (offs < len && size < len && offs + size <= len) {
qemu_send_packet(qemu_get_queue(s->nic), s->out_buf + offs, size);
+ }
}
s->out_ptr -= len;
memmove(s->out_buf, &s->out_buf[len], s->out_ptr);
--
1.8.3.1
- [Qemu-devel] [PULL 0/6] usb: misc bugfixes, Gerd Hoffmann, 2016/02/23
- [Qemu-devel] [PULL 2/6] tusb6010: move from hw/timer to hw/usb, Gerd Hoffmann, 2016/02/23
- [Qemu-devel] [PULL 1/6] usb: check USB configuration descriptor object, Gerd Hoffmann, 2016/02/23
- [Qemu-devel] [PULL 4/6] usb: check RNDIS buffer offsets & length,
Gerd Hoffmann <=
- [Qemu-devel] [PULL 5/6] usb: add pid check at the first of uhci_handle_td(), Gerd Hoffmann, 2016/02/23
- [Qemu-devel] [PULL 6/6] ohci: allocate timer only once., Gerd Hoffmann, 2016/02/23
- [Qemu-devel] [PULL 3/6] usb: check RNDIS message length, Gerd Hoffmann, 2016/02/23
- Re: [Qemu-devel] [PULL 0/6] usb: misc bugfixes, Peter Maydell, 2016/02/23