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

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