8fced6
From 89c4300c97739aa3291f0322037bb65068e08d41 Mon Sep 17 00:00:00 2001
8fced6
From: Jon Maloy <jmaloy@redhat.com>
8fced6
Date: Tue, 19 Jan 2021 23:34:33 -0500
8fced6
Subject: [PATCH] Drop bogus IPv6 messages
8fced6
MIME-Version: 1.0
8fced6
Content-Type: text/plain; charset=UTF-8
8fced6
Content-Transfer-Encoding: 8bit
8fced6
8fced6
RH-Author: Jon Maloy <jmaloy@redhat.com>
8fced6
Message-id: <20210119233433.1352902-2-jmaloy@redhat.com>
8fced6
Patchwork-id: 100695
8fced6
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/1] Drop bogus IPv6 messages
8fced6
Bugzilla: 1918054
8fced6
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
8fced6
RH-Acked-by: Thomas Huth <thuth@redhat.com>
8fced6
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8fced6
8fced6
From: Ralf Haferkamp <rhafer@suse.com>
8fced6
8fced6
Drop IPv6 message shorter than what's mentioned in the payload
8fced6
length header (+ the size of the IPv6 header). They're invalid an could
8fced6
lead to data leakage in icmp6_send_echoreply().
8fced6
8fced6
(cherry picked from libslirp commit c7ede54cbd2e2b25385325600958ba0124e31cc0)
8fced6
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
8fced6
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
8fced6
---
8fced6
 slirp/src/ip6_input.c | 7 +++++++
8fced6
 1 file changed, 7 insertions(+)
8fced6
8fced6
diff --git a/slirp/src/ip6_input.c b/slirp/src/ip6_input.c
8fced6
index d9d2b7e9cd4..0f2b17853ad 100644
8fced6
--- a/slirp/src/ip6_input.c
8fced6
+++ b/slirp/src/ip6_input.c
8fced6
@@ -49,6 +49,13 @@ void ip6_input(struct mbuf *m)
8fced6
         goto bad;
8fced6
     }
8fced6
 
8fced6
+    // Check if the message size is big enough to hold what's
8fced6
+    // set in the payload length header. If not this is an invalid
8fced6
+    // packet
8fced6
+    if (m->m_len < ntohs(ip6->ip_pl) + sizeof(struct ip6)) {
8fced6
+        goto bad;
8fced6
+    }
8fced6
+
8fced6
     /* check ip_ttl for a correct ICMP reply */
8fced6
     if (ip6->ip_hl == 0) {
8fced6
         icmp6_send_error(m, ICMP6_TIMXCEED, ICMP6_TIMXCEED_INTRANS);
8fced6
-- 
8fced6
2.27.0
8fced6