1072c8
From 1b8aa33b218a8ff3e8aa2f1b6875df40fd70f0ed 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:40 -0400
1072c8
Subject: [PATCH 11/14] udp: check upd_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-8-marcandre.lureau@redhat.com>
1072c8
Patchwork-id: 101826
1072c8
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 7/8] udp: check upd_input buffer size
1072c8
Bugzilla: 1970853
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-3594
1072c8
Fixes: https://gitlab.freedesktop.org/slirp/libslirp/-/issues/47
1072c8
1072c8
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1072c8
1072c8
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1970853
1072c8
1072c8
(cherry picked from commit 74572be49247c8c5feae7c6e0b50c4f569ca9824)
1072c8
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1072c8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1072c8
---
1072c8
 slirp/src/udp.c | 5 ++++-
1072c8
 1 file changed, 4 insertions(+), 1 deletion(-)
1072c8
1072c8
diff --git a/slirp/src/udp.c b/slirp/src/udp.c
1072c8
index ae23ba4b2a..86142bba14 100644
1072c8
--- a/slirp/src/udp.c
1072c8
+++ b/slirp/src/udp.c
1072c8
@@ -90,7 +90,10 @@ void udp_input(register struct mbuf *m, int iphlen)
1072c8
     /*
1072c8
      * Get IP and UDP header together in first mbuf.
1072c8
      */
1072c8
-    ip = mtod(m, struct ip *);
1072c8
+    ip = mtod_check(m, iphlen + sizeof(struct udphdr));
1072c8
+    if (ip == NULL) {
1072c8
+        goto bad;
1072c8
+    }
1072c8
     uh = (struct udphdr *)((char *)ip + iphlen);
1072c8
 
1072c8
     /*
1072c8
-- 
1072c8
2.27.0
1072c8