Blame SOURCES/kvm-Using-ip_deq-after-m_free-might-read-pointers-from-a.patch

016a62
From a4c22009a465ebe5fd0c09699e61ad0423b8849d Mon Sep 17 00:00:00 2001
016a62
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
016a62
Date: Fri, 6 Sep 2019 14:00:34 +0100
016a62
Subject: [PATCH 07/22] Using ip_deq after m_free might read pointers from an
016a62
 allocation reuse.
016a62
MIME-Version: 1.0
016a62
Content-Type: text/plain; charset=UTF-8
016a62
Content-Transfer-Encoding: 8bit
016a62
016a62
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
016a62
Message-id: <20190906140034.19722-2-philmd@redhat.com>
016a62
Patchwork-id: 90306
016a62
O-Subject: [RHEL-7.7 qemu-kvm-ma + RHEL-7.7 qemu-kvm-rhev + RHEL-8.1.0 qemu-kvm PATCH 1/1] Using ip_deq after m_free might read pointers from an allocation reuse.
016a62
Bugzilla: 1749724
016a62
RH-Acked-by: Thomas Huth <thuth@redhat.com>
016a62
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
016a62
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
016a62
016a62
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
016a62
016a62
This would be difficult to exploit, but that is still related with
016a62
CVE-2019-14378 which generates fragmented IP packets that would trigger this
016a62
issue and at least produce a DoS.
016a62
016a62
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
016a62
(cherry picked from libslirp commit c59279437eda91841b9d26079c70b8a540d41204)
016a62
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
016a62
016a62
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
016a62
---
016a62
 slirp/ip_input.c | 6 ++++--
016a62
 1 file changed, 4 insertions(+), 2 deletions(-)
016a62
016a62
diff --git a/slirp/ip_input.c b/slirp/ip_input.c
016a62
index 07d8808..7cf0133 100644
016a62
--- a/slirp/ip_input.c
016a62
+++ b/slirp/ip_input.c
016a62
@@ -300,6 +300,7 @@ ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp)
016a62
 	 */
016a62
 	while (q != (struct ipasfrag*)&fp->frag_link &&
016a62
             ip->ip_off + ip->ip_len > q->ipf_off) {
016a62
+		struct ipasfrag *prev;
016a62
 		i = (ip->ip_off + ip->ip_len) - q->ipf_off;
016a62
 		if (i < q->ipf_len) {
016a62
 			q->ipf_len -= i;
016a62
@@ -307,9 +308,10 @@ ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp)
016a62
 			m_adj(dtom(slirp, q), i);
016a62
 			break;
016a62
 		}
016a62
+		prev = q;
016a62
 		q = q->ipf_next;
016a62
-		m_free(dtom(slirp, q->ipf_prev));
016a62
-		ip_deq(q->ipf_prev);
016a62
+		ip_deq(prev);
016a62
+		m_free(dtom(slirp, prev));
016a62
 	}
016a62
 
016a62
 insert:
016a62
-- 
016a62
1.8.3.1
016a62