cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
73f313
From dea2f95979cc0ba0c36f07b8e9cc709bd1ef1eb4 Mon Sep 17 00:00:00 2001
73f313
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
73f313
Date: Fri, 17 Jan 2020 12:00:35 +0100
73f313
Subject: [PATCH 1/3] tcp_emu: Fix oob access
73f313
MIME-Version: 1.0
73f313
Content-Type: text/plain; charset=UTF-8
73f313
Content-Transfer-Encoding: 8bit
73f313
73f313
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
73f313
Message-id: <20200117120037.12800-2-philmd@redhat.com>
73f313
Patchwork-id: 93395
73f313
O-Subject: [RHEL-7.7.z qemu-kvm + RHEL-7.8 qemu-kvm + RHEL-7.9 qemu-kvm PATCH v2 1/3] tcp_emu: Fix oob access
73f313
Bugzilla: 1791560
73f313
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
73f313
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
73f313
RH-Acked-by: Thomas Huth <thuth@redhat.com>
73f313
73f313
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
73f313
73f313
The main loop only checks for one available byte, while we sometimes
73f313
need two bytes.
73f313
73f313
(cherry picked from libslirp commit 2655fffed7a9e765bcb4701dd876e9dab975f289)
73f313
[PMD: backported with style conflicts,
73f313
      CHANGELOG.md absent in downstream]
73f313
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
73f313
73f313
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
73f313
---
73f313
 slirp/tcp_subr.c | 7 +++++++
73f313
 1 file changed, 7 insertions(+)
73f313
73f313
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
73f313
index d49a366..70a4c83 100644
73f313
--- a/slirp/tcp_subr.c
73f313
+++ b/slirp/tcp_subr.c
73f313
@@ -837,6 +837,9 @@ tcp_emu(struct socket *so, struct mbuf *m)
73f313
 				break;
73f313
 
73f313
 			 case 5:
73f313
+				if (bptr == m->m_data + m->m_len - 1)
73f313
+					return 1; /* We need two bytes */
73f313
+
73f313
 				/*
73f313
 				 * The difference between versions 1.0 and
73f313
 				 * 2.0 is here. For future versions of
73f313
@@ -852,6 +855,10 @@ tcp_emu(struct socket *so, struct mbuf *m)
73f313
 				/* This is the field containing the port
73f313
 				 * number that RA-player is listening to.
73f313
 				 */
73f313
+
73f313
+				if (bptr == m->m_data + m->m_len - 1)
73f313
+					return 1; /* We need two bytes */
73f313
+
73f313
 				lport = (((u_char*)bptr)[0] << 8)
73f313
 				+ ((u_char *)bptr)[1];
73f313
 				if (lport < 6970)
73f313
-- 
73f313
1.8.3.1
73f313