thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-slirp-check-pkt_len-before-reading-protocol-header.patch

c687bc
From 2bfa25e55c0a49bc079e5769db2199989eda7745 Mon Sep 17 00:00:00 2001
c687bc
From: Jon Maloy <jmaloy@redhat.com>
c687bc
Date: Fri, 11 Dec 2020 00:59:26 -0500
c687bc
Subject: [PATCH 03/14] slirp: check pkt_len before reading protocol header
c687bc
MIME-Version: 1.0
c687bc
Content-Type: text/plain; charset=UTF-8
c687bc
Content-Transfer-Encoding: 8bit
c687bc
c687bc
RH-Author: Jon Maloy <jmaloy@redhat.com>
c687bc
Message-id: <20201211005926.618830-2-jmaloy@redhat.com>
c687bc
Patchwork-id: 100398
c687bc
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/1] slirp: check pkt_len before reading protocol header
c687bc
Bugzilla: 1902237
c687bc
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
c687bc
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
c687bc
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
c687bc
c687bc
While processing ARP/NCSI packets in 'arp_input' or 'ncsi_input'
c687bc
routines, ensure that pkt_len is large enough to accommodate the
c687bc
respective protocol headers, lest it should do an OOB access.
c687bc
Add check to avoid it.
c687bc
c687bc
CVE-2020-29129 CVE-2020-29130
c687bc
 QEMU: slirp: out-of-bounds access while processing ARP/NCSI packets
c687bc
 -> https://www.openwall.com/lists/oss-security/2020/11/27/1
c687bc
c687bc
Reported-by: Qiuhao Li <Qiuhao.Li@outlook.com>
c687bc
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
c687bc
Message-Id: <20201126135706.273950-1-ppandit@redhat.com>
c687bc
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
c687bc
c687bc
(cherry picked from libslirp commit 2e1dcbc0c2af64fcb17009eaf2ceedd81be2b27f)
c687bc
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
c687bc
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
c687bc
---
c687bc
 slirp/src/ncsi.c  | 4 ++++
c687bc
 slirp/src/slirp.c | 4 ++++
c687bc
 2 files changed, 8 insertions(+)
c687bc
c687bc
diff --git a/slirp/src/ncsi.c b/slirp/src/ncsi.c
c687bc
index 6864b735db4..251c0d2bfbb 100644
c687bc
--- a/slirp/src/ncsi.c
c687bc
+++ b/slirp/src/ncsi.c
c687bc
@@ -147,6 +147,10 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
c687bc
     uint32_t checksum;
c687bc
     uint32_t *pchecksum;
c687bc
 
c687bc
+    if (pkt_len < ETH_HLEN + sizeof(struct ncsi_pkt_hdr)) {
c687bc
+        return; /* packet too short */
c687bc
+    }
c687bc
+
c687bc
     memset(ncsi_reply, 0, sizeof(ncsi_reply));
c687bc
 
c687bc
     memset(reh->h_dest, 0xff, ETH_ALEN);
c687bc
diff --git a/slirp/src/slirp.c b/slirp/src/slirp.c
c687bc
index b0194cb32bb..86b0f52d923 100644
c687bc
--- a/slirp/src/slirp.c
c687bc
+++ b/slirp/src/slirp.c
c687bc
@@ -700,6 +700,10 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
c687bc
         return;
c687bc
     }
c687bc
 
c687bc
+    if (pkt_len < ETH_HLEN + sizeof(struct slirp_arphdr)) {
c687bc
+        return; /* packet too short */
c687bc
+    }
c687bc
+
c687bc
     ar_op = ntohs(ah->ar_op);
c687bc
     switch (ar_op) {
c687bc
     case ARPOP_REQUEST:
c687bc
-- 
c687bc
2.27.0
c687bc