dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0011-net-mipsnet-check-packet-length-against-buffer.patch

cf91b1
From: Prasad J Pandit <pjp@fedoraproject.org>
cf91b1
Date: Thu, 7 Apr 2016 15:56:02 +0530
cf91b1
Subject: [PATCH] net: mipsnet: check packet length against buffer
cf91b1
cf91b1
When receiving packets over MIPSnet network device, it uses
cf91b1
receive buffer of size 1514 bytes. In case the controller
cf91b1
accepts large(MTU) packets, it could lead to memory corruption.
cf91b1
Add check to avoid it.
cf91b1
cf91b1
Reported by: Oleksandr Bazhaniuk <oleksandr.bazhaniuk@intel.com>
cf91b1
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
cf91b1
Signed-off-by: Jason Wang <jasowang@redhat.com>
cf91b1
cf91b1
(cherry picked from commit 3af9187fc6caaf415ab9c0c6d92c9678f65cb17f)
cf91b1
---
cf91b1
 hw/net/mipsnet.c | 3 +++
cf91b1
 1 file changed, 3 insertions(+)
cf91b1
cf91b1
diff --git a/hw/net/mipsnet.c b/hw/net/mipsnet.c
cf91b1
index 740cd98..cf8b823 100644
cf91b1
--- a/hw/net/mipsnet.c
cf91b1
+++ b/hw/net/mipsnet.c
cf91b1
@@ -83,6 +83,9 @@ static ssize_t mipsnet_receive(NetClientState *nc, const uint8_t *buf, size_t si
cf91b1
     if (!mipsnet_can_receive(nc))
cf91b1
         return 0;
cf91b1
 
cf91b1
+    if (size >= sizeof(s->rx_buffer)) {
cf91b1
+        return 0;
cf91b1
+    }
cf91b1
     s->busy = 1;
cf91b1
 
cf91b1
     /* Just accept everything. */