diff options
author | Prasad J Pandit <pjp@fedoraproject.org> | 2016-06-08 16:07:04 +0530 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2016-06-28 10:13:57 +0800 |
commit | d88d3a093898bd1dc0898c7c87b0d3f555a24a6e (patch) | |
tree | 51445f4200a6ffffae73ac95d5801d17dfbd2abd /hw/net/mipsnet.c | |
parent | ca1ee3d6b546e841a1b9db413eb8fa09f13a061b (diff) | |
download | qemu-d88d3a093898bd1dc0898c7c87b0d3f555a24a6e.zip qemu-d88d3a093898bd1dc0898c7c87b0d3f555a24a6e.tar.gz qemu-d88d3a093898bd1dc0898c7c87b0d3f555a24a6e.tar.bz2 |
net: mipsnet: check transmit buffer size before sending
When processing MIPSnet I/O port write operation, it uses a
transmit buffer tx_buffer[MAX_ETH_FRAME_SIZE=1514]. Two indices
's->tx_written' and 's->tx_count' are used to control data written
to this buffer. If the two were to be equal before writing, it'd
lead to an OOB write access beyond tx_buffer. Add check to avoid it.
Reported-by: Li Qiang <qiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net/mipsnet.c')
-rw-r--r-- | hw/net/mipsnet.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/hw/net/mipsnet.c b/hw/net/mipsnet.c index cf8b823..5115adc 100644 --- a/hw/net/mipsnet.c +++ b/hw/net/mipsnet.c @@ -183,10 +183,12 @@ static void mipsnet_ioport_write(void *opaque, hwaddr addr, break; case MIPSNET_TX_DATA_BUFFER: s->tx_buffer[s->tx_written++] = val; - if (s->tx_written == s->tx_count) { + if ((s->tx_written >= MAX_ETH_FRAME_SIZE) + || (s->tx_written == s->tx_count)) { /* Send buffer. */ - trace_mipsnet_send(s->tx_count); - qemu_send_packet(qemu_get_queue(s->nic), s->tx_buffer, s->tx_count); + trace_mipsnet_send(s->tx_written); + qemu_send_packet(qemu_get_queue(s->nic), + s->tx_buffer, s->tx_written); s->tx_count = s->tx_written = 0; s->intctl |= MIPSNET_INTCTL_TXDONE; s->busy = 1; |