Skip to contentSkip to conversation

hw/net/net_tx_pkt: fix assertion failure in net_tx_pkt_add_raw_fragment()

PATCH Applied Mauro Matteo Cascella 3 participants 3 messages Aug 1, 2020 – Aug 4, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

---
 hw/net/net_tx_pkt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/net/net_tx_pkt.c +4 -1
index 9560e4a49e..da262edc3e 100644
@@ -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;
Signature · 1 line
2.26.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · 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.

Quoted 26 lines

---
hw/net/net_tx_pkt.c | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)
hw/net/net_tx_pkt.c +4 -1
index 9560e4a49e..da262edc3e 100644
@@ -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;
Signature · 1 line
2.26.2
Applied
#2 lore raw
In reply to Mauro Matteo Cascella
Quoted 19 lines · 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.

---
  hw/net/net_tx_pkt.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
hw/net/net_tx_pkt.c +0 -0
index 9560e4a49e..da262edc3e 100644
@@ -379,7 +379,10 @@ bool net_tx_pkt_add_raw_fragment(struct NetTxPkt *pkt, hwaddr pa,
      hwaddr mapped_len = 0;

hw/net/net_tx_pkt.c bool net_tx_pkt_add_raw_fragment(struct NetTxPkt *pkt, hwaddr pa, · line 388

Quoted 10 lines
hw/net/net_tx_pkt.c +4 -1
      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;

Applied.

Thanks