Blame SOURCES/kvm-rtl8139-check-IP-Header-Length-field-CVE-2015-5165.patch

b2d9fb
From 230b373704579a17a7a7e6890fe0dc1b789a2fa4 Mon Sep 17 00:00:00 2001
b2d9fb
From: Stefan Hajnoczi <stefanha@redhat.com>
b2d9fb
Date: Fri, 31 Jul 2015 15:59:45 +0200
b2d9fb
Subject: [PATCH 4/7] rtl8139: check IP Header Length field (CVE-2015-5165)
b2d9fb
b2d9fb
Message-id: <1438358388-10575-5-git-send-email-stefanha@redhat.com>
b2d9fb
Patchwork-id: 67239
b2d9fb
O-Subject: [RHEL-7.1.z qemu-kvm EMBARGOED PATCH 4/7] rtl8139: check IP Header Length field (CVE-2015-5165)
b2d9fb
Bugzilla: 1248764
b2d9fb
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
b2d9fb
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
b2d9fb
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
b2d9fb
b2d9fb
The IP Header Length field was only checked in the IP checksum case, but
b2d9fb
is used in other cases too.
b2d9fb
b2d9fb
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
b2d9fb
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
b2d9fb
---
b2d9fb
 hw/net/rtl8139.c | 19 ++++++++-----------
b2d9fb
 1 file changed, 8 insertions(+), 11 deletions(-)
b2d9fb
b2d9fb
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
b2d9fb
index 409029d..7efc0b5 100644
b2d9fb
--- a/hw/net/rtl8139.c
b2d9fb
+++ b/hw/net/rtl8139.c
b2d9fb
@@ -2178,6 +2178,10 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
b2d9fb
             }
b2d9fb
 
b2d9fb
             hlen = IP_HEADER_LENGTH(ip);
b2d9fb
+            if (hlen < sizeof(ip_header) || hlen > eth_payload_len) {
b2d9fb
+                goto skip_offload;
b2d9fb
+            }
b2d9fb
+
b2d9fb
             ip_protocol = ip->ip_p;
b2d9fb
             ip_data_len = be16_to_cpu(ip->ip_len) - hlen;
b2d9fb
 
b2d9fb
@@ -2185,17 +2189,10 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
b2d9fb
             {
b2d9fb
                 DPRINTF("+++ C+ mode need IP checksum\n");
b2d9fb
 
b2d9fb
-                if (hlen<sizeof(ip_header) || hlen>eth_payload_len) {/* min header length */
b2d9fb
-                    /* bad packet header len */
b2d9fb
-                    /* or packet too short */
b2d9fb
-                }
b2d9fb
-                else
b2d9fb
-                {
b2d9fb
-                    ip->ip_sum = 0;
b2d9fb
-                    ip->ip_sum = ip_checksum(ip, hlen);
b2d9fb
-                    DPRINTF("+++ C+ mode IP header len=%d checksum=%04x\n",
b2d9fb
-                        hlen, ip->ip_sum);
b2d9fb
-                }
b2d9fb
+                ip->ip_sum = 0;
b2d9fb
+                ip->ip_sum = ip_checksum(ip, hlen);
b2d9fb
+                DPRINTF("+++ C+ mode IP header len=%d checksum=%04x\n",
b2d9fb
+                    hlen, ip->ip_sum);
b2d9fb
             }
b2d9fb
 
b2d9fb
             if ((txdw0 & CP_TX_LGSEN) && ip_protocol == IP_PROTO_TCP)
b2d9fb
-- 
b2d9fb
1.8.3.1
b2d9fb