From 94ca0eddc117b57da009dacb19740fc8ae00143a Mon Sep 17 00:00:00 2001 From: Jon Maloy Date: Mon, 28 Sep 2020 18:27:35 -0400 Subject: [PATCH] hw/net/net_tx_pkt: fix assertion failure in net_tx_pkt_add_raw_fragment() RH-Author: Jon Maloy Message-id: <20200928182735.1008839-2-jmaloy@redhat.com> Patchwork-id: 98497 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() Bugzilla: 1860994 RH-Acked-by: Laszlo Ersek RH-Acked-by: Xiao Wang RH-Acked-by: Thomas Huth RH-Acked-by: Stefan Hajnoczi From: Mauro Matteo Cascella 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 Reported-by: Ziming Zhang Reviewed-by: Dmitry Fleytman Signed-off-by: Mauro Matteo Cascella Signed-off-by: Jason Wang (cherry picked from commit 035e69b063835a5fd23cacabd63690a3d84532a8) Signed-off-by: Jon Maloy Signed-off-by: Danilo C. L. de Paula --- hw/net/net_tx_pkt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 162f802dd77..54d4c3bbd02 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -379,7 +379,10 @@ bool net_tx_pkt_add_raw_fragment(struct NetTxPkt *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.27.0