qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] rtl8139: Fix buffer overflow in standard mode
@ 2015-08-26 19:51 Vladislav Yasevich
  2015-08-26 19:51 ` [Qemu-devel] [PATCH 1/2] rtl8139: Do not consume the packet during " Vladislav Yasevich
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Vladislav Yasevich @ 2015-08-26 19:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Vladislav Yasevich, jasowang, stefanha

When rtl8139 card is running in standard mode, it is very easy
to overlflow and the receive buffer and get into a siutation
where all packets are dropped.  Simply reproduction case is
to ping the guest from the host with 6500 byte packets.  

There are actually 2 problems here.
 1) When the rtl8129 buffer is overflow, the card emulation
    returns the size of the packet back to queue transmission.
    This signals successful reception even though the packet
    has been dropped.  The proper solution is to return 0, so
    that the packet is re-queued and will be resubmitted later.

 2) When packets are sized such that the fragments end up completely
    filling the receive buffer without overflow, the device thinks
    that the buffer is actually empty (instead of full).  This causes
    next packet to over-write the existing packets.  With the above
    ping reproducer, ever ICMP packet fills the buffer and thus keeps
    overwriting the previous packet and never waking up the guest.
    The solution here is track the number of unread bytes separately
    so we would know if we have anything in buffer to read or not.

V2: instead of tracking buffer_full condition, changed the code, as
    suggested by Stefan Hajnoczi, to track the number of unread bytes
    instead.  We initialize it to 0 at the start, adjust it on every
    receive from the network and read from the guest and can set
    the number of unread of bytes to full buffer size when the buffer
    full.

Vladislav Yasevich (2):
  rtl8139: Do not consume the packet during overflow in standard mode.
  rtl8139: correctly track full receive buffer in standard mode

 hw/net/rtl8139.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 5 deletions(-)

-- 
1.9.3

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 0/2] rtl8139: Fix buffer overflow in standard mode
@ 2015-08-21 21:59 Vladislav Yasevich
  2015-08-21 21:59 ` [Qemu-devel] [PATCH 2/2] rtl8139: correctly track full receive buffer " Vladislav Yasevich
  0 siblings, 1 reply; 7+ messages in thread
From: Vladislav Yasevich @ 2015-08-21 21:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Vladislav Yasevich, jasowang, stefanha

When rtl8139 card is running in standard mode, it is very easy
to overlflow and the receive buffer and get into a siutation
where all packets are dropped.  Simply reproduction case is
to ping the guest from the host with 6500 byte packets.  

There are actually 2 problems here.
 1) When the rtl8129 buffer is overflow, the card emulation
    returns the size of the packet back to queue transmission.
    This signals successful reception even though the packet
    has been dropped.  The proper solution is to return 0, so
    that the packet is re-queued and will be resubmitted later.

 2) When packets are sized such that the fragments end up completely
    filling the receive buffer without overflow, the device thinks
    that the buffer is actually empty (instead of full).  This causes
    next packet to over-write the existing packets.  With the above
    ping reproducer, ever ICMP packet fills the buffer and thus keeps
    overwriting the previous packet and never waking up the guest.
    The solution here is to trap the buffer full condition and let
    the guest read the data before writing more data to the rxBuffer.


Vladislav Yasevich (2):
  rtl8139: Do not consume the packet during overflow in standard mode.
  rtl8139: correctly track full receive buffer in standard mode

 hw/net/rtl8139.c | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

-- 
1.9.3

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-08-27  1:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-26 19:51 [Qemu-devel] [PATCH v2 0/2] rtl8139: Fix buffer overflow in standard mode Vladislav Yasevich
2015-08-26 19:51 ` [Qemu-devel] [PATCH 1/2] rtl8139: Do not consume the packet during " Vladislav Yasevich
2015-08-26 19:51 ` [Qemu-devel] [PATCH 2/2] rtl8139: correctly track full receive buffer " Vladislav Yasevich
2015-08-27  1:19 ` [Qemu-devel] [PATCH v2 0/2] rtl8139: Fix buffer overflow " Vlad Yasevich
  -- strict thread matches above, loose matches on Subject: below --
2015-08-21 21:59 [Qemu-devel] [PATCH " Vladislav Yasevich
2015-08-21 21:59 ` [Qemu-devel] [PATCH 2/2] rtl8139: correctly track full receive buffer " Vladislav Yasevich
2015-08-26 12:36   ` Stefan Hajnoczi
2015-08-26 13:07     ` Vlad Yasevich

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).