yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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