cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
6e7d01
From 6bd4d80f9274f76eb402ce85aa60729150b39980 Mon Sep 17 00:00:00 2001
6e7d01
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
6e7d01
Date: Thu, 29 Jul 2021 04:56:34 -0400
6e7d01
Subject: [PATCH 09/14] tftp: check tftp_input buffer size
6e7d01
MIME-Version: 1.0
6e7d01
Content-Type: text/plain; charset=UTF-8
6e7d01
Content-Transfer-Encoding: 8bit
6e7d01
6e7d01
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
6e7d01
Message-id: <20210708082537.1550263-6-marcandre.lureau@redhat.com>
6e7d01
Patchwork-id: 101823
6e7d01
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 5/8] tftp: check tftp_input buffer size
6e7d01
Bugzilla: 1970843
6e7d01
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
6e7d01
RH-Acked-by: Eric Blake <eblake@redhat.com>
6e7d01
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
6e7d01
6e7d01
From: Marc-André Lureau <marcandre.lureau@redhat.com>
6e7d01
6e7d01
Fixes: CVE-2021-3595
6e7d01
Fixes: https://gitlab.freedesktop.org/slirp/libslirp/-/issues/46
6e7d01
6e7d01
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6e7d01
6e7d01
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1970843
6e7d01
6e7d01
(cherry picked from commit 3f17948137155f025f7809fdc38576d5d2451c3d)
6e7d01
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6e7d01
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
6e7d01
---
6e7d01
 slirp/src/tftp.c | 6 +++++-
6e7d01
 1 file changed, 5 insertions(+), 1 deletion(-)
6e7d01
6e7d01
diff --git a/slirp/src/tftp.c b/slirp/src/tftp.c
6e7d01
index 093c2e06a3..07e8f3cb2f 100644
6e7d01
--- a/slirp/src/tftp.c
6e7d01
+++ b/slirp/src/tftp.c
6e7d01
@@ -444,7 +444,11 @@ static void tftp_handle_error(Slirp *slirp, struct sockaddr_storage *srcsas,
6e7d01
 
6e7d01
 void tftp_input(struct sockaddr_storage *srcsas, struct mbuf *m)
6e7d01
 {
6e7d01
-    struct tftp_t *tp = (struct tftp_t *)m->m_data;
6e7d01
+    struct tftp_t *tp = mtod_check(m, offsetof(struct tftp_t, x.tp_buf));
6e7d01
+
6e7d01
+    if (tp == NULL) {
6e7d01
+        return;
6e7d01
+    }
6e7d01
 
6e7d01
     switch (ntohs(tp->tp_op)) {
6e7d01
     case TFTP_RRQ:
6e7d01
-- 
6e7d01
2.27.0
6e7d01