thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
Blob Blame History Raw
From 1b5e283b804f9d650e1c96a3a97bd690876ac0aa Mon Sep 17 00:00:00 2001
From: Jon Maloy <jmaloy@redhat.com>
Date: Mon, 28 Sep 2020 20:05:20 -0400
Subject: [PATCH 1/2] hw/net/vmxnet_tx_pkt: fix assertion failure in
 vmxnet_tx_pkt_add_raw_fragment()

RH-Author: Jon Maloy <jmaloy@redhat.com>
Message-id: <20200928200520.1045037-2-jmaloy@redhat.com>
Patchwork-id: 98500
O-Subject: [RHEL-7.9.z qemu-kvm PATCH 1/1] hw/net/vmxnet_tx_pkt: fix assertion failure in vmxnet_tx_pkt_add_raw_fragment()
Bugzilla: 1860960
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>

An assertion failure issue was found in the code that processes network packets
while adding data fragments into the packet context. It could be abused by a
malicious guest to abort the QEMU process on the host. This patch replaces the
affected assert() with a conditional statement, returning false if the current
data fragment exceeds max_raw_frags.

Reported-by: Alexander Bulekov <alxndr@bu.edu>
Reported-by: Ziming Zhang <ezrakiez@gmail.com>
Reviewed-by: Dmitry Fleytman <dmitry.fleytman@gmail.com>
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>

(cherry picked from commit 035e69b063835a5fd23cacabd63690a3d84532a8)
Manually adapted since the affected function is located in a different
file and has a different name.
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: Jon Maloy <jmaloy.redhat.com>
---
 hw/net/vmxnet_tx_pkt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/net/vmxnet_tx_pkt.c b/hw/net/vmxnet_tx_pkt.c
index 03f34cf86f..cbb309e8a9 100644
--- a/hw/net/vmxnet_tx_pkt.c
+++ b/hw/net/vmxnet_tx_pkt.c
@@ -330,7 +330,10 @@ bool vmxnet_tx_pkt_add_raw_fragment(struct VmxnetTxPkt *pkt, hwaddr pa,
     hwaddr mapped_len = 0;
     struct iovec *ventry;
     assert(pkt);
-    assert(pkt->max_raw_frags > pkt->raw_frags);
+
+    if (pkt->raw_frags >= pkt->max_raw_frags) {
+	    return false;
+    }
 
     if (!len) {
         return true;
-- 
2.18.2