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

8b1478
From 2cca40617df140d2907a47fb58d15487cbf2af59 Mon Sep 17 00:00:00 2001
8b1478
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
8b1478
Date: Fri, 17 Jan 2020 11:49:41 +0100
8b1478
Subject: [PATCH 2/3] slirp: use correct size while emulating IRC commands
8b1478
MIME-Version: 1.0
8b1478
Content-Type: text/plain; charset=UTF-8
8b1478
Content-Transfer-Encoding: 8bit
8b1478
8b1478
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
8b1478
Message-id: <20200117114942.12236-3-philmd@redhat.com>
8b1478
Patchwork-id: 93392
8b1478
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 2/3] slirp: use correct size while emulating IRC commands
8b1478
Bugzilla: 1791563 1791570
8b1478
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
8b1478
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
8b1478
RH-Acked-by: Thomas Huth <thuth@redhat.com>
8b1478
8b1478
From: Prasad J Pandit <pjp@fedoraproject.org>
8b1478
8b1478
While emulating IRC DCC commands, tcp_emu() uses 'mbuf' size
8b1478
'm->m_size' to write DCC commands via snprintf(3). This may
8b1478
lead to OOB write access, because 'bptr' points somewhere in
8b1478
the middle of 'mbuf' buffer, not at the start. Use M_FREEROOM(m)
8b1478
size to avoid OOB access.
8b1478
8b1478
Reported-by: Vishnu Dev TJ <vishnudevtj@gmail.com>
8b1478
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
8b1478
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
8b1478
Message-Id: <20200109094228.79764-2-ppandit@redhat.com>
8b1478
(cherry picked from libslirp commit ce131029d6d4a405cb7d3ac6716d03e58fb4a5d9)
8b1478
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8b1478
8b1478
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
8b1478
---
8b1478
 slirp/tcp_subr.c | 6 +++---
8b1478
 1 file changed, 3 insertions(+), 3 deletions(-)
8b1478
8b1478
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
8b1478
index decfd9b..b60310d 100644
8b1478
--- a/slirp/tcp_subr.c
8b1478
+++ b/slirp/tcp_subr.c
8b1478
@@ -783,7 +783,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
8b1478
 				return 1;
8b1478
 			}
8b1478
 			m->m_len = bptr - m->m_data; /* Adjust length */
8b1478
-                        m->m_len += snprintf(bptr, m->m_size,
8b1478
+                        m->m_len += snprintf(bptr, M_FREEROOM(m),
8b1478
                                              "DCC CHAT chat %lu %u%c\n",
8b1478
                                              (unsigned long)ntohl(so->so_faddr.s_addr),
8b1478
                                              ntohs(so->so_fport), 1);
8b1478
@@ -794,7 +794,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
8b1478
 				return 1;
8b1478
 			}
8b1478
 			m->m_len = bptr - m->m_data; /* Adjust length */
8b1478
-                        m->m_len += snprintf(bptr, m->m_size,
8b1478
+                        m->m_len += snprintf(bptr, M_FREEROOM(m),
8b1478
                                              "DCC SEND %s %lu %u %u%c\n", buff,
8b1478
                                              (unsigned long)ntohl(so->so_faddr.s_addr),
8b1478
                                              ntohs(so->so_fport), n1, 1);
8b1478
@@ -805,7 +805,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
8b1478
 				return 1;
8b1478
 			}
8b1478
 			m->m_len = bptr - m->m_data; /* Adjust length */
8b1478
-                        m->m_len += snprintf(bptr, m->m_size,
8b1478
+                        m->m_len += snprintf(bptr, M_FREEROOM(m),
8b1478
                                              "DCC MOVE %s %lu %u %u%c\n", buff,
8b1478
                                              (unsigned long)ntohl(so->so_faddr.s_addr),
8b1478
                                              ntohs(so->so_fport), n1, 1);
8b1478
-- 
8b1478
1.8.3.1
8b1478