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