* [Qemu-devel] [PATCH v2] net: mcf: limit buffer descriptor count
@ 2016-09-22 10:32 P J P
2016-09-22 10:33 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: P J P @ 2016-09-22 10:32 UTC (permalink / raw)
To: Qemu Developers; +Cc: Paolo Bonzini, Jason Wang, Li Qiang, Prasad J Pandit
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>
---
hw/net/mcf_fec.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Update per
-> https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg05284.html
diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
index 7c0398e..6d3418e 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.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] net: mcf: limit buffer descriptor count
2016-09-22 10:32 [Qemu-devel] [PATCH v2] net: mcf: limit buffer descriptor count P J P
@ 2016-09-22 10:33 ` Paolo Bonzini
2016-09-23 5:23 ` Jason Wang
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2016-09-22 10:33 UTC (permalink / raw)
To: P J P, Qemu Developers; +Cc: Jason Wang, Li Qiang, Prasad J Pandit
On 22/09/2016 12:32, P J P wrote:
> 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>
> ---
> hw/net/mcf_fec.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> Update per
> -> https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg05284.html
>
> diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
> index 7c0398e..6d3418e 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);
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] net: mcf: limit buffer descriptor count
2016-09-22 10:33 ` Paolo Bonzini
@ 2016-09-23 5:23 ` Jason Wang
0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2016-09-23 5:23 UTC (permalink / raw)
To: Paolo Bonzini, P J P, Qemu Developers; +Cc: Li Qiang, Prasad J Pandit
On 2016年09月22日 18:33, Paolo Bonzini wrote:
>
> On 22/09/2016 12:32, P J P wrote:
>> 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>
>> ---
>> hw/net/mcf_fec.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> Update per
>> -> https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg05284.html
>>
>> diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
>> index 7c0398e..6d3418e 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);
>>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-23 5:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22 10:32 [Qemu-devel] [PATCH v2] net: mcf: limit buffer descriptor count P J P
2016-09-22 10:33 ` Paolo Bonzini
2016-09-23 5:23 ` Jason Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.