From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSuLY-0006ke-Kh for qemu-devel@nongnu.org; Fri, 21 Aug 2015 17:59:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZSuLT-00052m-J4 for qemu-devel@nongnu.org; Fri, 21 Aug 2015 17:59:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSuLT-000521-Ek for qemu-devel@nongnu.org; Fri, 21 Aug 2015 17:59:31 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6B45E8A178 for ; Fri, 21 Aug 2015 21:59:30 +0000 (UTC) From: Vladislav Yasevich Date: Fri, 21 Aug 2015 14:59:23 -0700 Message-Id: <1440194365-27610-1-git-send-email-vyasevic@redhat.com> Subject: [Qemu-devel] [PATCH 0/2] rtl8139: Fix buffer overflow in standard mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Vladislav Yasevich , jasowang@redhat.com, stefanha@redhat.com 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