22c213
From 5c2c5496083fa549e1dff903413bb6136fc19d8d Mon Sep 17 00:00:00 2001
22c213
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
22c213
Date: Fri, 17 Jan 2020 12:07:56 +0100
22c213
Subject: [PATCH 1/4] tcp_emu: Fix oob access
22c213
MIME-Version: 1.0
22c213
Content-Type: text/plain; charset=UTF-8
22c213
Content-Transfer-Encoding: 8bit
22c213
22c213
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
22c213
Message-id: <20200117120758.1076549-2-marcandre.lureau@redhat.com>
22c213
Patchwork-id: 93399
22c213
O-Subject: [RHEL-AV-8.1.0 qemu-kvm + RHEL-AV-8.2.0 qemu-kvm PATCH 1/3] tcp_emu: Fix oob access
22c213
Bugzilla: 1791568
22c213
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22c213
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
22c213
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
22c213
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
22c213
22c213
The main loop only checks for one available byte, while we sometimes
22c213
need two bytes.
22c213
22c213
[ MA - minor conflict, CHANGELOG.md absent ]
22c213
(cherry picked from libslirp commit 2655fffed7a9e765bcb4701dd876e9dab975f289)
22c213
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
22c213
22c213
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
22c213
---
22c213
 slirp/src/tcp_subr.c | 7 +++++++
22c213
 1 file changed, 7 insertions(+)
22c213
22c213
diff --git a/slirp/src/tcp_subr.c b/slirp/src/tcp_subr.c
22c213
index d6dd133..cbecd64 100644
22c213
--- a/slirp/src/tcp_subr.c
22c213
+++ b/slirp/src/tcp_subr.c
22c213
@@ -886,6 +886,9 @@ int tcp_emu(struct socket *so, struct mbuf *m)
22c213
                 break;
22c213
 
22c213
             case 5:
22c213
+                if (bptr == m->m_data + m->m_len - 1)
22c213
+                        return 1; /* We need two bytes */
22c213
+
22c213
                 /*
22c213
                  * The difference between versions 1.0 and
22c213
                  * 2.0 is here. For future versions of
22c213
@@ -901,6 +904,10 @@ int tcp_emu(struct socket *so, struct mbuf *m)
22c213
                 /* This is the field containing the port
22c213
                  * number that RA-player is listening to.
22c213
                  */
22c213
+
22c213
+                if (bptr == m->m_data + m->m_len - 1)
22c213
+                        return 1; /* We need two bytes */
22c213
+
22c213
                 lport = (((uint8_t *)bptr)[0] << 8) + ((uint8_t *)bptr)[1];
22c213
                 if (lport < 6970)
22c213
                     lport += 256; /* don't know why */
22c213
-- 
22c213
1.8.3.1
22c213