From: Stephen Hemminger <stephen@networkplumber.org>
To: ajit.khaparde@broadcom.com, somnath.kotur@broadcom.com
Cc: dev@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>,
Christopher Ertl <Christopher.Ertl@microsoft.com>
Subject: [dpdk-dev] [PATCH 6/6] net/bnxt: sanitize max_l2_ctx
Date: Tue, 3 Mar 2020 09:59:38 -0800 [thread overview]
Message-ID: <20200303175938.14292-7-stephen@networkplumber.org> (raw)
In-Reply-To: <20200303175938.14292-1-stephen@networkplumber.org>
If max_l2_ctx is very large, then adding the additional value
could cause wraparound.
Reported-by: Christopher Ertl <Christopher.Ertl@microsoft.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/bnxt/bnxt_hwrm.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index d878320aa110..099e04fa550a 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -651,8 +651,15 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
bp->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
bp->max_rx_em_flows = rte_le_to_cpu_16(resp->max_rx_em_flows);
bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
- if (!BNXT_CHIP_THOR(bp))
- bp->max_l2_ctx += bp->max_rx_em_flows;
+ if (!BNXT_CHIP_THOR(bp)) {
+ uint16_t max_l2_ctx;
+
+ if (rte_add_overflow(bp->max_l2_ctx, bp->max_rx_em_flows,
+ &max_l2_ctx))
+ return -EINVAL;
+ bp->max_l2_ctx = max_l2_ctx;
+ }
+
/* TODO: For now, do not support VMDq/RFS on VFs. */
if (BNXT_PF(bp)) {
if (bp->pf.max_vfs)
--
2.20.1
next prev parent reply other threads:[~2020-03-03 18:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 17:59 [dpdk-dev] [PATCH 0/6] net/bnxt: bounds checking patches Stephen Hemminger
2020-03-03 17:59 ` [dpdk-dev] [PATCH 1/6] eal: add portable way to check for math overflow Stephen Hemminger
2020-03-03 22:28 ` Dmitry Kozlyuk
2020-03-03 17:59 ` [dpdk-dev] [PATCH 2/6] net/bnxt: fix potential data race Stephen Hemminger
2020-03-03 18:13 ` [dpdk-dev] [EXTERNAL] " Christopher Ertl
2020-03-03 18:16 ` Stephen Hemminger
2020-03-03 17:59 ` [dpdk-dev] [PATCH 3/6] net/bnxt: avoid potential out of bounds read Stephen Hemminger
2020-03-03 17:59 ` [dpdk-dev] [PATCH 4/6] net/bnxt: check for integer overflow in buffer sizing Stephen Hemminger
2020-03-03 17:59 ` [dpdk-dev] [PATCH 5/6] net/bnxt: add integer underflow check Stephen Hemminger
2020-03-03 17:59 ` Stephen Hemminger [this message]
2020-03-31 11:47 ` [dpdk-dev] [PATCH 0/6] net/bnxt: bounds checking patches Ferruh Yigit
2020-03-31 17:52 ` Ajit Khaparde
2020-03-31 18:04 ` Stephen Hemminger
2020-10-19 22:28 ` Thomas Monjalon
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=20200303175938.14292-7-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=Christopher.Ertl@microsoft.com \
--cc=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=somnath.kotur@broadcom.com \
/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).