From: P J P <ppandit@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: Alexander Bulekov <alxndr@bu.edu>,
Cheolwoo Myung <cwmyung@snu.ac.kr>,
Ruhr-University Bochum <bugs-syssec@rub.de>,
QEMU Developers <qemu-devel@nongnu.org>,
Prasad J Pandit <pjp@fedoraproject.org>
Subject: [PATCH] net: e1000: check transmit descriptor field values
Date: Wed, 10 Feb 2021 20:22:58 +0530 [thread overview]
Message-ID: <20210210145258.143131-1-ppandit@redhat.com> (raw)
From: Prasad J Pandit <pjp@fedoraproject.org>
While processing transmit (tx) descriptors in process_tx_desc()
various descriptor fields are not checked properly. This may lead
to infinite loop like issue. Add checks to avoid them.
Reported-by: Alexander Bulekov <alxndr@bu.edu>
Reported-by: Cheolwoo Myung <cwmyung@snu.ac.kr>
Reported-by: Ruhr-University Bochum <bugs-syssec@rub.de>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
hw/net/e1000.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index d8da2f6528..15949a3d64 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -667,9 +667,11 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
addr = le64_to_cpu(dp->buffer_addr);
if (tp->cptse) {
+ assert(tp->tso_props.hdr_len);
msh = tp->tso_props.hdr_len + tp->tso_props.mss;
do {
bytes = split_size;
+ assert(msh > tp->size);
if (tp->size + bytes > msh)
bytes = msh - tp->size;
@@ -681,22 +683,26 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
memmove(tp->header, tp->data, tp->tso_props.hdr_len);
}
tp->size = sz;
+ assert(tp->size); /* sz may get truncated */
addr += bytes;
if (sz == msh) {
xmit_seg(s);
memmove(tp->data, tp->header, tp->tso_props.hdr_len);
tp->size = tp->tso_props.hdr_len;
}
+ assert(split_size >= bytes);
split_size -= bytes;
} while (bytes && split_size);
} else {
split_size = MIN(sizeof(tp->data) - tp->size, split_size);
+ assert(tp->size && split_size);
pci_dma_read(d, addr, tp->data + tp->size, split_size);
tp->size += split_size;
}
if (!(txd_lower & E1000_TXD_CMD_EOP))
return;
+ assert(tp->size && tp->tso_props.hdr_len);
if (!(tp->cptse && tp->size < tp->tso_props.hdr_len)) {
xmit_seg(s);
}
--
2.29.2
next reply other threads:[~2021-02-10 14:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-10 14:52 P J P [this message]
2021-02-18 5:53 ` [PATCH] net: e1000: check transmit descriptor field values Jason Wang
2021-02-18 7:47 ` P J P
2021-02-19 2:53 ` Jason Wang
2021-02-19 3:05 ` Alexander Bulekov
2021-02-19 9:01 ` P J P
2021-02-19 10:27 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210210145258.143131-1-ppandit@redhat.com \
--to=ppandit@redhat.com \
--cc=alxndr@bu.edu \
--cc=bugs-syssec@rub.de \
--cc=cwmyung@snu.ac.kr \
--cc=jasowang@redhat.com \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).