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

22c213
From 0f659af4870f151e25a7d2184b9a383bff58e3ba 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:57 +0100
22c213
Subject: [PATCH 2/4] slirp: use correct size while emulating IRC commands
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-3-marcandre.lureau@redhat.com>
22c213
Patchwork-id: 93400
22c213
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
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: Prasad J Pandit <pjp@fedoraproject.org>
22c213
22c213
While emulating IRC DCC commands, tcp_emu() uses 'mbuf' size
22c213
'm->m_size' to write DCC commands via snprintf(3). This may
22c213
lead to OOB write access, because 'bptr' points somewhere in
22c213
the middle of 'mbuf' buffer, not at the start. Use M_FREEROOM(m)
22c213
size to avoid OOB access.
22c213
22c213
Reported-by: Vishnu Dev TJ <vishnudevtj@gmail.com>
22c213
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
22c213
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
22c213
Message-Id: <20200109094228.79764-2-ppandit@redhat.com>
22c213
22c213
(cherry picked from libslirp commit ce131029d6d4a405cb7d3ac6716d03e58fb4a5d9)
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 | 11 ++++++-----
22c213
 1 file changed, 6 insertions(+), 5 deletions(-)
22c213
22c213
diff --git a/slirp/src/tcp_subr.c b/slirp/src/tcp_subr.c
22c213
index cbecd64..cedbfb2 100644
22c213
--- a/slirp/src/tcp_subr.c
22c213
+++ b/slirp/src/tcp_subr.c
22c213
@@ -778,7 +778,8 @@ int tcp_emu(struct socket *so, struct mbuf *m)
22c213
                 return 1;
22c213
             }
22c213
             m->m_len = bptr - m->m_data; /* Adjust length */
22c213
-            m->m_len += snprintf(bptr, m->m_size, "DCC CHAT chat %lu %u%c\n",
22c213
+            m->m_len += snprintf(bptr, M_FREEROOM(m),
22c213
+                                 "DCC CHAT chat %lu %u%c\n",
22c213
                                  (unsigned long)ntohl(so->so_faddr.s_addr),
22c213
                                  ntohs(so->so_fport), 1);
22c213
         } else if (sscanf(bptr, "DCC SEND %256s %u %u %u", buff, &laddr, &lport,
22c213
@@ -788,8 +789,8 @@ int tcp_emu(struct socket *so, struct mbuf *m)
22c213
                 return 1;
22c213
             }
22c213
             m->m_len = bptr - m->m_data; /* Adjust length */
22c213
-            m->m_len +=
22c213
-                snprintf(bptr, m->m_size, "DCC SEND %s %lu %u %u%c\n", buff,
22c213
+            m->m_len += snprintf(bptr, M_FREEROOM(m),
22c213
+                         "DCC SEND %s %lu %u %u%c\n", buff,
22c213
                          (unsigned long)ntohl(so->so_faddr.s_addr),
22c213
                          ntohs(so->so_fport), n1, 1);
22c213
         } else if (sscanf(bptr, "DCC MOVE %256s %u %u %u", buff, &laddr, &lport,
22c213
@@ -799,8 +800,8 @@ int tcp_emu(struct socket *so, struct mbuf *m)
22c213
                 return 1;
22c213
             }
22c213
             m->m_len = bptr - m->m_data; /* Adjust length */
22c213
-            m->m_len +=
22c213
-                snprintf(bptr, m->m_size, "DCC MOVE %s %lu %u %u%c\n", buff,
22c213
+            m->m_len += snprintf(bptr, M_FREEROOM(m),
22c213
+                         "DCC MOVE %s %lu %u %u%c\n", buff,
22c213
                          (unsigned long)ntohl(so->so_faddr.s_addr),
22c213
                          ntohs(so->so_fport), n1, 1);
22c213
         }
22c213
-- 
22c213
1.8.3.1
22c213