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

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