Drop bogus IPv6 messages
authorRalf Haferkamp <rhafer@suse.com>
Fri, 3 Jul 2020 12:51:16 +0000 (14:51 +0200)
committerwanchao-xu <wanchao.xu@samsung.com>
Tue, 9 Jan 2024 12:00:55 +0000 (20:00 +0800)
Git-commit: c7ede54cbd2e2b25385325600958ba0124e31cc0
References: bsc#1172380 CVE-2020-10756

Drop IPv6 message shorter than what's mentioned in the payload
length header (+ the size of the IPv6 header). They're invalid an could
lead to data leakage in icmp6_send_echoreply().

Signed-off-by: Jose R Ziviani <jose.ziviani@suse.com>
slirp/src/ip6_input.c

index dfcbfd6a78a8f78e45f89427f5a5e87f2d8838a7..d88d1ab92355eda0f83970ba7f3b21d230050b1a 100644 (file)
@@ -49,6 +49,13 @@ void ip6_input(struct mbuf *m)
         goto bad;
     }
 
+    // Check if the message size is big enough to hold what's
+    // set in the payload length header. If not this is an invalid
+    // packet
+    if (m->m_len < ntohs(ip6->ip_pl) + sizeof(struct ip6)) {
+        goto bad;
+    }
+
     /* check ip_ttl for a correct ICMP reply */
     if (ip6->ip_hl == 0) {
         icmp6_send_error(m, ICMP6_TIMXCEED, ICMP6_TIMXCEED_INTRANS);