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