yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-slirp-check-data-length-while-emulating-ident-functi.patch

26ba25
From c894cd80e9b6c7c317da2dbeacf52a34dc5efdbb Mon Sep 17 00:00:00 2001
26ba25
From: Xiao Wang <jasowang@redhat.com>
26ba25
Date: Fri, 22 Feb 2019 08:32:02 +0000
26ba25
Subject: [PATCH] slirp: check data length while emulating ident function
26ba25
MIME-Version: 1.0
26ba25
Content-Type: text/plain; charset=UTF-8
26ba25
Content-Transfer-Encoding: 8bit
26ba25
26ba25
RH-Author: Xiao Wang <jasowang@redhat.com>
26ba25
Message-id: <20190222083202.20283-1-jasowang@redhat.com>
26ba25
Patchwork-id: 84699
26ba25
O-Subject: [RHEL8/rhel qemu-kvm PATCH] slirp: check data length while emulating ident function
26ba25
Bugzilla: 1669069
26ba25
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
26ba25
RH-Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
26ba25
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
26ba25
26ba25
From: Prasad J Pandit <pjp@fedoraproject.org>
26ba25
26ba25
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1669069
26ba25
Brew Build: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=20325086
26ba25
Test status: Tested by myself
26ba25
Branch: rhel8/master-2.12.0
26ba25
26ba25
While emulating identification protocol, tcp_emu() does not check
26ba25
available space in the 'sc_rcv->sb_data' buffer. It could lead to
26ba25
heap buffer overflow issue. Add check to avoid it.
26ba25
26ba25
Reported-by: Kira <864786842@qq.com>
26ba25
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
26ba25
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
26ba25
(cherry picked from commit a7104eda7dab99d0cdbd3595c211864cba415905)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 slirp/tcp_subr.c | 5 +++++
26ba25
 1 file changed, 5 insertions(+)
26ba25
26ba25
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
26ba25
index da0d537..1c7eb28 100644
26ba25
--- a/slirp/tcp_subr.c
26ba25
+++ b/slirp/tcp_subr.c
26ba25
@@ -638,6 +638,11 @@ tcp_emu(struct socket *so, struct mbuf *m)
26ba25
 			socklen_t addrlen = sizeof(struct sockaddr_in);
26ba25
 			struct sbuf *so_rcv = &so->so_rcv;
26ba25
 
26ba25
+			if (m->m_len > so_rcv->sb_datalen
26ba25
+					- (so_rcv->sb_wptr - so_rcv->sb_data)) {
26ba25
+			    return 1;
26ba25
+			}
26ba25
+
26ba25
 			memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
26ba25
 			so_rcv->sb_wptr += m->m_len;
26ba25
 			so_rcv->sb_rptr += m->m_len;
26ba25
-- 
26ba25
1.8.3.1
26ba25