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