From a66ab346bf74ebf3ed8fca0dc2e2febfe70069e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 29 Jul 2021 04:56:28 -0400 Subject: [PATCH 07/14] bootp: check bootp_input buffer size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Marc-André Lureau Message-id: <20210708082537.1550263-4-marcandre.lureau@redhat.com> Patchwork-id: 101820 O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 3/8] bootp: check bootp_input buffer size Bugzilla: 1970819 RH-Acked-by: Stefano Garzarella RH-Acked-by: Eric Blake RH-Acked-by: Stefan Hajnoczi From: Marc-André Lureau Fixes: CVE-2021-3592 Fixes: https://gitlab.freedesktop.org/slirp/libslirp/-/issues/44 Signed-off-by: Marc-André Lureau BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1970819 (cherry picked from commit 2eca0838eee1da96204545e22cdaed860d9d7c6c) Signed-off-by: Marc-André Lureau Signed-off-by: Miroslav Rezanina --- slirp/src/bootp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slirp/src/bootp.c b/slirp/src/bootp.c index 5754327138..5789187166 100644 --- a/slirp/src/bootp.c +++ b/slirp/src/bootp.c @@ -366,9 +366,9 @@ udp_output(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); void bootp_input(struct mbuf *m) { - struct bootp_t *bp = mtod(m, struct bootp_t *); + struct bootp_t *bp = mtod_check(m, sizeof(struct bootp_t)); - if (bp->bp_op == BOOTP_REQUEST) { + if (bp && bp->bp_op == BOOTP_REQUEST) { bootp_reply(m->slirp, bp, m_end(m)); } } -- 2.27.0