Blame SOURCES/kvm-slirp-use-correct-size-while-emulating-IRC-commands.patch

902636
From 0f659af4870f151e25a7d2184b9a383bff58e3ba Mon Sep 17 00:00:00 2001
902636
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
902636
Date: Fri, 17 Jan 2020 12:07:57 +0100
902636
Subject: [PATCH 2/4] slirp: use correct size while emulating IRC commands
d8ab4a
MIME-Version: 1.0
d8ab4a
Content-Type: text/plain; charset=UTF-8
d8ab4a
Content-Transfer-Encoding: 8bit
d8ab4a
902636
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
902636
Message-id: <20200117120758.1076549-3-marcandre.lureau@redhat.com>
902636
Patchwork-id: 93400
902636
O-Subject: [RHEL-AV-8.1.0 qemu-kvm + RHEL-AV-8.2.0 qemu-kvm PATCH 2/3] slirp: use correct size while emulating IRC commands
902636
Bugzilla: 1791568
902636
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
d8ab4a
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
016a62
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
d8ab4a
d8ab4a
From: Prasad J Pandit <pjp@fedoraproject.org>
d8ab4a
d8ab4a
While emulating IRC DCC commands, tcp_emu() uses 'mbuf' size
d8ab4a
'm->m_size' to write DCC commands via snprintf(3). This may
d8ab4a
lead to OOB write access, because 'bptr' points somewhere in
d8ab4a
the middle of 'mbuf' buffer, not at the start. Use M_FREEROOM(m)
d8ab4a
size to avoid OOB access.
d8ab4a
d8ab4a
Reported-by: Vishnu Dev TJ <vishnudevtj@gmail.com>
d8ab4a
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
d8ab4a
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
d8ab4a
Message-Id: <20200109094228.79764-2-ppandit@redhat.com>
902636
d8ab4a
(cherry picked from libslirp commit ce131029d6d4a405cb7d3ac6716d03e58fb4a5d9)
902636
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
d8ab4a
016a62
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
d8ab4a
---
902636
 slirp/src/tcp_subr.c | 11 ++++++-----
902636
 1 file changed, 6 insertions(+), 5 deletions(-)
d8ab4a
902636
diff --git a/slirp/src/tcp_subr.c b/slirp/src/tcp_subr.c
902636
index cbecd64..cedbfb2 100644
902636
--- a/slirp/src/tcp_subr.c
902636
+++ b/slirp/src/tcp_subr.c
902636
@@ -778,7 +778,8 @@ int tcp_emu(struct socket *so, struct mbuf *m)
902636
                 return 1;
902636
             }
902636
             m->m_len = bptr - m->m_data; /* Adjust length */
902636
-            m->m_len += snprintf(bptr, m->m_size, "DCC CHAT chat %lu %u%c\n",
902636
+            m->m_len += snprintf(bptr, M_FREEROOM(m),
902636
+                                 "DCC CHAT chat %lu %u%c\n",
902636
                                  (unsigned long)ntohl(so->so_faddr.s_addr),
902636
                                  ntohs(so->so_fport), 1);
902636
         } else if (sscanf(bptr, "DCC SEND %256s %u %u %u", buff, &laddr, &lport,
902636
@@ -788,8 +789,8 @@ int tcp_emu(struct socket *so, struct mbuf *m)
902636
                 return 1;
902636
             }
902636
             m->m_len = bptr - m->m_data; /* Adjust length */
902636
-            m->m_len +=
902636
-                snprintf(bptr, m->m_size, "DCC SEND %s %lu %u %u%c\n", buff,
902636
+            m->m_len += snprintf(bptr, M_FREEROOM(m),
902636
+                         "DCC SEND %s %lu %u %u%c\n", buff,
902636
                          (unsigned long)ntohl(so->so_faddr.s_addr),
902636
                          ntohs(so->so_fport), n1, 1);
902636
         } else if (sscanf(bptr, "DCC MOVE %256s %u %u %u", buff, &laddr, &lport,
902636
@@ -799,8 +800,8 @@ int tcp_emu(struct socket *so, struct mbuf *m)
902636
                 return 1;
902636
             }
902636
             m->m_len = bptr - m->m_data; /* Adjust length */
902636
-            m->m_len +=
902636
-                snprintf(bptr, m->m_size, "DCC MOVE %s %lu %u %u%c\n", buff,
902636
+            m->m_len += snprintf(bptr, M_FREEROOM(m),
902636
+                         "DCC MOVE %s %lu %u %u%c\n", buff,
902636
                          (unsigned long)ntohl(so->so_faddr.s_addr),
902636
                          ntohs(so->so_fport), n1, 1);
902636
         }
d8ab4a
-- 
d8ab4a
1.8.3.1
d8ab4a