From: Jason Wang <jasowang@redhat.com>
To: peter.maydell@linaro.org, qemu-devel@nongnu.org
Cc: Prasad J Pandit <pjp@fedoraproject.org>,
Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PULL 2/5] net: mipsnet: check transmit buffer size before sending
Date: Tue, 28 Jun 2016 11:35:07 +0800 [thread overview]
Message-ID: <1467084910-14643-3-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1467084910-14643-1-git-send-email-jasowang@redhat.com>
From: Prasad J Pandit <pjp@fedoraproject.org>
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>
---
hw/net/mipsnet.c | 8 +++++---
1 file 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;
--
2.7.4
next prev parent reply other threads:[~2016-06-28 3:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-28 3:35 [Qemu-devel] [PULL 0/5] Net patches Jason Wang
2016-06-28 3:35 ` [Qemu-devel] [PULL 1/5] net: fix qemu_announce_self not emitting packets Jason Wang
2016-06-28 3:35 ` Jason Wang [this message]
2016-06-28 3:35 ` [Qemu-devel] [PULL 3/5] Change net/socket.c to use socket_*() functions Jason Wang
2016-06-28 3:35 ` [Qemu-devel] [PULL 4/5] rtl8139: save/load RxMulOk counter (again) Jason Wang
2016-06-28 3:35 ` [Qemu-devel] [PULL 5/5] vmxnet3: Fix reading/writing guest memory specially when behind an IOMMU Jason Wang
2016-06-28 10:07 ` [Qemu-devel] [PULL 0/5] Net patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467084910-14643-3-git-send-email-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).