yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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