Blame SOURCES/kvm-Fix-use-afte-free-in-ip_reass-CVE-2020-1983.patch

7a3f2e
From 06b7f03c663268ad662892c91925724f5ae9eb9b Mon Sep 17 00:00:00 2001
7a3f2e
From: Jon Maloy <jmaloy@redhat.com>
7a3f2e
Date: Sat, 20 Jun 2020 15:19:21 -0400
7a3f2e
Subject: [PATCH 2/2] Fix use-afte-free in ip_reass() (CVE-2020-1983)
7a3f2e
MIME-Version: 1.0
7a3f2e
Content-Type: text/plain; charset=UTF-8
7a3f2e
Content-Transfer-Encoding: 8bit
7a3f2e
7a3f2e
RH-Author: Jon Maloy <jmaloy@redhat.com>
7a3f2e
Message-id: <20200620151921.3353831-2-jmaloy@redhat.com>
7a3f2e
Patchwork-id: 97682
7a3f2e
O-Subject: [RHEL-7.9 qemu-kvm-ma PATCH 1/1] Fix use-afte-free in ip_reass() (CVE-2020-1983)
7a3f2e
Bugzilla: 1837568
7a3f2e
RH-Acked-by: Thomas Huth <thuth@redhat.com>
7a3f2e
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
7a3f2e
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7a3f2e
7a3f2e
From: Marc-André Lureau <marcandre.lureau@redhat.com>
7a3f2e
7a3f2e
The q pointer is updated when the mbuf data is moved from m_dat to
7a3f2e
m_ext.
7a3f2e
7a3f2e
m_ext buffer may also be realloc()'ed and moved during m_cat():
7a3f2e
q should also be updated in this case.
7a3f2e
7a3f2e
Reported-by: Aviv Sasson <asasson@paloaltonetworks.com>
7a3f2e
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7a3f2e
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
7a3f2e
7a3f2e
(cherry picked from libslirp commit 9bd6c5913271eabcb7768a58197ed3301fe19f2d)
7a3f2e
Conflicts:
7a3f2e
	- Fixed indentation issues
7a3f2e
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
7a3f2e
Signed-off-by: Jon Maloy <jmaloy.redhat.com>
7a3f2e
---
7a3f2e
 slirp/ip_input.c | 9 ++++-----
7a3f2e
 1 file changed, 4 insertions(+), 5 deletions(-)
7a3f2e
7a3f2e
diff --git a/slirp/ip_input.c b/slirp/ip_input.c
7a3f2e
index 7cf01336bf..9d2d79dfff 100644
7a3f2e
--- a/slirp/ip_input.c
7a3f2e
+++ b/slirp/ip_input.c
7a3f2e
@@ -333,10 +333,10 @@ insert:
7a3f2e
 	/*
7a3f2e
 	 * Reassembly is complete; concatenate fragments.
7a3f2e
 	 */
7a3f2e
-    q = fp->frag_link.next;
7a3f2e
+	q = fp->frag_link.next;
7a3f2e
 	m = dtom(slirp, q);
7a3f2e
 
7a3f2e
-	int was_ext = m->m_flags & M_EXT;
7a3f2e
+	int delta = (char *)q - (m->m_flags & M_EXT ? m->m_ext : m->m_dat);
7a3f2e
 
7a3f2e
 	q = (struct ipasfrag *) q->ipf_next;
7a3f2e
 	while (q != (struct ipasfrag*)&fp->frag_link) {
7a3f2e
@@ -360,12 +360,11 @@ insert:
7a3f2e
 	 * the old buffer (in the mbuf), so we must point ip
7a3f2e
 	 * into the new buffer.
7a3f2e
 	 */
7a3f2e
-	if (!was_ext && m->m_flags & M_EXT) {
7a3f2e
-	  int delta = (char *)q - m->m_dat;
7a3f2e
+	if (m->m_flags & M_EXT) {
7a3f2e
 	  q = (struct ipasfrag *)(m->m_ext + delta);
7a3f2e
 	}
7a3f2e
 
7a3f2e
-    ip = fragtoip(q);
7a3f2e
+	ip = fragtoip(q);
7a3f2e
 	ip->ip_len = next;
7a3f2e
 	ip->ip_tos &= ~1;
7a3f2e
 	ip->ip_src = fp->ipq_src;
7a3f2e
-- 
7a3f2e
2.18.2
7a3f2e