From: fengchengwen <fengchengwen@huawei.com>
To: Tyler Retzlaff <roretzla@linux.microsoft.com>,
Jie Hai <haijie1@huawei.com>
Cc: <dev@dpdk.org>, <lihuisong@huawei.com>
Subject: Re: [PATCH 00/21] replace strtok with strtok_r
Date: Wed, 15 Nov 2023 11:02:46 +0800 [thread overview]
Message-ID: <1e636881-c543-b23b-4f75-499b175db058@huawei.com> (raw)
In-Reply-To: <20231114174916.GD23774@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
On 2023/11/15 1:49, Tyler Retzlaff wrote:
> On Tue, Nov 14, 2023 at 09:34:33AM -0800, Tyler Retzlaff wrote:
>> On Tue, Nov 14, 2023 at 09:32:48AM -0800, Tyler Retzlaff wrote:
>>> On Tue, Nov 14, 2023 at 08:50:17PM +0800, Jie Hai wrote:
>>>> On 2023/11/14 1:09, Tyler Retzlaff wrote:
>>>>> On Mon, Nov 13, 2023 at 06:45:29PM +0800, Jie Hai wrote:
>>>>>> 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 function.
>>>>>
>>>>> could you please use strtok_s instead of strtok_r the former is part of
>>>>> the C11 standard the latter is not.
>>>>>
>>>>> thanks!
>>>>>
>>>> Hi, Tyler Retzlaff
>>>>
>>>> Thanks for your comment.
>>>>
>>>> For the use of strtok_s, I have consulted some documents, see
>>>> https://en.cppreference.com/w/c/string/byte/strtok
>>>> It says
>>>> "As with all bounds-checked functions, strtok_s only guaranteed to be
>>>> available if __STDC_LIB_EXT1__ is defined by the implementation and if
>>>> the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before
>>>> including <string.h>.
>>>> "
>>>>
>>>> I use strtok_s with "#ifdef __STDC_LIB_EXT1__ ... #endif" around and
>>>> compiled
>>>> locally and found that __STDC_LIB_EXT1__ was not defined, so the related
>>>> code was not called. I'm afraid there's a problem with this
>>>> modification.
>>>>
>>>> Am I using strtok_s wrong?
>>>
>>> no i overlooked that it is optional my fault sorry.
>>>
>>> since there is no portable strtok_r i'm going to have to agree with others
>>> that only places where you actually need reentrant strtok be converted to
>>> strtok_r.
>>>
>>> for windows i think we'll either need to introduce an abstracted strtok_r
>>> name for portability or something in the rte_ namespace (dependent on
>>> what other revieweres would prefer)
>>
>> just as a follow up here maybe it would be optimal if we could use
>> strtok_s *if* we test that the toolchain makes it available and if not
>> provide a mapping of strtok_s -> strtok_r.
>
> just a final follow up, i can see that we already have a rte_strerror
> here to do the replace with reentrant dance. it is probably good to
> follow the already established pattern for this and have a rte_strtok.
+1 for have rte_strtok which could cover different platform.
>
> what do others think?
>
>>>
>>> thanks!
>>>
>>>>
>>>> Thanks,
>>>> Jie Hai
>>>>>>
>>>>>> Jie Hai (21):
>>>>>> app/graph: replace strtok with strtok_r
>>>>>> app/test-bbdev: replace strtok with strtok_r
>>>>>> app/test-compress-perf: replace strtok with strtok_r
>>>>>> app/test-crypto-perf: replace strtok with strtok_r
>>>>>> app/test-dma-perf: replace strtok with strtok_r
>>>>>> app/test-fib: replace strtok with strtok_r
>>>>>> app/dpdk-test-flow-perf: replace strtok with strtok_r
>>>>>> app/test-mldev: replace strtok with strtok_r
>>>>>> lib/dmadev: replace strtok with strtok_r
>>>>>> lib/eal: replace strtok with strtok_r
>>>>>> lib/ethdev: replace strtok with strtok_r
>>>>>> lib/eventdev: replace strtok with strtok_r
>>>>>> lib/telemetry: replace strtok with strtok_r
>>>>>> lib/telemetry: replace strtok with strtok_r
>>>>>> bus/fslmc: replace strtok with strtok_r
>>>>>> common/cnxk: replace strtok with strtok_r
>>>>>> event/cnxk: replace strtok with strtok_r
>>>>>> net/ark: replace strtok with strtok_r
>>>>>> raw/cnxk_gpio: replace strtok with strtok_r
>>>>>> examples/l2fwd-crypto: replace strtok with strtok_r
>>>>>> examples/vhost: replace strtok with strtok_r
>>>>>>
>>>>>> app/graph/graph.c | 5 ++-
>>>>>> app/graph/utils.c | 15 +++++---
>>>>>> app/test-bbdev/test_bbdev_vector.c | 25 +++++++-----
>>>>>> .../comp_perf_options_parse.c | 16 ++++----
>>>>>> app/test-crypto-perf/cperf_options_parsing.c | 16 ++++----
>>>>>> .../cperf_test_vector_parsing.c | 10 +++--
>>>>>> app/test-dma-perf/main.c | 13 ++++---
>>>>>> app/test-fib/main.c | 10 ++---
>>>>>> app/test-flow-perf/main.c | 22 ++++++-----
>>>>>> app/test-mldev/ml_options.c | 18 ++++-----
>>>>>> drivers/bus/fslmc/fslmc_bus.c | 5 ++-
>>>>>> drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +-
>>>>>> drivers/common/cnxk/cnxk_telemetry_nix.c | 12 +++---
>>>>>> drivers/event/cnxk/cnxk_eventdev.c | 10 +++--
>>>>>> drivers/event/cnxk/cnxk_tim_evdev.c | 11 +++---
>>>>>> drivers/net/ark/ark_pktchkr.c | 10 ++---
>>>>>> drivers/net/ark/ark_pktgen.c | 10 ++---
>>>>>> drivers/raw/cnxk_gpio/cnxk_gpio.c | 6 +--
>>>>>> examples/l2fwd-crypto/main.c | 6 +--
>>>>>> examples/vhost/main.c | 3 +-
>>>>>> lib/dmadev/rte_dmadev.c | 4 +-
>>>>>> lib/eal/common/eal_common_memory.c | 8 ++--
>>>>>> lib/ethdev/rte_ethdev_telemetry.c | 6 ++-
>>>>>> lib/eventdev/rte_event_eth_rx_adapter.c | 38 +++++++++----------
>>>>>> lib/eventdev/rte_eventdev.c | 18 ++++-----
>>>>>> lib/security/rte_security.c | 3 +-
>>>>>> lib/telemetry/telemetry.c | 5 ++-
>>>>>> 27 files changed, 169 insertions(+), 140 deletions(-)
>>>>>>
>>>>>> --
>>>>>> 2.30.0
>>>>> .
> .
>
next prev parent reply other threads:[~2023-11-15 3:02 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-13 10:45 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 [this message]
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
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=1e636881-c543-b23b-4f75-499b175db058@huawei.com \
--to=fengchengwen@huawei.com \
--cc=dev@dpdk.org \
--cc=haijie1@huawei.com \
--cc=lihuisong@huawei.com \
--cc=roretzla@linux.microsoft.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).