cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
1072c8
From 6bd4d80f9274f76eb402ce85aa60729150b39980 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:34 -0400
1072c8
Subject: [PATCH 09/14] tftp: check tftp_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-6-marcandre.lureau@redhat.com>
1072c8
Patchwork-id: 101823
1072c8
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 5/8] tftp: check tftp_input buffer size
1072c8
Bugzilla: 1970843
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-3595
1072c8
Fixes: https://gitlab.freedesktop.org/slirp/libslirp/-/issues/46
1072c8
1072c8
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1072c8
1072c8
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1970843
1072c8
1072c8
(cherry picked from commit 3f17948137155f025f7809fdc38576d5d2451c3d)
1072c8
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1072c8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1072c8
---
1072c8
 slirp/src/tftp.c | 6 +++++-
1072c8
 1 file changed, 5 insertions(+), 1 deletion(-)
1072c8
1072c8
diff --git a/slirp/src/tftp.c b/slirp/src/tftp.c
1072c8
index 093c2e06a3..07e8f3cb2f 100644
1072c8
--- a/slirp/src/tftp.c
1072c8
+++ b/slirp/src/tftp.c
1072c8
@@ -444,7 +444,11 @@ static void tftp_handle_error(Slirp *slirp, struct sockaddr_storage *srcsas,
1072c8
 
1072c8
 void tftp_input(struct sockaddr_storage *srcsas, struct mbuf *m)
1072c8
 {
1072c8
-    struct tftp_t *tp = (struct tftp_t *)m->m_data;
1072c8
+    struct tftp_t *tp = mtod_check(m, offsetof(struct tftp_t, x.tp_buf));
1072c8
+
1072c8
+    if (tp == NULL) {
1072c8
+        return;
1072c8
+    }
1072c8
 
1072c8
     switch (ntohs(tp->tp_op)) {
1072c8
     case TFTP_RRQ:
1072c8
-- 
1072c8
2.27.0
1072c8