cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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