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