Blame SOURCES/kvm-Fix-heap-overflow-in-ip_reass-on-big-packet-input.patch

b38b0f
From 486e74dd9b8515f478698fee494086b339015d51 Mon Sep 17 00:00:00 2001
69f3e1
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
69f3e1
Date: Wed, 31 Jul 2019 18:45:29 +0100
b38b0f
Subject: [PATCH 14/14] Fix heap overflow in ip_reass on big packet input
69f3e1
MIME-Version: 1.0
69f3e1
Content-Type: text/plain; charset=UTF-8
69f3e1
Content-Transfer-Encoding: 8bit
69f3e1
69f3e1
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
69f3e1
Message-id: <20190731184529.21905-2-philmd@redhat.com>
69f3e1
Patchwork-id: 89820
69f3e1
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/1] Fix heap overflow in ip_reass on big packet input
b38b0f
Bugzilla: 1734751
69f3e1
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
69f3e1
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
69f3e1
RH-Acked-by: Thomas Huth <thuth@redhat.com>
69f3e1
69f3e1
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
69f3e1
69f3e1
When the first fragment does not fit in the preallocated buffer, q will
69f3e1
already be pointing to the ext buffer, so we mustn't try to update it.
69f3e1
69f3e1
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
69f3e1
(cherry picked from libslirp commit 126c04acbabd7ad32c2b018fe10dfac2a3bc1210)
69f3e1
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
69f3e1
69f3e1
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
69f3e1
---
69f3e1
 slirp/ip_input.c | 4 +++-
69f3e1
 1 file changed, 3 insertions(+), 1 deletion(-)
69f3e1
69f3e1
diff --git a/slirp/ip_input.c b/slirp/ip_input.c
69f3e1
index 348e1dc..07d8808 100644
69f3e1
--- a/slirp/ip_input.c
69f3e1
+++ b/slirp/ip_input.c
69f3e1
@@ -334,6 +334,8 @@ insert:
69f3e1
     q = fp->frag_link.next;
69f3e1
 	m = dtom(slirp, q);
69f3e1
 
69f3e1
+	int was_ext = m->m_flags & M_EXT;
69f3e1
+
69f3e1
 	q = (struct ipasfrag *) q->ipf_next;
69f3e1
 	while (q != (struct ipasfrag*)&fp->frag_link) {
69f3e1
 	  struct mbuf *t = dtom(slirp, q);
69f3e1
@@ -356,7 +358,7 @@ insert:
69f3e1
 	 * the old buffer (in the mbuf), so we must point ip
69f3e1
 	 * into the new buffer.
69f3e1
 	 */
69f3e1
-	if (m->m_flags & M_EXT) {
69f3e1
+	if (!was_ext && m->m_flags & M_EXT) {
69f3e1
 	  int delta = (char *)q - m->m_dat;
69f3e1
 	  q = (struct ipasfrag *)(m->m_ext + delta);
69f3e1
 	}
69f3e1
-- 
69f3e1
1.8.3.1
69f3e1