blob: 7175b24e99a9d1bffa76d5c03a80d784659c95fa [file] [log] [blame]
Andrew Geisslerc926e172021-05-07 16:11:35 -05001From affdf476543405045c281a7c67d1eaedbcea8135 Mon Sep 17 00:00:00 2001
2From: Jason Wang <jasowang@redhat.com>
3Date: Wed, 24 Feb 2021 13:45:28 +0800
4Subject: [PATCH] e1000: fail early for evil descriptor
5
6During procss_tx_desc(), driver can try to chain data descriptor with
7legacy descriptor, when will lead underflow for the following
8calculation in process_tx_desc() for bytes:
9
10 if (tp->size + bytes > msh)
11 bytes = msh - tp->size;
12
13This will lead a infinite loop. So check and fail early if tp->size if
14greater or equal to msh.
15
16Reported-by: Alexander Bulekov <alxndr@bu.edu>
17Reported-by: Cheolwoo Myung <cwmyung@snu.ac.kr>
18Reported-by: Ruhr-University Bochum <bugs-syssec@rub.de>
19Cc: Prasad J Pandit <ppandit@redhat.com>
20Cc: qemu-stable@nongnu.org
21Signed-off-by: Jason Wang <jasowang@redhat.com>
22
23Upstream-Status: Backport [3de46e6fc489c52c9431a8a832ad8170a7569bd8]
24CVE: CVE-2021-20257
25
26Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com>
27---
28 hw/net/e1000.c | 4 ++++
29 1 file changed, 4 insertions(+)
30
31diff --git a/hw/net/e1000.c b/hw/net/e1000.c
32index cf22c4f07..c3564c7ce 100644
33--- a/hw/net/e1000.c
34+++ b/hw/net/e1000.c
35@@ -670,6 +670,9 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
36 msh = tp->tso_props.hdr_len + tp->tso_props.mss;
37 do {
38 bytes = split_size;
39+ if (tp->size >= msh) {
40+ goto eop;
41+ }
42 if (tp->size + bytes > msh)
43 bytes = msh - tp->size;
44
45@@ -695,6 +698,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
46 tp->size += split_size;
47 }
48
49+eop:
50 if (!(txd_lower & E1000_TXD_CMD_EOP))
51 return;
52 if (!(tp->cptse && tp->size < tp->tso_props.hdr_len)) {
53--
542.29.2
55