cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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