qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Samuel Thibault" <samuel.thibault@ens-lyon.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Michael Roth" <mdroth@linux.vnet.ibm.com>,
	"Jan Kiszka" <jan.kiszka@siemens.com>
Subject: [Qemu-devel] [PATCH-for-3.1.1 1/1] Fix heap overflow in ip_reass on big packet input
Date: Fri,  2 Aug 2019 20:04:49 +0200	[thread overview]
Message-ID: <20190802180449.10288-2-philmd@redhat.com> (raw)
In-Reply-To: <20190802180449.10288-1-philmd@redhat.com>

From: Samuel Thibault <samuel.thibault@ens-lyon.org>

When the first fragment does not fit in the preallocated buffer, q will
already be pointing to the ext buffer, so we mustn't try to update it.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
(cherry picked from libslirp commit 126c04acbabd7ad32c2b018fe10dfac2a3bc1210)
Fixes: CVE-2019-14378
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 slirp/ip_input.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/slirp/ip_input.c b/slirp/ip_input.c
index 348e1dca5a..07d8808671 100644
--- a/slirp/ip_input.c
+++ b/slirp/ip_input.c
@@ -334,6 +334,8 @@ insert:
     q = fp->frag_link.next;
 	m = dtom(slirp, q);
 
+	int was_ext = m->m_flags & M_EXT;
+
 	q = (struct ipasfrag *) q->ipf_next;
 	while (q != (struct ipasfrag*)&fp->frag_link) {
 	  struct mbuf *t = dtom(slirp, q);
@@ -356,7 +358,7 @@ insert:
 	 * the old buffer (in the mbuf), so we must point ip
 	 * into the new buffer.
 	 */
-	if (m->m_flags & M_EXT) {
+	if (!was_ext && m->m_flags & M_EXT) {
 	  int delta = (char *)q - m->m_dat;
 	  q = (struct ipasfrag *)(m->m_ext + delta);
 	}
-- 
2.20.1



  reply	other threads:[~2019-08-02 18:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02 18:04 [Qemu-devel] [PATCH-for-3.1.1 0/1] Backport of CVE-2019-14378 fix Philippe Mathieu-Daudé
2019-08-02 18:04 ` Philippe Mathieu-Daudé [this message]
2019-08-02 22:18   ` [Qemu-devel] [PATCH-for-3.1.1 1/1] Fix heap overflow in ip_reass on big packet input Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190802180449.10288-2-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@ens-lyon.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).