From: Rahul Bhansali <rbhansali@marvell.com>
To: <dev@dpdk.org>, Thomas Monjalon <thomas@monjalon.net>,
Nithin Dabilpuram <ndabilpuram@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
"Sunil Kumar Kori" <skori@marvell.com>,
Satha Rao <skoteshwar@marvell.com>,
"Harman Kalra" <hkalra@marvell.com>,
Rakesh Kudurumalla <rkudurumalla@marvell.com>
Cc: <jerinj@marvell.com>, Alok Mishra <almishra@marvell.com>,
<stable@dpdk.org>
Subject: [PATCH v3 09/20] common/cnxk: fix cnxk xstats names
Date: Mon, 15 Jun 2026 21:54:35 +0530 [thread overview]
Message-ID: <20260615162446.578336-9-rbhansali@marvell.com> (raw)
In-Reply-To: <20260615162446.578336-1-rbhansali@marvell.com>
From: Alok Mishra <almishra@marvell.com>
Prevent out of bounds writes when application provides a smaller
xstat name array. Return required count when xstats_names is NULL
or when the provided buffer is too small,
Fixes: 825bd1d9d8e6 ("common/cnxk: update extra stats for inline device")
Cc: stable@dpdk.org
Signed-off-by: Alok Mishra <almishra@marvell.com>
---
Changes in v3: No change.
Changes in v2: No change.
.mailmap | 1 +
drivers/common/cnxk/roc_nix_stats.c | 46 ++++++++++++++++-------------
2 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/.mailmap b/.mailmap
index 0e0d83e1c6..efcb38b6bd 100644
--- a/.mailmap
+++ b/.mailmap
@@ -80,6 +80,7 @@ Alin Rauta <alin.rauta@intel.com>
Allain Legacy <allain.legacy@windriver.com>
Allen Hubbe <allen.hubbe@amd.com>
Alok Makhariya <alok.makhariya@nxp.com>
+Alok Mishra <almishra@marvell.com>
Alok Prasad <palok@marvell.com>
Alvaro Karsz <alvaro.karsz@solid-run.com>
Alvin Zhang <alvinx.zhang@intel.com>
diff --git a/drivers/common/cnxk/roc_nix_stats.c b/drivers/common/cnxk/roc_nix_stats.c
index 6f241c72de..ec2aca8164 100644
--- a/drivers/common/cnxk/roc_nix_stats.c
+++ b/drivers/common/cnxk/roc_nix_stats.c
@@ -503,46 +503,51 @@ roc_nix_xstats_names_get(struct roc_nix *roc_nix,
struct idev_cfg *idev = idev_get_cfg();
uint64_t i, count = 0;
- PLT_SET_USED(limit);
-
for (i = 0; i < CNXK_NIX_NUM_TX_XSTATS; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_tx_xstats, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_tx_xstats, i);
count++;
}
for (i = 0; i < CNXK_NIX_NUM_RX_XSTATS; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_rx_xstats, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_rx_xstats, i);
count++;
}
if (nix->inb_inl_dev && idev) {
if (idev->nix_inl_dev) {
for (i = 0; i < CNXK_INL_NIX_NUM_RX_XSTATS; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count,
- inl_nix_rx_xstats, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count,
+ inl_nix_rx_xstats, i);
count++;
}
for (i = 0; i < CNXK_INL_NIX_RQ_XSTATS; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count,
- inl_nix_rq_xstats, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count,
+ inl_nix_rq_xstats, i);
count++;
}
for (i = 0; i < PLT_DIM(inl_sw_xstats); i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count, inl_sw_xstats, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count, inl_sw_xstats,
+ i);
count++;
}
}
}
for (i = 0; i < CNXK_NIX_NUM_QUEUE_XSTATS; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_q_xstats, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_q_xstats, i);
count++;
}
if (roc_model_is_cn10k() || roc_model_is_cn20k()) {
for (i = 0; i < CNXK_NIX_NUM_CN10K_RX_XSTATS; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count,
- nix_cn10k_rx_xstats, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_cn10k_rx_xstats, i);
count++;
}
}
@@ -552,30 +557,29 @@ roc_nix_xstats_names_get(struct roc_nix *roc_nix,
if (roc_model_is_cn9k()) {
for (i = 0; i < CNXK_NIX_NUM_RX_XSTATS_CGX; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count,
- nix_rx_xstats_cgx, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_rx_xstats_cgx, i);
count++;
}
for (i = 0; i < CNXK_NIX_NUM_TX_XSTATS_CGX; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count,
- nix_tx_xstats_cgx, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_tx_xstats_cgx, i);
count++;
}
} else {
for (i = 0; i < CNXK_NIX_NUM_RX_XSTATS_RPM; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count,
- nix_rx_xstats_rpm, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_rx_xstats_rpm, i);
count++;
}
for (i = 0; i < CNXK_NIX_NUM_TX_XSTATS_RPM; i++) {
- NIX_XSTATS_NAME_PRINT(xstats_names, count,
- nix_tx_xstats_rpm, i);
+ if (xstats_names && count < limit)
+ NIX_XSTATS_NAME_PRINT(xstats_names, count, nix_tx_xstats_rpm, i);
count++;
}
}
-
return count;
}
--
2.34.1
next prev parent reply other threads:[~2026-06-15 16:26 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 7:32 [PATCH 01/17] net/cnxk: update mbuf next field for multi segment Rahul Bhansali
2026-06-11 7:32 ` [PATCH 02/17] common/cnxk: add API of SA valid for cn20k platform Rahul Bhansali
2026-06-11 7:32 ` [PATCH 03/17] common/cnxk: additional NIX SQ ctx fields prints Rahul Bhansali
2026-06-11 7:32 ` [PATCH 04/17] common/cnxk: update NIX irq handler Rahul Bhansali
2026-06-11 7:32 ` [PATCH 05/17] common/cnxk: configure LSO mask for single segments Rahul Bhansali
2026-06-11 7:33 ` [PATCH 06/17] net/cnxk: reserve memory for lookup mem at probe Rahul Bhansali
2026-06-11 7:33 ` [PATCH 07/17] drivers: add support for devargs skip size Rahul Bhansali
2026-06-11 7:33 ` [PATCH 08/17] net/cnxk: update inbound SA pkind for " Rahul Bhansali
2026-06-11 7:33 ` [PATCH 09/17] common/cnxk: fix cnxk xstats names Rahul Bhansali
2026-06-11 7:33 ` [PATCH 10/17] common/cnxk: fix event type for soft expiry Rahul Bhansali
2026-06-11 7:33 ` [PATCH 11/17] net/cnxk: enable CPT CQ by default for inline IPsec Rahul Bhansali
2026-06-11 7:33 ` [PATCH 12/17] net/cnxk: fix unsigned integer underflow in LSO calculation Rahul Bhansali
2026-06-11 7:33 ` [PATCH 13/17] net/cnxk: derive ethdev from SA for inbound CPT CQ events Rahul Bhansali
2026-06-11 7:33 ` [PATCH 14/17] net/cnxk: fix bitwise operand size mismatch in link mode Rahul Bhansali
2026-06-11 7:33 ` [PATCH 15/17] common/cnxk: add cipher key length check in key set Rahul Bhansali
2026-06-11 7:33 ` [PATCH 16/17] common/cnxk: fix Klocwork static analysis issues Rahul Bhansali
2026-06-11 7:33 ` [PATCH 17/17] common/cnxk: add auth key len check in inbound SA Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 01/22] net/cnxk: update mbuf next field for multi segment Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 02/22] common/cnxk: add API of SA valid for cn20k platform Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 03/22] common/cnxk: additional NIX SQ ctx fields prints Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 04/22] common/cnxk: update NIX irq handler Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 05/22] common/cnxk: configure LSO mask for single segments Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 06/22] net/cnxk: reserve memory for lookup mem at probe Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 07/22] drivers: add support for devargs skip size Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 08/22] net/cnxk: update inbound SA pkind for " Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 09/22] common/cnxk: fix cnxk xstats names Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 10/22] common/cnxk: fix event type for soft expiry Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 11/22] net/cnxk: enable CPT CQ by default for inline IPsec Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 12/22] net/cnxk: fix unsigned integer underflow in LSO calculation Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 13/22] net/cnxk: derive ethdev from SA for inbound CPT CQ events Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 14/22] net/cnxk: fix bitwise operand size mismatch in link mode Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 15/22] common/cnxk: add cipher key length check in key set Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 16/22] common/cnxk: fix Klocwork static analysis issues Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 17/22] common/cnxk: add auth key len check in inbound SA Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 18/22] common/cnxk: add FEC configuration support Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 19/22] net/cnxk: add FEC get set and capability ops Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 20/22] event/cnxk: fix Klocwork static analysis issues Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 21/22] crypto/cnxk: enforce DES/3DES cipher key length Rahul Bhansali
2026-06-11 14:20 ` [PATCH v2 22/22] common/cnxk: fix TM link config selection in debug dump Rahul Bhansali
2026-06-11 15:26 ` [PATCH v2 01/22] net/cnxk: update mbuf next field for multi segment Stephen Hemminger
2026-06-11 17:23 ` [PATCH 01/17] " Stephen Hemminger
2026-06-15 16:24 ` [PATCH v3 01/20] " Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 02/20] common/cnxk: add API of SA valid for cn20k platform Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 03/20] common/cnxk: additional NIX SQ ctx fields prints Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 04/20] common/cnxk: update NIX irq handler Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 05/20] common/cnxk: configure LSO mask for single segments Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 06/20] net/cnxk: reserve memory for lookup mem at probe Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 07/20] drivers: add support for devargs skip size Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 08/20] net/cnxk: update inbound SA pkind for " Rahul Bhansali
2026-06-15 16:24 ` Rahul Bhansali [this message]
2026-06-15 16:24 ` [PATCH v3 10/20] common/cnxk: fix event type for soft expiry Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 11/20] net/cnxk: enable CPT CQ by default for inline IPsec Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 12/20] net/cnxk: fix unsigned integer underflow in LSO calculation Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 13/20] net/cnxk: derive ethdev from SA for inbound CPT CQ events Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 14/20] net/cnxk: fix bitwise operand size mismatch in link mode Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 15/20] common/cnxk: add cipher key length check in key set Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 16/20] common/cnxk: fix Klocwork static analysis issues Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 17/20] common/cnxk: add auth key len check in inbound SA Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 18/20] event/cnxk: fix Klocwork static analysis issues Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 19/20] crypto/cnxk: enforce DES/3DES cipher key length Rahul Bhansali
2026-06-15 16:24 ` [PATCH v3 20/20] common/cnxk: fix TM link config selection in debug dump Rahul Bhansali
2026-06-22 12:13 ` [PATCH v3 01/20] net/cnxk: update mbuf next field for multi segment Jerin Jacob
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=20260615162446.578336-9-rbhansali@marvell.com \
--to=rbhansali@marvell.com \
--cc=almishra@marvell.com \
--cc=dev@dpdk.org \
--cc=hkalra@marvell.com \
--cc=jerinj@marvell.com \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=rkudurumalla@marvell.com \
--cc=skori@marvell.com \
--cc=skoteshwar@marvell.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
/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