yeahuh / rpms / qemu-kvm

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