26ba25
From 725b20685e3faf11198560a6d9035c394ef77594 Mon Sep 17 00:00:00 2001
26ba25
From: Xiao Wang <jasowang@redhat.com>
26ba25
Date: Fri, 11 Jan 2019 07:58:59 +0000
26ba25
Subject: [PATCH 04/11] net: ignore packet size greater than INT_MAX
26ba25
MIME-Version: 1.0
26ba25
Content-Type: text/plain; charset=UTF-8
26ba25
Content-Transfer-Encoding: 8bit
26ba25
26ba25
RH-Author: Xiao Wang <jasowang@redhat.com>
26ba25
Message-id: <20190111075904.2030-5-jasowang@redhat.com>
26ba25
Patchwork-id: 83978
26ba25
O-Subject: [RHEL8 qemu-kvm PATCH 4/9] net: ignore packet size greater than INT_MAX
26ba25
Bugzilla: 1636784
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
26ba25
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
26ba25
RH-Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
26ba25
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
26ba25
26ba25
There should not be a reason for passing a packet size greater than
26ba25
INT_MAX. It's usually a hint of bug somewhere, so ignore packet size
26ba25
greater than INT_MAX in qemu_deliver_packet_iov()
26ba25
26ba25
CC: qemu-stable@nongnu.org
26ba25
Reported-by: Daniel Shapira <daniel@twistlock.com>
26ba25
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
26ba25
Signed-off-by: Jason Wang <jasowang@redhat.com>
26ba25
(cherry picked from commit 1592a9947036d60dde5404204a5d45975133caf5)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 net/net.c | 7 ++++++-
26ba25
 1 file changed, 6 insertions(+), 1 deletion(-)
26ba25
26ba25
diff --git a/net/net.c b/net/net.c
26ba25
index 29f8398..c991243 100644
26ba25
--- a/net/net.c
26ba25
+++ b/net/net.c
26ba25
@@ -712,10 +712,15 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,
26ba25
                                 void *opaque)
26ba25
 {
26ba25
     NetClientState *nc = opaque;
26ba25
+    size_t size = iov_size(iov, iovcnt);
26ba25
     int ret;
26ba25
 
26ba25
+    if (size > INT_MAX) {
26ba25
+        return size;
26ba25
+    }
26ba25
+
26ba25
     if (nc->link_down) {
26ba25
-        return iov_size(iov, iovcnt);
26ba25
+        return size;
26ba25
     }
26ba25
 
26ba25
     if (nc->receive_disabled) {
26ba25
-- 
26ba25
1.8.3.1
26ba25