DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jie Hai <haijie1@huawei.com>
To: <dev@dpdk.org>, <thomas@monjalon.net>, <ferruh.yigit@amd.com>,
	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>,
	Jerin Jacob <jerinj@marvell.com>,
	Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Cc: <lihuisong@huawei.com>, <fengchengwen@huawei.com>,
	<haijie1@huawei.com>, <huangdengdui@huawei.com>
Subject: [PATCH v5 16/25] common/cnxk: replace strtok with reentrant version
Date: Fri, 8 Nov 2024 19:03:55 +0800	[thread overview]
Message-ID: <20241108110404.18317-17-haijie1@huawei.com> (raw)
In-Reply-To: <20241108110404.18317-1-haijie1@huawei.com>

Multiple threads calling the same function may cause condition
race issues, which often leads to abnormal behavior and can cause
more serious vulnerabilities such as abnormal termination, denial
of service, and compromised data integrity.

The strtok() is non-reentrant, it is better to replace it with a
reentrant version.

Fixes: af75aac78978 ("common/cnxk: support telemetry for NIX")
Cc: stable@dpdk.org

Signed-off-by: Jie Hai <haijie1@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/cnxk/cnxk_telemetry_nix.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c
index abeefafe1e19..a0b587c97c63 100644
--- a/drivers/common/cnxk/cnxk_telemetry_nix.c
+++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
@@ -3,6 +3,7 @@
  */
 
 #include <ctype.h>
+#include <rte_os_shim.h>
 #include "cnxk_telemetry.h"
 #include "roc_api.h"
 #include "roc_priv.h"
@@ -1015,7 +1016,7 @@ cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
 			   struct plt_tel_data *d)
 {
 	struct nix_tel_node *node;
-	char *name, *param;
+	char *name, *param, *sp = NULL;
 	char buf[1024];
 	int rc = -1;
 
@@ -1023,11 +1024,11 @@ cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
 		goto exit;
 
 	plt_strlcpy(buf, params, PCI_PRI_STR_SIZE + 1);
-	name = strtok(buf, ",");
+	name = strtok_r(buf, ",", &sp);
 	if (name == NULL)
 		goto exit;
 
-	param = strtok(NULL, "\0");
+	param = strtok_r(NULL, "\0", &sp);
 
 	node = nix_tel_node_get_by_pcidev_name(name);
 	if (!node)
@@ -1036,7 +1037,7 @@ cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
 	plt_tel_data_start_dict(d);
 
 	if (strstr(cmd, "rq")) {
-		char *tok = strtok(param, ",");
+		char *tok = strtok_r(param, ",", &sp);
 		int rq;
 
 		if (!tok)
@@ -1052,7 +1053,7 @@ cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
 			rc = cnxk_tel_nix_rq(node->rqs[rq], d);
 
 	} else if (strstr(cmd, "cq")) {
-		char *tok = strtok(param, ",");
+		char *tok = strtok_r(param, ",", &sp);
 		int cq;
 
 		if (!tok)
@@ -1068,7 +1069,7 @@ cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
 			rc = cnxk_tel_nix_cq(node->cqs[cq], d);
 
 	} else if (strstr(cmd, "sq")) {
-		char *tok = strtok(param, ",");
+		char *tok = strtok_r(param, ",", &sp);
 		int sq;
 
 		if (!tok)
-- 
2.22.0


  parent reply	other threads:[~2024-11-08 11:17 UTC|newest]

Thread overview: 152+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 10:45 [PATCH 00/21] replace strtok with strtok_r Jie Hai
2023-11-13 10:45 ` [PATCH 01/21] app/graph: " Jie Hai
2023-11-13 10:45 ` [PATCH 02/21] app/test-bbdev: " Jie Hai
2023-11-13 10:45 ` [PATCH 03/21] app/test-compress-perf: " Jie Hai
2023-11-13 10:45 ` [PATCH 04/21] app/test-crypto-perf: " Jie Hai
2023-11-13 10:45 ` [PATCH 05/21] app/test-dma-perf: " Jie Hai
2023-11-13 10:45 ` [PATCH 06/21] app/test-fib: " Jie Hai
2023-11-13 10:45 ` [PATCH 07/21] app/dpdk-test-flow-perf: " Jie Hai
2023-11-13 10:45 ` [PATCH 08/21] app/test-mldev: " Jie Hai
2023-11-13 10:45 ` [PATCH 09/21] lib/dmadev: " Jie Hai
2023-11-13 10:45 ` [PATCH 10/21] lib/eal: " Jie Hai
2023-11-13 16:27   ` Stephen Hemminger
2023-11-14  1:05     ` fengchengwen
2023-11-14  1:08       ` Stephen Hemminger
2023-11-13 10:45 ` [PATCH 11/21] lib/ethdev: " Jie Hai
2023-11-13 10:45 ` [PATCH 12/21] lib/eventdev: " Jie Hai
2023-11-13 10:45 ` [PATCH 13/21] lib/telemetry: " Jie Hai
2023-11-13 10:45 ` [PATCH 14/21] " Jie Hai
2023-11-13 10:45 ` [PATCH 15/21] bus/fslmc: " Jie Hai
2023-11-15  2:41   ` Sachin Saxena
2023-11-13 10:45 ` [PATCH 16/21] common/cnxk: " Jie Hai
2023-11-13 10:45 ` [PATCH 17/21] event/cnxk: " Jie Hai
2023-11-13 10:45 ` [PATCH 18/21] net/ark: " Jie Hai
2023-11-13 10:45 ` [PATCH 19/21] raw/cnxk_gpio: " Jie Hai
2023-11-13 10:45 ` [PATCH 20/21] examples/l2fwd-crypto: " Jie Hai
2023-11-13 10:45 ` [PATCH 21/21] examples/vhost: " Jie Hai
2023-11-13 16:26   ` Stephen Hemminger
2023-11-13 11:00 ` [PATCH 00/21] " Thomas Monjalon
2023-11-13 11:33 ` fengchengwen
2023-11-13 16:25 ` Stephen Hemminger
2023-11-13 17:09 ` Tyler Retzlaff
2023-11-14 12:50   ` Jie Hai
2023-11-14 17:32     ` Tyler Retzlaff
2023-11-14 17:34       ` Tyler Retzlaff
2023-11-14 17:49         ` Tyler Retzlaff
2023-11-15  3:02           ` fengchengwen
2023-11-15 11:27             ` Morten Brørup
2023-11-15 15:08               ` Stephen Hemminger
2023-11-21  3:32                 ` Jie Hai
2024-02-01 11:13                   ` David Marchand
2023-11-14  8:41 ` [PATCH v2 00/22] replace strtok with reentrant version Jie Hai
2023-11-14  8:41   ` [PATCH v2 01/22] app/graph: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 02/22] app/bbdev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 03/22] app/compress-perf: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 04/22] app/crypto-perf: " Jie Hai
2024-01-11 17:10     ` Power, Ciara
2023-11-14  8:41   ` [PATCH v2 05/22] app/dma-perf: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 06/22] app/test-fib: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 07/22] app/flow-perf: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 08/22] app/test-mldev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 09/22] dmadev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 10/22] eal: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 11/22] ethdev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 12/22] eventdev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 13/22] security: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 14/22] telemetry: " Jie Hai
2024-01-11 17:13     ` Power, Ciara
2023-11-14  8:41   ` [PATCH v2 15/22] bus/fslmc: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 16/22] common/cnxk: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 17/22] event/cnxk: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 18/22] net/ark: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 19/22] raw/cnxk_gpio: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 20/22] examples/l2fwd-crypto: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 21/22] examples/vhost: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 22/22] devtools: check for some reentrant function Jie Hai
2023-11-14 10:59 ` [PATCH v3 00/22] replace strtok with reentrant version Jie Hai
2023-11-14 10:59   ` [PATCH v3 01/22] app/graph: " Jie Hai
2023-11-15  0:07     ` Stephen Hemminger
2023-11-14 10:59   ` [PATCH v3 02/22] app/bbdev: " Jie Hai
2023-11-15  0:09     ` Stephen Hemminger
2023-11-14 10:59   ` [PATCH v3 03/22] app/compress-perf: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 04/22] app/crypto-perf: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 05/22] app/dma-perf: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 06/22] app/test-fib: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 07/22] app/flow-perf: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 08/22] app/test-mldev: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 09/22] dmadev: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 10/22] eal: " Jie Hai
2023-11-15  7:17     ` [EXT] " Amit Prakash Shukla
2023-11-14 10:59   ` [PATCH v3 11/22] ethdev: " Jie Hai
2023-12-16 10:01     ` Andrew Rybchenko
2023-11-14 10:59   ` [PATCH v3 12/22] eventdev: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 13/22] security: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 14/22] telemetry: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 15/22] bus/fslmc: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 16/22] common/cnxk: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 17/22] event/cnxk: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 18/22] net/ark: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 19/22] raw/cnxk_gpio: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 20/22] examples/l2fwd-crypto: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 21/22] examples/vhost: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 22/22] devtools: check for some reentrant function Jie Hai
2024-10-22 10:46   ` [PATCH v3 00/22] replace strtok with reentrant version Morten Brørup
2024-10-26 10:14 ` [PATCH v4 00/13] " Jie Hai
2024-10-26 10:14   ` [PATCH v4 01/13] dmadev: " Jie Hai
2024-10-27  3:00     ` Stephen Hemminger
2024-10-26 10:14   ` [PATCH v4 02/13] eal: " Jie Hai
2024-10-27  3:00     ` Stephen Hemminger
2024-10-28 13:04       ` fengchengwen
2024-10-28 15:31         ` Stephen Hemminger
2024-10-29  0:56           ` fengchengwen
2024-10-29  2:51             ` Stephen Hemminger
2024-11-07 12:29               ` Jie Hai
2024-10-26 10:14   ` [PATCH v4 03/13] ethdev: " Jie Hai
2024-10-27  3:01     ` Stephen Hemminger
2024-10-26 10:14   ` [PATCH v4 04/13] eventdev: " Jie Hai
2024-10-27  3:02     ` Stephen Hemminger
2024-10-26 10:14   ` [PATCH v4 05/13] security: " Jie Hai
2024-10-27  3:03     ` Stephen Hemminger
2024-10-26 10:14   ` [PATCH v4 06/13] telemetry: " Jie Hai
2024-10-27  3:05     ` Stephen Hemminger
2024-10-26 10:14   ` [PATCH v4 07/13] bus/fslmc: " Jie Hai
2024-10-27  3:06     ` Stephen Hemminger
2024-10-26 10:14   ` [PATCH v4 08/13] common/cnxk: " Jie Hai
2024-10-27  3:07     ` Stephen Hemminger
2024-10-26 10:14   ` [PATCH v4 09/13] event/cnxk: " Jie Hai
2024-10-27  3:08     ` Stephen Hemminger
2024-10-26 10:14   ` [PATCH v4 10/13] net/ark: " Jie Hai
2024-10-26 10:14   ` [PATCH v4 11/13] raw/cnxk_gpio: " Jie Hai
2024-10-26 10:14   ` [PATCH v4 12/13] net/cnxk: " Jie Hai
2024-10-26 10:14   ` [PATCH v4 13/13] devtools: check for some reentrant function Jie Hai
2024-10-27  3:11     ` Stephen Hemminger
2024-11-05 16:28   ` [PATCH v4 00/13] replace strtok with reentrant version Stephen Hemminger
2024-11-06 20:11   ` David Marchand
2024-11-07 12:23     ` Jie Hai
2024-11-08 11:03 ` [PATCH v5 00/25] Jie Hai
2024-11-08 11:03   ` [PATCH v5 01/25] app/graph: replace strtok with reentrant version Jie Hai
2024-11-08 11:03   ` [PATCH v5 02/25] app/bbdev: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 03/25] app/compress-perf: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 04/25] app/crypto-perf: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 05/25] app/dma-perf: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 06/25] app/flow-perf: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 07/25] app/test-mldev: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 08/25] app/test-fib: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 09/25] dmadev: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 10/25] eal: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 11/25] ethdev: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 12/25] eventdev: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 13/25] security: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 14/25] telemetry: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 15/25] bus/fslmc: " Jie Hai
2024-11-08 11:03   ` Jie Hai [this message]
2024-11-08 11:03   ` [PATCH v5 17/25] event/cnxk: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 18/25] net/ark: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 19/25] raw/cnxk_gpio: " Jie Hai
2024-11-08 11:03   ` [PATCH v5 20/25] net/cnxk: " Jie Hai
2024-11-08 11:04   ` [PATCH v5 21/25] common/qat: " Jie Hai
2024-11-08 11:04   ` [PATCH v5 22/25] net/mlx5: " Jie Hai
2024-11-08 11:04   ` [PATCH v5 23/25] examples/l2fwd-crypto: " Jie Hai
2024-11-08 11:04   ` [PATCH v5 24/25] examples/vhost: " Jie Hai
2024-11-08 11:04   ` [PATCH v5 25/25] devtools: check for some reentrant function Jie Hai
2024-11-08 14:39   ` [PATCH v5 00/25] David Marchand

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=20241108110404.18317-17-haijie1@huawei.com \
    --to=haijie1@huawei.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=ferruh.yigit@amd.com \
    --cc=gmuthukrishn@marvell.com \
    --cc=hkalra@marvell.com \
    --cc=huangdengdui@huawei.com \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=lihuisong@huawei.com \
    --cc=ndabilpuram@marvell.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.com \
    --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;
as well as URLs for NNTP newsgroup(s).