Skip to contentSkip to conversation

Backport of CVE-2019-14378 fix

PATCH In review Philippe Mathieu-Daudé 2 participants 3 messages Aug 2, 2019

lore
Share & tools
lore
#0 lore raw

cover Backport of CVE-2019-14378 fix

Trivial backport from the libslirp repository.

Samuel Thibault (1):
Fix heap overflow in ip_reass on big packet input

 slirp/ip_input.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 Fix heap overflow in ip_reass on big packet input

From: Samuel Thibault <[email protected]>

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.

(cherry picked from libslirp commit 126c04acbabd7ad32c2b018fe10dfac2a3bc1210)

Fixes CVE-2019-14378
---
 slirp/ip_input.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
slirp/ip_input.c +3 -1
index 348e1dca5a..07d8808671 100644
@@ -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);
 	}
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#2 lore raw

Re: [Qemu-devel] [PATCH-for-3.1.1 1/1] Fix heap overflow in ip_reass on big packet input

Quoted 10 lines · Philippe Mathieu-Daudé

From: Samuel Thibault <[email protected]>

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.

(cherry picked from libslirp commit 126c04acbabd7ad32c2b018fe10dfac2a3bc1210)

Fixes CVE-2019-14378

thanks

Quoted 30 lines
---
 slirp/ip_input.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
slirp/ip_input.c +3 -2
index 348e1dca5a..07d8808671 100644
@@ -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

Signature · 1 line
Marc-André Lureau