From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ao78j-0008Qi-TS for qemu-devel@nongnu.org; Thu, 07 Apr 2016 06:26:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ao78e-0007Bv-4y for qemu-devel@nongnu.org; Thu, 07 Apr 2016 06:26:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ao78d-0007Bp-W3 for qemu-devel@nongnu.org; Thu, 07 Apr 2016 06:26:12 -0400 From: P J P Date: Thu, 7 Apr 2016 15:56:02 +0530 Message-Id: <1460024762-14592-1-git-send-email-ppandit@redhat.com> Subject: [Qemu-devel] [PATCH] net: mipsnet: check packet length against buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Qemu Developers Cc: Oleksandr Bazhaniuk , Jason Wang , Prasad J Pandit From: Prasad J Pandit When receiving packets over MIPSnet network device, it uses receive buffer of size 1514 bytes. In case the controller accepts large(MTU) packets, it could lead to memory corruption. Add check to avoid it. Reported by: Oleksandr Bazhaniuk Signed-off-by: Prasad J Pandit --- hw/net/mipsnet.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/net/mipsnet.c b/hw/net/mipsnet.c index f261011..e134b31 100644 --- a/hw/net/mipsnet.c +++ b/hw/net/mipsnet.c @@ -82,6 +82,9 @@ static ssize_t mipsnet_receive(NetClientState *nc, const uint8_t *buf, size_t si if (!mipsnet_can_receive(nc)) return 0; + if (size >= sizeof(s->rx_buffer)) { + return 0; + } s->busy = 1; /* Just accept everything. */ -- 2.5.5