Received: from eggs.gnu.org ([2001:4830:134:3::10]:53501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoC6m-0001u5-Ns for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:44:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoC6i-00085i-80 for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:44:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59480) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoC6i-000850-3B for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:44:32 -0400 From: Markus Armbruster References: <1460024762-14592-1-git-send-email-ppandit@redhat.com> Date: Thu, 07 Apr 2016 17:44:29 +0200 In-Reply-To: <1460024762-14592-1-git-send-email-ppandit@redhat.com> (P. J. P.'s message of "Thu, 7 Apr 2016 15:56:02 +0530") Message-ID: <87r3ehwhia.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] net: mipsnet: check packet length against buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: P J P Cc: Oleksandr Bazhaniuk , Jason Wang , Qemu Developers , Prasad J Pandit P J P writes: > 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. */ Prompted by Peter Maydell's review of the buddy patch to stellaris_enet: What does the physical device do when it receives such a packet?