yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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