thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-hw-net-net_tx_pkt-fix-assertion-failure-in-net_tx_pk.patch

8fced6
From 94ca0eddc117b57da009dacb19740fc8ae00143a Mon Sep 17 00:00:00 2001
8fced6
From: Jon Maloy <jmaloy@redhat.com>
8fced6
Date: Mon, 28 Sep 2020 18:27:35 -0400
8fced6
Subject: [PATCH] hw/net/net_tx_pkt: fix assertion failure in
8fced6
 net_tx_pkt_add_raw_fragment()
8fced6
8fced6
RH-Author: Jon Maloy <jmaloy@redhat.com>
8fced6
Message-id: <20200928182735.1008839-2-jmaloy@redhat.com>
8fced6
Patchwork-id: 98497
8fced6
O-Subject: [RHEL-8.0.0 qemu-kvm PATCH 1/1] hw/net/net_tx_pkt: fix assertion failure in net_tx_pkt_add_raw_fragment()
8fced6
Bugzilla: 1860994
8fced6
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
8fced6
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
8fced6
RH-Acked-by: Thomas Huth <thuth@redhat.com>
8fced6
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
8fced6
From: Mauro Matteo Cascella <mcascell@redhat.com>
8fced6
8fced6
An assertion failure issue was found in the code that processes network packets
8fced6
while adding data fragments into the packet context. It could be abused by a
8fced6
malicious guest to abort the QEMU process on the host. This patch replaces the
8fced6
affected assert() with a conditional statement, returning false if the current
8fced6
data fragment exceeds max_raw_frags.
8fced6
8fced6
Reported-by: Alexander Bulekov <alxndr@bu.edu>
8fced6
Reported-by: Ziming Zhang <ezrakiez@gmail.com>
8fced6
Reviewed-by: Dmitry Fleytman <dmitry.fleytman@gmail.com>
8fced6
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
8fced6
Signed-off-by: Jason Wang <jasowang@redhat.com>
8fced6
8fced6
(cherry picked from commit 035e69b063835a5fd23cacabd63690a3d84532a8)
8fced6
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
8fced6
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
8fced6
---
8fced6
 hw/net/net_tx_pkt.c | 5 ++++-
8fced6
 1 file changed, 4 insertions(+), 1 deletion(-)
8fced6
8fced6
diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c
8fced6
index 162f802dd77..54d4c3bbd02 100644
8fced6
--- a/hw/net/net_tx_pkt.c
8fced6
+++ b/hw/net/net_tx_pkt.c
8fced6
@@ -379,7 +379,10 @@ bool net_tx_pkt_add_raw_fragment(struct NetTxPkt *pkt, hwaddr pa,
8fced6
     hwaddr mapped_len = 0;
8fced6
     struct iovec *ventry;
8fced6
     assert(pkt);
8fced6
-    assert(pkt->max_raw_frags > pkt->raw_frags);
8fced6
+
8fced6
+    if (pkt->raw_frags >= pkt->max_raw_frags) {
8fced6
+        return false;
8fced6
+    }
8fced6
 
8fced6
     if (!len) {
8fced6
         return true;
8fced6
-- 
8fced6
2.27.0
8fced6