From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Fabio Pricoco <fabio.pricoco@intel.com>,
stable@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH 2/9] net/ice/base: add bounds check
Date: Fri, 11 Oct 2024 17:44:52 +0100 [thread overview]
Message-ID: <20241011164459.1987538-3-bruce.richardson@intel.com> (raw)
In-Reply-To: <20241011164459.1987538-1-bruce.richardson@intel.com>
From: Fabio Pricoco <fabio.pricoco@intel.com>
Refactor while loop to add a check that the values read are in the
correct range.
Fixes: 6c1f26be50a2 ("net/ice/base: add control queue information")
Cc: stable@dpdk.org
Signed-off-by: Fabio Pricoco <fabio.pricoco@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/ice/base/ice_controlq.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ice/base/ice_controlq.c b/drivers/net/ice/base/ice_controlq.c
index af27dc8542..b210495827 100644
--- a/drivers/net/ice/base/ice_controlq.c
+++ b/drivers/net/ice/base/ice_controlq.c
@@ -839,16 +839,35 @@ static u16 ice_clean_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
struct ice_ctl_q_ring *sq = &cq->sq;
u16 ntc = sq->next_to_clean;
struct ice_aq_desc *desc;
+ u32 head;
desc = ICE_CTL_Q_DESC(*sq, ntc);
- while (rd32(hw, cq->sq.head) != ntc) {
- ice_debug(hw, ICE_DBG_AQ_MSG, "ntc %d head %d.\n", ntc, rd32(hw, cq->sq.head));
+ head = rd32(hw, sq->head);
+ if (head >= sq->count) {
+ ice_debug(hw, ICE_DBG_AQ_MSG,
+ "Read head value (%d) exceeds allowed range.\n",
+ head);
+ return 0;
+ }
+
+ while (head != ntc) {
+ ice_debug(hw, ICE_DBG_AQ_MSG,
+ "ntc %d head %d.\n",
+ ntc, head);
ice_memset(desc, 0, sizeof(*desc), ICE_DMA_MEM);
ntc++;
if (ntc == sq->count)
ntc = 0;
desc = ICE_CTL_Q_DESC(*sq, ntc);
+
+ head = rd32(hw, sq->head);
+ if (head >= sq->count) {
+ ice_debug(hw, ICE_DBG_AQ_MSG,
+ "Read head value (%d) exceeds allowed range.\n",
+ head);
+ return 0;
+ }
}
sq->next_to_clean = ntc;
--
2.43.0
next prev parent reply other threads:[~2024-10-11 16:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241011164459.1987538-1-bruce.richardson@intel.com>
2024-10-11 16:44 ` [PATCH 1/9] net/ice/base: re-enable bypass mode for E822 Bruce Richardson
2024-10-11 16:44 ` Bruce Richardson [this message]
2024-10-11 16:44 ` [PATCH 3/9] net/ice/base: fix VLAN replay after reset Bruce Richardson
[not found] ` <20241014110250.2314727-1-bruce.richardson@intel.com>
2024-10-14 11:02 ` [PATCH v2 01/10] net/ice/base: re-enable bypass mode for E822 Bruce Richardson
2024-10-14 11:02 ` [PATCH v2 02/10] net/ice/base: add bounds check Bruce Richardson
2024-10-14 11:02 ` [PATCH v2 03/10] net/ice/base: fix VLAN replay after reset Bruce Richardson
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=20241011164459.1987538-3-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=fabio.pricoco@intel.com \
--cc=stable@dpdk.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).