yeahuh / rpms / qemu-kvm

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