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

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