1072c8
From 6808086932ddc83fd748c46fea495e7004299b55 Mon Sep 17 00:00:00 2001
1072c8
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
1072c8
Date: Thu, 29 Jul 2021 04:56:31 -0400
1072c8
Subject: [PATCH 08/14] upd6: check udp6_input buffer size
1072c8
MIME-Version: 1.0
1072c8
Content-Type: text/plain; charset=UTF-8
1072c8
Content-Transfer-Encoding: 8bit
1072c8
1072c8
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
1072c8
Message-id: <20210708082537.1550263-5-marcandre.lureau@redhat.com>
1072c8
Patchwork-id: 101822
1072c8
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 4/8] upd6: check udp6_input buffer size
1072c8
Bugzilla: 1970835
1072c8
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
1072c8
RH-Acked-by: Eric Blake <eblake@redhat.com>
1072c8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
1072c8
1072c8
From: Marc-André Lureau <marcandre.lureau@redhat.com>
1072c8
1072c8
Fixes: CVE-2021-3593
1072c8
Fixes: https://gitlab.freedesktop.org/slirp/libslirp/-/issues/45
1072c8
1072c8
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1072c8
1072c8
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1970835
1072c8
1072c8
(cherry picked from commit de71c15de66ba9350bf62c45b05f8fbff166517b)
1072c8
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1072c8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1072c8
---
1072c8
 slirp/src/udp6.c | 5 ++++-
1072c8
 1 file changed, 4 insertions(+), 1 deletion(-)
1072c8
1072c8
diff --git a/slirp/src/udp6.c b/slirp/src/udp6.c
1072c8
index 6f9486bbca..8c490e4d10 100644
1072c8
--- a/slirp/src/udp6.c
1072c8
+++ b/slirp/src/udp6.c
1072c8
@@ -28,7 +28,10 @@ void udp6_input(struct mbuf *m)
1072c8
     ip = mtod(m, struct ip6 *);
1072c8
     m->m_len -= iphlen;
1072c8
     m->m_data += iphlen;
1072c8
-    uh = mtod(m, struct udphdr *);
1072c8
+    uh = mtod_check(m, sizeof(struct udphdr));
1072c8
+    if (uh == NULL) {
1072c8
+        goto bad;
1072c8
+    }
1072c8
     m->m_len += iphlen;
1072c8
     m->m_data -= iphlen;
1072c8
 
1072c8
-- 
1072c8
2.27.0
1072c8