qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Prasad J Pandit <pjp@fedoraproject.org>,
	Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PULL V2 25/27] net: mcf: limit buffer descriptor count
Date: Tue, 27 Sep 2016 18:13:05 +0800	[thread overview]
Message-ID: <1474971187-15627-26-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1474971187-15627-1-git-send-email-jasowang@redhat.com>

From: Prasad J Pandit <pjp@fedoraproject.org>

ColdFire Fast Ethernet Controller uses buffer descriptors to manage
data flow to/fro receive & transmit queues. While transmitting
packets, it could continue to read buffer descriptors if a buffer
descriptor has length of zero and has crafted values in bd.flags.
Set upper limit to number of buffer descriptors.

Reported-by: Li Qiang <liqiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/mcf_fec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
index 0ee8ad9..d31fea1 100644
--- a/hw/net/mcf_fec.c
+++ b/hw/net/mcf_fec.c
@@ -23,6 +23,7 @@ do { printf("mcf_fec: " fmt , ## __VA_ARGS__); } while (0)
 #define DPRINTF(fmt, ...) do {} while(0)
 #endif
 
+#define FEC_MAX_DESC 1024
 #define FEC_MAX_FRAME_SIZE 2032
 
 typedef struct {
@@ -149,7 +150,7 @@ static void mcf_fec_do_tx(mcf_fec_state *s)
     uint32_t addr;
     mcf_fec_bd bd;
     int frame_size;
-    int len;
+    int len, descnt = 0;
     uint8_t frame[FEC_MAX_FRAME_SIZE];
     uint8_t *ptr;
 
@@ -157,7 +158,7 @@ static void mcf_fec_do_tx(mcf_fec_state *s)
     ptr = frame;
     frame_size = 0;
     addr = s->tx_descriptor;
-    while (1) {
+    while (descnt++ < FEC_MAX_DESC) {
         mcf_fec_read_bd(&bd, addr);
         DPRINTF("tx_bd %x flags %04x len %d data %08x\n",
                 addr, bd.flags, bd.length, bd.data);
-- 
2.7.4

  parent reply	other threads:[~2016-09-27 10:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-27 10:12 [Qemu-devel] [PULL V2 00/27] Net patches Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 01/27] virtio-net: allow increasing rx queue size Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 02/27] net: hmp_host_net_remove: Del the -net option of the removed host_net Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 03/27] qemu-char: Add qemu_chr_add_handlers_full() for GMaincontext Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 04/27] colo-compare: introduce colo compare initialization Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 05/27] net/colo.c: add colo.c to define and handle packet Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 06/27] Jhash: add linux kernel jhashtable in qemu Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 07/27] colo-compare: track connection and enqueue packet Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 08/27] colo-compare: introduce packet comparison thread Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 09/27] colo-compare: add TCP, UDP, ICMP packet comparison Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 10/27] filter-rewriter: introduce filter-rewriter initialization Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 11/27] filter-rewriter: track connection and parse packet Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 12/27] filter-rewriter: rewrite tcp packet to keep secondary connection Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 13/27] MAINTAINERS: add maintainer for COLO-proxy Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 14/27] docs: Add documentation " Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 15/27] e1000: fix buliding complaint Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 16/27] tap: Allow specifying a bridge Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 17/27] net: limit allocation in nc_sendv_compat Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 18/27] e1000e: Flush all receive queues on receive enable Jason Wang
2016-09-27 10:12 ` [Qemu-devel] [PULL V2 19/27] e1000e: Flush receive queues on link up Jason Wang
2016-09-27 10:13 ` [Qemu-devel] [PULL V2 20/27] e1000e: Fix CTRL_EXT.EIAME behavior Jason Wang
2016-09-27 10:13 ` [Qemu-devel] [PULL V2 21/27] e1000e: Fix PBACLR implementation Jason Wang
2016-09-27 10:13 ` [Qemu-devel] [PULL V2 22/27] e1000e: Fix OTHER interrupts processing for MSI-X Jason Wang
2016-09-27 10:13 ` [Qemu-devel] [PULL V2 23/27] e1000e: Fix spurious RX TCP ACK interrupts Jason Wang
2016-09-27 10:13 ` [Qemu-devel] [PULL V2 24/27] e1000e: Fix EIAC register implementation Jason Wang
2016-09-27 10:13 ` Jason Wang [this message]
2016-09-27 10:13 ` [Qemu-devel] [PULL V2 26/27] mcf_fec: fix error in qemu_send_packet argument Jason Wang
2016-09-27 10:13 ` [Qemu-devel] [PULL V2 27/27] imx_fec: " Jason Wang
2016-09-27 18:24 ` [Qemu-devel] [PULL V2 00/27] 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=1474971187-15627-26-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).