thebeanogamer / rpms / qemu-kvm

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