From 89c4300c97739aa3291f0322037bb65068e08d41 Mon Sep 17 00:00:00 2001 From: Jon Maloy Date: Tue, 19 Jan 2021 23:34:33 -0500 Subject: [PATCH] Drop bogus IPv6 messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Jon Maloy Message-id: <20210119233433.1352902-2-jmaloy@redhat.com> Patchwork-id: 100695 O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/1] Drop bogus IPv6 messages Bugzilla: 1918054 RH-Acked-by: Stefano Garzarella RH-Acked-by: Thomas Huth RH-Acked-by: Philippe Mathieu-Daudé From: Ralf Haferkamp 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(). (cherry picked from libslirp commit c7ede54cbd2e2b25385325600958ba0124e31cc0) Signed-off-by: Jon Maloy Signed-off-by: Danilo C. L. de Paula --- slirp/src/ip6_input.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/slirp/src/ip6_input.c b/slirp/src/ip6_input.c index d9d2b7e9cd4..0f2b17853ad 100644 --- a/slirp/src/ip6_input.c +++ b/slirp/src/ip6_input.c @@ -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); -- 2.27.0