cryptospore / 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

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