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

ddf19c
From a33ea192428d9c9307f1140f3e25631a6ef7657c Mon Sep 17 00:00:00 2001
ddf19c
From: Jon Maloy <jmaloy@redhat.com>
ddf19c
Date: Sat, 20 Jun 2020 15:02:59 -0400
ddf19c
Subject: [PATCH 12/12] Fix use-afte-free in ip_reass() (CVE-2020-1983)
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Jon Maloy <jmaloy@redhat.com>
ddf19c
Message-id: <20200620150259.3352467-2-jmaloy@redhat.com>
ddf19c
Patchwork-id: 97678
ddf19c
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 1/1] Fix use-afte-free in ip_reass() (CVE-2020-1983)
ddf19c
Bugzilla: 1838070
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
ddf19c
From: Marc-André Lureau <marcandre.lureau@redhat.com>
ddf19c
ddf19c
The q pointer is updated when the mbuf data is moved from m_dat to
ddf19c
m_ext.
ddf19c
ddf19c
m_ext buffer may also be realloc()'ed and moved during m_cat():
ddf19c
q should also be updated in this case.
ddf19c
ddf19c
Reported-by: Aviv Sasson <asasson@paloaltonetworks.com>
ddf19c
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
ddf19c
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
ddf19c
ddf19c
(cherry picked from libslirp commit 9bd6c5913271eabcb7768a58197ed3301fe19f2d)
ddf19c
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 slirp/src/ip_input.c | 5 ++---
ddf19c
 1 file changed, 2 insertions(+), 3 deletions(-)
ddf19c
ddf19c
diff --git a/slirp/src/ip_input.c b/slirp/src/ip_input.c
ddf19c
index df1c846ade..0f5d522ec1 100644
ddf19c
--- a/slirp/src/ip_input.c
ddf19c
+++ b/slirp/src/ip_input.c
ddf19c
@@ -329,7 +329,7 @@ insert:
ddf19c
     q = fp->frag_link.next;
ddf19c
     m = dtom(slirp, q);
ddf19c
 
ddf19c
-    int was_ext = m->m_flags & M_EXT;
ddf19c
+    int delta = (char *)q - (m->m_flags & M_EXT ? m->m_ext : m->m_dat);
ddf19c
 
ddf19c
     q = (struct ipasfrag *)q->ipf_next;
ddf19c
     while (q != (struct ipasfrag *)&fp->frag_link) {
ddf19c
@@ -353,8 +353,7 @@ insert:
ddf19c
      * the old buffer (in the mbuf), so we must point ip
ddf19c
      * into the new buffer.
ddf19c
      */
ddf19c
-    if (!was_ext && m->m_flags & M_EXT) {
ddf19c
-        int delta = (char *)q - m->m_dat;
ddf19c
+    if (m->m_flags & M_EXT) {
ddf19c
         q = (struct ipasfrag *)(m->m_ext + delta);
ddf19c
     }
ddf19c
 
ddf19c
-- 
ddf19c
2.27.0
ddf19c