|
|
1bdc94 |
From 34a609b26d1c20f15b168ebf889705886f9c7d1d Mon Sep 17 00:00:00 2001
|
|
|
12f46f |
From: Xiao Wang <jasowang@redhat.com>
|
|
|
1bdc94 |
Date: Mon, 30 Jul 2018 08:06:27 +0200
|
|
|
1bdc94 |
Subject: [PATCH 13/15] slirp: correct size computation while concatenating
|
|
|
1bdc94 |
mbuf
|
|
|
12f46f |
|
|
|
12f46f |
RH-Author: Xiao Wang <jasowang@redhat.com>
|
|
|
1bdc94 |
Message-id: <1532937987-25050-1-git-send-email-jasowang@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 81544
|
|
|
1bdc94 |
O-Subject: [RHEL-7.6/7.5z qemu-kvm-rhev] slirp: correct size computation while concatenating mbuf
|
|
|
1bdc94 |
Bugzilla: 1586255
|
|
|
12f46f |
RH-Acked-by: wexu@redhat.com
|
|
|
1bdc94 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
12f46f |
|
|
|
12f46f |
From: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
12f46f |
|
|
|
12f46f |
While reassembling incoming fragmented datagrams, 'm_cat' routine
|
|
|
12f46f |
extends the 'mbuf' buffer, if it has insufficient room. It computes
|
|
|
12f46f |
a wrong buffer size, which leads to overwriting adjacent heap buffer
|
|
|
12f46f |
area. Correct this size computation in m_cat.
|
|
|
12f46f |
|
|
|
12f46f |
Reported-by: ZDI Disclosures <zdi-disclosures@trendmicro.com>
|
|
|
12f46f |
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
12f46f |
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
|
|
|
12f46f |
(cherry picked from commit 864036e251f54c99d31df124aad7f34f01f5344c)
|
|
|
12f46f |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
12f46f |
---
|
|
|
12f46f |
slirp/mbuf.c | 11 +++++------
|
|
|
12f46f |
slirp/mbuf.h | 8 +++-----
|
|
|
12f46f |
2 files changed, 8 insertions(+), 11 deletions(-)
|
|
|
12f46f |
|
|
|
12f46f |
diff --git a/slirp/mbuf.c b/slirp/mbuf.c
|
|
|
12f46f |
index 5ff2455..18cbf75 100644
|
|
|
12f46f |
--- a/slirp/mbuf.c
|
|
|
12f46f |
+++ b/slirp/mbuf.c
|
|
|
12f46f |
@@ -138,7 +138,7 @@ m_cat(struct mbuf *m, struct mbuf *n)
|
|
|
12f46f |
* If there's no room, realloc
|
|
|
12f46f |
*/
|
|
|
12f46f |
if (M_FREEROOM(m) < n->m_len)
|
|
|
12f46f |
- m_inc(m,m->m_size+MINCSIZE);
|
|
|
12f46f |
+ m_inc(m, m->m_len + n->m_len);
|
|
|
12f46f |
|
|
|
12f46f |
memcpy(m->m_data+m->m_len, n->m_data, n->m_len);
|
|
|
12f46f |
m->m_len += n->m_len;
|
|
|
12f46f |
@@ -147,7 +147,7 @@ m_cat(struct mbuf *m, struct mbuf *n)
|
|
|
12f46f |
}
|
|
|
12f46f |
|
|
|
12f46f |
|
|
|
12f46f |
-/* make m size bytes large */
|
|
|
12f46f |
+/* make m 'size' bytes large from m_data */
|
|
|
12f46f |
void
|
|
|
12f46f |
m_inc(struct mbuf *m, int size)
|
|
|
12f46f |
{
|
|
|
12f46f |
@@ -158,12 +158,12 @@ m_inc(struct mbuf *m, int size)
|
|
|
12f46f |
|
|
|
12f46f |
if (m->m_flags & M_EXT) {
|
|
|
12f46f |
datasize = m->m_data - m->m_ext;
|
|
|
12f46f |
- m->m_ext = g_realloc(m->m_ext, size);
|
|
|
12f46f |
+ m->m_ext = g_realloc(m->m_ext, size + datasize);
|
|
|
12f46f |
m->m_data = m->m_ext + datasize;
|
|
|
12f46f |
} else {
|
|
|
12f46f |
char *dat;
|
|
|
12f46f |
datasize = m->m_data - m->m_dat;
|
|
|
12f46f |
- dat = g_malloc(size);
|
|
|
12f46f |
+ dat = g_malloc(size + datasize);
|
|
|
12f46f |
memcpy(dat, m->m_dat, m->m_size);
|
|
|
12f46f |
|
|
|
12f46f |
m->m_ext = dat;
|
|
|
12f46f |
@@ -171,8 +171,7 @@ m_inc(struct mbuf *m, int size)
|
|
|
12f46f |
m->m_flags |= M_EXT;
|
|
|
12f46f |
}
|
|
|
12f46f |
|
|
|
12f46f |
- m->m_size = size;
|
|
|
12f46f |
-
|
|
|
12f46f |
+ m->m_size = size + datasize;
|
|
|
12f46f |
}
|
|
|
12f46f |
|
|
|
12f46f |
|
|
|
12f46f |
diff --git a/slirp/mbuf.h b/slirp/mbuf.h
|
|
|
12f46f |
index 893601f..33b8448 100644
|
|
|
12f46f |
--- a/slirp/mbuf.h
|
|
|
12f46f |
+++ b/slirp/mbuf.h
|
|
|
12f46f |
@@ -33,8 +33,6 @@
|
|
|
12f46f |
#ifndef MBUF_H
|
|
|
12f46f |
#define MBUF_H
|
|
|
12f46f |
|
|
|
12f46f |
-#define MINCSIZE 4096 /* Amount to increase mbuf if too small */
|
|
|
12f46f |
-
|
|
|
12f46f |
/*
|
|
|
12f46f |
* Macros for type conversion
|
|
|
12f46f |
* mtod(m,t) - convert mbuf pointer to data pointer of correct type
|
|
|
12f46f |
@@ -72,11 +70,11 @@ struct mbuf {
|
|
|
12f46f |
struct mbuf *m_prevpkt; /* Flags aren't used in the output queue */
|
|
|
12f46f |
int m_flags; /* Misc flags */
|
|
|
12f46f |
|
|
|
12f46f |
- int m_size; /* Size of data */
|
|
|
12f46f |
+ int m_size; /* Size of mbuf, from m_dat or m_ext */
|
|
|
12f46f |
struct socket *m_so;
|
|
|
12f46f |
|
|
|
12f46f |
- caddr_t m_data; /* Location of data */
|
|
|
12f46f |
- int m_len; /* Amount of data in this mbuf */
|
|
|
12f46f |
+ caddr_t m_data; /* Current location of data */
|
|
|
12f46f |
+ int m_len; /* Amount of data in this mbuf, from m_data */
|
|
|
12f46f |
|
|
|
12f46f |
Slirp *slirp;
|
|
|
12f46f |
bool resolution_requested;
|
|
|
12f46f |
--
|
|
|
12f46f |
1.8.3.1
|
|
|
12f46f |
|