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

9ae3a8
From 7980bf40d749aeb86a972a73db67a42fe000dbca Mon Sep 17 00:00:00 2001
9ae3a8
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
9ae3a8
Date: Wed, 31 Jul 2019 21:39:33 +0200
9ae3a8
Subject: [PATCH 4/4] Fix heap overflow in ip_reass on big packet input
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
9ae3a8
Message-id: <20190731213933.16245-2-philmd@redhat.com>
9ae3a8
Patchwork-id: 89844
9ae3a8
O-Subject: [RHEL-7.7 qemu-kvm PATCH 1/1] Fix heap overflow in ip_reass on big packet input
9ae3a8
Bugzilla: 1734749
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9ae3a8
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9ae3a8
9ae3a8
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
9ae3a8
9ae3a8
When the first fragment does not fit in the preallocated buffer, q will
9ae3a8
already be pointing to the ext buffer, so we mustn't try to update it.
9ae3a8
9ae3a8
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9ae3a8
(cherry picked from libslirp commit 126c04acbabd7ad32c2b018fe10dfac2a3bc1210)
9ae3a8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 slirp/ip_input.c | 4 +++-
9ae3a8
 1 file changed, 3 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
diff --git a/slirp/ip_input.c b/slirp/ip_input.c
9ae3a8
index 880bdfd..5226224 100644
9ae3a8
--- a/slirp/ip_input.c
9ae3a8
+++ b/slirp/ip_input.c
9ae3a8
@@ -330,6 +330,8 @@ insert:
9ae3a8
     q = fp->frag_link.next;
9ae3a8
 	m = dtom(slirp, q);
9ae3a8
 
9ae3a8
+	int was_ext = m->m_flags & M_EXT;
9ae3a8
+
9ae3a8
 	q = (struct ipasfrag *) q->ipf_next;
9ae3a8
 	while (q != (struct ipasfrag*)&fp->frag_link) {
9ae3a8
 	  struct mbuf *t = dtom(slirp, q);
9ae3a8
@@ -352,7 +354,7 @@ insert:
9ae3a8
 	 * the old buffer (in the mbuf), so we must point ip
9ae3a8
 	 * into the new buffer.
9ae3a8
 	 */
9ae3a8
-	if (m->m_flags & M_EXT) {
9ae3a8
+	if (!was_ext && m->m_flags & M_EXT) {
9ae3a8
 	  int delta = (char *)q - m->m_dat;
9ae3a8
 	  q = (struct ipasfrag *)(m->m_ext + delta);
9ae3a8
 	}
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8