yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
1072c8
From 7bd3000cf22a91e6bc6afc1e7adbf0ae1b731104 Mon Sep 17 00:00:00 2001
1072c8
From: Jon Maloy <jmaloy@redhat.com>
1072c8
Date: Tue, 13 Apr 2021 22:45:17 -0400
1072c8
Subject: [PATCH 2/5] e1000: fail early for evil descriptor
1072c8
1072c8
RH-Author: Jon Maloy <jmaloy@redhat.com>
1072c8
Message-id: <20210413224517.3841507-2-jmaloy@redhat.com>
1072c8
Patchwork-id: 101473
1072c8
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 1/1] e1000: fail early for evil descriptor
1072c8
Bugzilla: 1930092
1072c8
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
1072c8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
1072c8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
1072c8
1072c8
From: Jason Wang <jasowang@redhat.com>
1072c8
1072c8
During procss_tx_desc(), driver can try to chain data descriptor with
1072c8
legacy descriptor, when will lead underflow for the following
1072c8
calculation in process_tx_desc() for bytes:
1072c8
1072c8
            if (tp->size + bytes > msh)
1072c8
                bytes = msh - tp->size;
1072c8
1072c8
This will lead a infinite loop. So check and fail early if tp->size if
1072c8
greater or equal to msh.
1072c8
1072c8
Reported-by: Alexander Bulekov <alxndr@bu.edu>
1072c8
Reported-by: Cheolwoo Myung <cwmyung@snu.ac.kr>
1072c8
Reported-by: Ruhr-University Bochum <bugs-syssec@rub.de>
1072c8
Cc: Prasad J Pandit <ppandit@redhat.com>
1072c8
Cc: qemu-stable@nongnu.org
1072c8
Signed-off-by: Jason Wang <jasowang@redhat.com>
1072c8
1072c8
(cherry picked from commit 3de46e6fc489c52c9431a8a832ad8170a7569bd8)
1072c8
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
1072c8
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
1072c8
---
1072c8
 hw/net/e1000.c | 4 ++++
1072c8
 1 file changed, 4 insertions(+)
1072c8
1072c8
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
1072c8
index fc73fdd6fa..fe56bccd52 100644
1072c8
--- a/hw/net/e1000.c
1072c8
+++ b/hw/net/e1000.c
1072c8
@@ -671,6 +671,9 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
1072c8
         msh = tp->tso_props.hdr_len + tp->tso_props.mss;
1072c8
         do {
1072c8
             bytes = split_size;
1072c8
+            if (tp->size >= msh) {
1072c8
+                goto eop;
1072c8
+            }
1072c8
             if (tp->size + bytes > msh)
1072c8
                 bytes = msh - tp->size;
1072c8
 
1072c8
@@ -696,6 +699,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
1072c8
         tp->size += split_size;
1072c8
     }
1072c8
 
1072c8
+eop:
1072c8
     if (!(txd_lower & E1000_TXD_CMD_EOP))
1072c8
         return;
1072c8
     if (!(tp->cptse && tp->size < tp->tso_props.hdr_len)) {
1072c8
-- 
1072c8
2.27.0
1072c8