From f81cddfe8abe7d7e2220e611ee69d2cdf34eb789 Mon Sep 17 00:00:00 2001 From: Lukas Straub Date: Fri, 31 Jul 2020 07:06:04 +0200 Subject: colo-compare: Remove superfluous NULL-pointer checks for s->iothread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit s->iothread is checked for NULL on object creation in colo_compare_complete, so it's guaranteed not to be NULL. This resolves a false alert from Coverity (CID 1429969). Signed-off-by: Lukas Straub Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang Reviewed-by: Zhang Chen Signed-off-by: Jason Wang --- net/colo-compare.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index cc15f23dea..2c20de1537 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -1442,9 +1442,7 @@ static void colo_compare_finalize(Object *obj) qemu_chr_fe_deinit(&s->chr_notify_dev, false); } - if (s->iothread) { - colo_compare_timer_del(s); - } + colo_compare_timer_del(s); qemu_bh_delete(s->event_bh); @@ -1470,9 +1468,7 @@ static void colo_compare_finalize(Object *obj) g_hash_table_destroy(s->connection_track_table); } - if (s->iothread) { - object_unref(OBJECT(s->iothread)); - } + object_unref(OBJECT(s->iothread)); g_free(s->pri_indev); g_free(s->sec_indev); -- cgit v1.2.3 From 035e69b063835a5fd23cacabd63690a3d84532a8 Mon Sep 17 00:00:00 2001 From: Mauro Matteo Cascella Date: Sat, 1 Aug 2020 18:42:38 +0200 Subject: hw/net/net_tx_pkt: fix assertion failure in net_tx_pkt_add_raw_fragment() 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 --- 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 9560e4a49e..da262edc3e 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; -- cgit v1.2.3