From f63534122060ee84b0fe696bef136b05e427c755 Mon Sep 17 00:00:00 2001 From: Jon Maloy Date: Mon, 28 Sep 2020 20:44:52 -0400 Subject: [PATCH] hw/net/net_tx_pkt: fix assertion failure in net_tx_pkt_add_raw_fragment() RH-Author: Jon Maloy Message-id: <20200928204452.1061309-2-jmaloy@redhat.com> Patchwork-id: 98507 O-Subject: [RHEL-7.9.z qemu-kvm-ma PATCH 1/1] hw/net/net_tx_pkt: fix assertion failure in net_tx_pkt_add_raw_fragment() Bugzilla: 1860961 RH-Acked-by: Miroslav Rezanina RH-Acked-by: Laszlo Ersek 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: Jon Maloy --- 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 162f802dd7..54d4c3bbd0 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.18.2