]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
net: mipsnet: check packet length against buffer
authorPrasad J Pandit <pjp@fedoraproject.org>
Thu, 7 Apr 2016 10:26:02 +0000 (15:56 +0530)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 9 Aug 2016 19:28:45 +0000 (14:28 -0500)
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 <oleksandr.bazhaniuk@intel.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit 3af9187fc6caaf415ab9c0c6d92c9678f65cb17f)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/net/mipsnet.c

index 740cd98ff1fdc357e4565aa5bd5321a695ebe0d0..cf8b8236df8045023ed1d475b5ea05c2c22508e6 100644 (file)
@@ -83,6 +83,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. */