yeahuh / rpms / qemu-kvm

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