* [PATCH 0/5] fix segment fault when parse args
@ 2023-03-14 12:48 Chengwen Feng
2023-03-14 12:48 ` [PATCH 1/5] app/pdump: " Chengwen Feng
` (11 more replies)
0 siblings, 12 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-14 12:48 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
It may leads to segment fault when parse args with 'only key', this
patchset fixes rest of them.
Chengwen Feng (5):
app/pdump: fix segment fault when parse args
net/memif: fix segment fault when parse devargs
net/pcap: fix segment fault when parse devargs
net/ring: fix segment fault when parse devargs
net/sfc: fix segment fault when parse devargs
app/pdump/main.c | 12 ++++++++++++
drivers/net/memif/rte_eth_memif.c | 30 ++++++++++++++++++++++++++++++
drivers/net/pcap/pcap_ethdev.c | 13 +++++++++++--
drivers/net/ring/rte_eth_ring.c | 6 ++++++
drivers/net/sfc/sfc.c | 3 +++
drivers/net/sfc/sfc_ev.c | 3 +++
drivers/net/sfc/sfc_kvargs.c | 6 ++++++
7 files changed, 71 insertions(+), 2 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH 1/5] app/pdump: fix segment fault when parse args
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
@ 2023-03-14 12:48 ` Chengwen Feng
2023-03-16 17:34 ` Ferruh Yigit
2023-03-14 12:48 ` [PATCH 2/5] net/memif: fix segment fault when parse devargs Chengwen Feng
` (10 subsequent siblings)
11 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-14 12:48 UTC (permalink / raw)
To: thomas, ferruh.yigit, Reshma Pattan, Stephen Hemminger; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse --pdump args with 'only keys'
(e.g. 'port,queue=*').
Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
app/pdump/main.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/app/pdump/main.c b/app/pdump/main.c
index c6cf9d9c87..d286952483 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -170,6 +170,9 @@ parse_device_id(const char *key __rte_unused, const char *value,
{
struct pdump_tuples *pt = extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
pt->device_id = strdup(value);
pt->dump_by_type = DEVICE_ID;
@@ -182,6 +185,9 @@ parse_queue(const char *key __rte_unused, const char *value, void *extra_args)
unsigned long n;
struct pdump_tuples *pt = extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
if (!strcmp(value, "*"))
pt->queue = RTE_PDUMP_ALL_QUEUES;
else {
@@ -197,6 +203,9 @@ parse_rxtxdev(const char *key, const char *value, void *extra_args)
struct pdump_tuples *pt = extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
if (!strcmp(key, PDUMP_RX_DEV_ARG)) {
strlcpy(pt->rx_dev, value, sizeof(pt->rx_dev));
/* identify the tx stream type for pcap vdev */
@@ -220,6 +229,9 @@ parse_uint_value(const char *key, const char *value, void *extra_args)
char *end;
int ret = 0;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
errno = 0;
v = extra_args;
t = strtoul(value, &end, 10);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH 2/5] net/memif: fix segment fault when parse devargs
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
2023-03-14 12:48 ` [PATCH 1/5] app/pdump: " Chengwen Feng
@ 2023-03-14 12:48 ` Chengwen Feng
2023-03-16 18:20 ` Ferruh Yigit
2023-03-14 12:48 ` [PATCH 3/5] net/pcap: " Chengwen Feng
` (9 subsequent siblings)
11 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-14 12:48 UTC (permalink / raw)
To: thomas, ferruh.yigit, Jakub Grajciar, Ferruh Yigit; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
Fixes: 2f865ed07bb6 ("net/memif: use abstract socket address")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/memif/rte_eth_memif.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index 6a8ff5b4eb..c6674ddf25 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1720,6 +1720,9 @@ memif_set_role(const char *key __rte_unused, const char *value,
{
enum memif_role_t *role = (enum memif_role_t *)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
if (strstr(value, "server") != NULL) {
*role = MEMIF_ROLE_SERVER;
} else if (strstr(value, "client") != NULL) {
@@ -1742,6 +1745,9 @@ memif_set_zc(const char *key __rte_unused, const char *value, void *extra_args)
{
uint32_t *flags = (uint32_t *)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
if (strstr(value, "yes") != NULL) {
if (!rte_mcfg_get_single_file_segments()) {
MIF_LOG(ERR, "Zero-copy doesn't support multi-file segments.");
@@ -1762,6 +1768,9 @@ memif_set_id(const char *key __rte_unused, const char *value, void *extra_args)
{
memif_interface_id_t *id = (memif_interface_id_t *)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
/* even if parsing fails, 0 is a valid id */
*id = strtoul(value, NULL, 10);
return 0;
@@ -1773,6 +1782,9 @@ memif_set_bs(const char *key __rte_unused, const char *value, void *extra_args)
unsigned long tmp;
uint16_t *pkt_buffer_size = (uint16_t *)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
tmp = strtoul(value, NULL, 10);
if (tmp == 0 || tmp > 0xFFFF) {
MIF_LOG(ERR, "Invalid buffer size: %s.", value);
@@ -1789,6 +1801,9 @@ memif_set_rs(const char *key __rte_unused, const char *value, void *extra_args)
memif_log2_ring_size_t *log2_ring_size =
(memif_log2_ring_size_t *)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
tmp = strtoul(value, NULL, 10);
if (tmp == 0 || tmp > ETH_MEMIF_MAX_LOG2_RING_SIZE) {
MIF_LOG(ERR, "Invalid ring size: %s (max %u).",
@@ -1840,6 +1855,9 @@ memif_set_socket_filename(const char *key __rte_unused, const char *value,
{
const char **socket_filename = (const char **)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
*socket_filename = value;
return 0;
}
@@ -1849,6 +1867,9 @@ memif_set_is_socket_abstract(const char *key __rte_unused, const char *value, vo
{
uint32_t *flags = (uint32_t *)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
if (strstr(value, "yes") != NULL) {
*flags |= ETH_MEMIF_FLAG_SOCKET_ABSTRACT;
} else if (strstr(value, "no") != NULL) {
@@ -1870,6 +1891,9 @@ memif_set_owner(const char *key, const char *value, void *extra_args)
char *end = NULL;
uint32_t *id = (uint32_t *)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
val = strtoul(value, &end, 10);
if (*value == '\0' || *end != '\0') {
MIF_LOG(ERR, "Failed to parse %s: %s.", key, value);
@@ -1889,6 +1913,9 @@ memif_set_mac(const char *key __rte_unused, const char *value, void *extra_args)
{
struct rte_ether_addr *ether_addr = (struct rte_ether_addr *)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
if (rte_ether_unformat_addr(value, ether_addr) < 0)
MIF_LOG(WARNING, "Failed to parse mac '%s'.", value);
return 0;
@@ -1899,6 +1926,9 @@ memif_set_secret(const char *key __rte_unused, const char *value, void *extra_ar
{
const char **secret = (const char **)extra_args;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
*secret = value;
return 0;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH 3/5] net/pcap: fix segment fault when parse devargs
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
2023-03-14 12:48 ` [PATCH 1/5] app/pdump: " Chengwen Feng
2023-03-14 12:48 ` [PATCH 2/5] net/memif: fix segment fault when parse devargs Chengwen Feng
@ 2023-03-14 12:48 ` Chengwen Feng
2023-03-16 18:20 ` Ferruh Yigit
2023-03-14 12:48 ` [PATCH 4/5] net/ring: " Chengwen Feng
` (8 subsequent siblings)
11 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-14 12:48 UTC (permalink / raw)
To: thomas, ferruh.yigit, Ferruh Yigit, Ido Goshen,
Juhamatti Kuusisaari, Cian Ferriter
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 4c173302c307 ("pcap: add new driver")
Fixes: 53bf48403409 ("net/pcap: capture only ingress packets from Rx iface")
Fixes: c9507cd0cada ("net/pcap: support physical interface MAC address")
Fixes: a3f5252e5cbd ("net/pcap: enable infinitely Rx a pcap file")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/pcap/pcap_ethdev.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index bfec085045..3fa121c521 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -1034,6 +1034,9 @@ open_rx_pcap(const char *key, const char *value, void *extra_args)
struct pmd_devargs *rx = extra_args;
pcap_t *pcap = NULL;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
if (open_single_rx_pcap(pcap_filename, &pcap) < 0)
return -1;
@@ -1056,6 +1059,9 @@ open_tx_pcap(const char *key, const char *value, void *extra_args)
struct pmd_devargs *dumpers = extra_args;
pcap_dumper_t *dumper;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
if (open_single_tx_pcap(pcap_filename, &dumper) < 0)
return -1;
@@ -1077,6 +1083,9 @@ open_rx_tx_iface(const char *key, const char *value, void *extra_args)
struct pmd_devargs *tx = extra_args;
pcap_t *pcap = NULL;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
if (open_single_iface(iface, &pcap) < 0)
return -1;
@@ -1163,7 +1172,7 @@ static int
select_phy_mac(const char *key __rte_unused, const char *value,
void *extra_args)
{
- if (extra_args) {
+ if (value != NULL && extra_args != NULL) {
const int phy_mac = atoi(value);
int *enable_phy_mac = extra_args;
@@ -1177,7 +1186,7 @@ static int
get_infinite_rx_arg(const char *key __rte_unused,
const char *value, void *extra_args)
{
- if (extra_args) {
+ if (value != NULL && extra_args != NULL) {
const int infinite_rx = atoi(value);
int *enable_infinite_rx = extra_args;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH 4/5] net/ring: fix segment fault when parse devargs
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
` (2 preceding siblings ...)
2023-03-14 12:48 ` [PATCH 3/5] net/pcap: " Chengwen Feng
@ 2023-03-14 12:48 ` Chengwen Feng
2023-03-14 12:48 ` [PATCH 5/5] net/sfc: " Chengwen Feng
` (7 subsequent siblings)
11 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-14 12:48 UTC (permalink / raw)
To: thomas, ferruh.yigit, Bruce Richardson, Neil Horman, Ferruh Yigit; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 61934c0956d4 ("ring: convert to use of PMD_REGISTER_DRIVER and fix linking")
Fixes: 96cb19521147 ("net/ring: use EAL APIs in PMD specific API")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/ring/rte_eth_ring.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index e8bc9b6271..4edff83531 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -562,6 +562,9 @@ static int parse_kvlist(const char *key __rte_unused,
char *node;
char *end;
+ if (value == NULL || data == NULL)
+ return -EINVAL;
+
name = strdup(value);
ret = -EINVAL;
@@ -630,6 +633,9 @@ parse_internal_args(const char *key __rte_unused, const char *value,
void *args;
int ret, n;
+ if (value == NULL)
+ return -EINVAL;
+
/* make sure 'value' is valid pointer length */
if (strnlen(value, ETH_RING_INTERNAL_ARG_MAX_LEN) >=
ETH_RING_INTERNAL_ARG_MAX_LEN) {
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH 5/5] net/sfc: fix segment fault when parse devargs
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
` (3 preceding siblings ...)
2023-03-14 12:48 ` [PATCH 4/5] net/ring: " Chengwen Feng
@ 2023-03-14 12:48 ` Chengwen Feng
2023-03-16 18:20 ` Ferruh Yigit
2023-03-16 18:18 ` [PATCH 0/5] fix segment fault when parse args Ferruh Yigit
` (6 subsequent siblings)
11 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-14 12:48 UTC (permalink / raw)
To: thomas, ferruh.yigit, Andrew Rybchenko, Roman Zhukov, Andrew Lee,
Robert Stonehouse, Ferruh Yigit, Andy Moreton
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 9e7fc8b8f3be ("net/sfc: add device parameter to choose FW variant")
Fixes: c22d3c508e0c ("net/sfc: support parameter to choose performance profile")
Fixes: 63d588ff2692 ("net/sfc: libefx-based driver stub")
Fixes: df1bfde4ff0d ("net/sfc: factor out libefx-based Rx datapath")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/sfc/sfc.c | 3 +++
drivers/net/sfc/sfc_ev.c | 3 +++
drivers/net/sfc/sfc_kvargs.c | 6 ++++++
3 files changed, 12 insertions(+)
diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 22753e3417..c5271347a4 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -1108,6 +1108,9 @@ sfc_kvarg_fv_variant_handler(__rte_unused const char *key,
{
uint32_t *value = opaque;
+ if (value_str == NULL || opaque == NULL)
+ return -EINVAL;
+
if (strcasecmp(value_str, SFC_KVARG_FW_VARIANT_DONT_CARE) == 0)
*value = EFX_FW_VARIANT_DONT_CARE;
else if (strcasecmp(value_str, SFC_KVARG_FW_VARIANT_FULL_FEATURED) == 0)
diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c
index f949abbfc3..4cd900bd76 100644
--- a/drivers/net/sfc/sfc_ev.c
+++ b/drivers/net/sfc/sfc_ev.c
@@ -955,6 +955,9 @@ sfc_kvarg_perf_profile_handler(__rte_unused const char *key,
{
uint32_t *value = opaque;
+ if (value_str == NULL || opaque == NULL)
+ return -EINVAL;
+
if (strcasecmp(value_str, SFC_KVARG_PERF_PROFILE_THROUGHPUT) == 0)
*value = EFX_EVQ_FLAGS_TYPE_THROUGHPUT;
else if (strcasecmp(value_str, SFC_KVARG_PERF_PROFILE_LOW_LATENCY) == 0)
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 783cb43ae6..f77c4af345 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -85,6 +85,9 @@ sfc_kvarg_bool_handler(__rte_unused const char *key,
};
bool *value = opaque;
+ if (!key || !opaque)
+ return -EINVAL;
+
if (sfc_kvarg_match_value(value_str, true_strs,
RTE_DIM(true_strs)))
*value = true;
@@ -120,6 +123,9 @@ int
sfc_kvarg_string_handler(__rte_unused const char *key,
const char *value_str, void *opaque)
{
+ if (value_str == NULL || opaque == NULL)
+ return -EINVAL;
+
*(const char **)opaque = value_str;
return 0;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 1/5] app/pdump: fix segment fault when parse args
2023-03-14 12:48 ` [PATCH 1/5] app/pdump: " Chengwen Feng
@ 2023-03-16 17:34 ` Ferruh Yigit
0 siblings, 0 replies; 131+ messages in thread
From: Ferruh Yigit @ 2023-03-16 17:34 UTC (permalink / raw)
To: Chengwen Feng, thomas, Reshma Pattan, Stephen Hemminger; +Cc: dev
On 3/14/2023 12:48 PM, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse --pdump args with 'only keys'
> (e.g. 'port,queue=*').
>
> Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Hi Chengwen,
Thanks for the fix, +1 to patch.
> ---
> app/pdump/main.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/app/pdump/main.c b/app/pdump/main.c
> index c6cf9d9c87..d286952483 100644
> --- a/app/pdump/main.c
> +++ b/app/pdump/main.c
> @@ -170,6 +170,9 @@ parse_device_id(const char *key __rte_unused, const char *value,
> {
> struct pdump_tuples *pt = extra_args;
>
> + if (value == NULL || extra_args == NULL)
> + return -EINVAL;
> +
Do we need to check 'extra_args'?
It is not something changes in the runtime, functions provides this
callback is local to this file and in control, also if 'extra_args' is
not provided correctly it will crash immediately so easy to detect it.
But +1 to check 'value', since that depends what user provided and need
to verify user input.
Same comment for all set.
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 0/5] fix segment fault when parse args
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
` (4 preceding siblings ...)
2023-03-14 12:48 ` [PATCH 5/5] net/sfc: " Chengwen Feng
@ 2023-03-16 18:18 ` Ferruh Yigit
2023-03-17 2:43 ` fengchengwen
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (5 subsequent siblings)
11 siblings, 1 reply; 131+ messages in thread
From: Ferruh Yigit @ 2023-03-16 18:18 UTC (permalink / raw)
To: Chengwen Feng, thomas; +Cc: dev, David Marchand
On 3/14/2023 12:48 PM, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> It may leads to segment fault when parse args with 'only key', this
> patchset fixes rest of them.
>
> Chengwen Feng (5):
> app/pdump: fix segment fault when parse args
> net/memif: fix segment fault when parse devargs
> net/pcap: fix segment fault when parse devargs
> net/ring: fix segment fault when parse devargs
> net/sfc: fix segment fault when parse devargs
Hi Chengwen,
Did you scan all `rte_kvargs_process()` instances?
And if there would be a way to tell kvargs that a value is expected (or
not) this checks could be done in kvargs layer, I think this also can be
to look at.
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 2/5] net/memif: fix segment fault when parse devargs
2023-03-14 12:48 ` [PATCH 2/5] net/memif: fix segment fault when parse devargs Chengwen Feng
@ 2023-03-16 18:20 ` Ferruh Yigit
0 siblings, 0 replies; 131+ messages in thread
From: Ferruh Yigit @ 2023-03-16 18:20 UTC (permalink / raw)
To: Chengwen Feng, thomas, Jakub Grajciar, Ferruh Yigit
Cc: dev, Stephen Hemminger, Andrew Rybchenko, Olivier Matz
On 3/14/2023 12:48 PM, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
> Fixes: 2f865ed07bb6 ("net/memif: use abstract socket address")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
<...>
> @@ -1889,6 +1913,9 @@ memif_set_mac(const char *key __rte_unused, const char *value, void *extra_args)
> {
> struct rte_ether_addr *ether_addr = (struct rte_ether_addr *)extra_args;
>
> + if (value == NULL || extra_args == NULL)
> + return -EINVAL;
> +
> if (rte_ether_unformat_addr(value, ether_addr) < 0)
> MIF_LOG(WARNING, "Failed to parse mac '%s'.", value);
Not related to the patch, but to record it,
it seems public 'rte_ether_unformat_addr()' API is missing parameter
verification, we need to fix it.
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 3/5] net/pcap: fix segment fault when parse devargs
2023-03-14 12:48 ` [PATCH 3/5] net/pcap: " Chengwen Feng
@ 2023-03-16 18:20 ` Ferruh Yigit
0 siblings, 0 replies; 131+ messages in thread
From: Ferruh Yigit @ 2023-03-16 18:20 UTC (permalink / raw)
To: Chengwen Feng, thomas, Ferruh Yigit, Ido Goshen,
Juhamatti Kuusisaari, Cian Ferriter
Cc: dev
On 3/14/2023 12:48 PM, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: 4c173302c307 ("pcap: add new driver")
> Fixes: 53bf48403409 ("net/pcap: capture only ingress packets from Rx iface")
> Fixes: c9507cd0cada ("net/pcap: support physical interface MAC address")
> Fixes: a3f5252e5cbd ("net/pcap: enable infinitely Rx a pcap file")
> Cc: stable@dpdk.org
>
Can you please check following callbacks too:
`rx_iface_args_process()`
`open_tx_iface()`
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 5/5] net/sfc: fix segment fault when parse devargs
2023-03-14 12:48 ` [PATCH 5/5] net/sfc: " Chengwen Feng
@ 2023-03-16 18:20 ` Ferruh Yigit
0 siblings, 0 replies; 131+ messages in thread
From: Ferruh Yigit @ 2023-03-16 18:20 UTC (permalink / raw)
To: Chengwen Feng, thomas, Andrew Rybchenko, Roman Zhukov,
Andrew Lee, Robert Stonehouse, Ferruh Yigit, Andy Moreton
Cc: dev
On 3/14/2023 12:48 PM, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: 9e7fc8b8f3be ("net/sfc: add device parameter to choose FW variant")
> Fixes: c22d3c508e0c ("net/sfc: support parameter to choose performance profile")
> Fixes: 63d588ff2692 ("net/sfc: libefx-based driver stub")
> Fixes: df1bfde4ff0d ("net/sfc: factor out libefx-based Rx datapath")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
<...>
> index 783cb43ae6..f77c4af345 100644
> --- a/drivers/net/sfc/sfc_kvargs.c
> +++ b/drivers/net/sfc/sfc_kvargs.c
> @@ -85,6 +85,9 @@ sfc_kvarg_bool_handler(__rte_unused const char *key,
> };
> bool *value = opaque;
>
> + if (!key || !opaque)
> + return -EINVAL;
s/key/value_str/ ?
And better to be consistent with compression syntax,
`!ptr` vs `ptr == NULL"
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 0/5] fix segment fault when parse args
2023-03-16 18:18 ` [PATCH 0/5] fix segment fault when parse args Ferruh Yigit
@ 2023-03-17 2:43 ` fengchengwen
2023-03-21 13:50 ` Ferruh Yigit
0 siblings, 1 reply; 131+ messages in thread
From: fengchengwen @ 2023-03-17 2:43 UTC (permalink / raw)
To: Ferruh Yigit, thomas; +Cc: dev, David Marchand
On 2023/3/17 2:18, Ferruh Yigit wrote:
> On 3/14/2023 12:48 PM, Chengwen Feng wrote:
>> The rte_kvargs_process() was used to parse KV pairs, it also supports
>> to parse 'only keys' (e.g. socket_id) type. And the callback function
>> parameter 'value' is NULL when parsed 'only keys'.
>>
>> It may leads to segment fault when parse args with 'only key', this
>> patchset fixes rest of them.
>>
>> Chengwen Feng (5):
>> app/pdump: fix segment fault when parse args
>> net/memif: fix segment fault when parse devargs
>> net/pcap: fix segment fault when parse devargs
>> net/ring: fix segment fault when parse devargs
>> net/sfc: fix segment fault when parse devargs
>
> Hi Chengwen,
>
> Did you scan all `rte_kvargs_process()` instances?
No, I was just looking at the modules I was concerned about.
I looked at it briefly, and some modules had the same problem.
>
>
> And if there would be a way to tell kvargs that a value is expected (or
> not) this checks could be done in kvargs layer, I think this also can be
> to look at.
Yes, the way to tell kvargs may lead to a lot of modifys and also break ABI.
I also think about just set value = "" when only exist key, It could perfectly solve the above segment scene.
But it also break the API's behavior.
Or continue fix the exist code (about 10+ place more),
for new invoking, because the 'arg_handler_t' already well documented (52ab17efdecf935792ee1d0cb749c0dbd536c083),
they'll take the initiative to prevent this.
Hope for more advise for the next.
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 00/44] fix segment fault when parse args
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
` (5 preceding siblings ...)
2023-03-16 18:18 ` [PATCH 0/5] fix segment fault when parse args Ferruh Yigit
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 01/44] app/pdump: " Chengwen Feng
` (44 more replies)
2023-10-31 20:58 ` [RFC] kvargs: don't pass parse handler a NULL pointer Stephen Hemminger
` (4 subsequent siblings)
11 siblings, 45 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
It may leads to segment fault when parse args with 'only key', this
patchset fixes rest of them.
Chengwen Feng (44):
app/pdump: fix segment fault when parse args
ethdev: fix segment fault when parse args
net/memif: fix segment fault when parse devargs
net/pcap: fix segment fault when parse devargs
net/ring: fix segment fault when parse devargs
net/sfc: fix segment fault when parse devargs
net/af_xdp: fix segment fault when parse devargs
net/ark: fix segment fault when parse devargs
net/cnxk: fix segment fault when parse devargs
net/cxgbe: fix segment fault when parse devargs
net/dpaa2: fix segment fault when parse devargs
net/ena: fix segment fault when parse devargs
net/enic: fix segment fault when parse devargs
net/fm10k: fix segment fault when parse devargs
net/i40e: fix segment fault when parse devargs
net/iavf: fix segment fault when parse devargs
net/ice: fix segment fault when parse devargs
net/idpf: fix segment fault when parse devargs
net/ionic: fix segment fault when parse devargs
net/mana: fix segment fault when parse devargs
net/mlx4: fix segment fault when parse devargs
net/mvneta: fix segment fault when parse devargs
net/mvpp2: fix segment fault when parse devargs
net/netvsc: fix segment fault when parse devargs
net/octeontx: fix segment fault when parse devargs
net/pfe: fix segment fault when parse devargs
net/qede: fix segment fault when parse devargs
baseband/la12xx: fix segment fault when parse devargs
bus/pci: fix segment fault when parse args
common/mlx5: fix segment fault when parse devargs
crypto/cnxk: fix segment fault when parse devargs
crypto/dpaa_sec: fix segment fault when parse devargs
crypto/dpaa2_sec: fix segment fault when parse devargs
crypto/mvsam: fix segment fault when parse devargs
crypto/scheduler: fix segment fault when parse devargs
dma/dpaa2: fix segment fault when parse devargs
event/cnxk: fix segment fault when parse devargs
event/dlb2: fix segment fault when parse devargs
event/dpaa: fix segment fault when parse devargs
event/octeontx: fix segment fault when parse devargs
event/opdl: fix segment fault when parse devargs
event/sw: fix segment fault when parse devargs
mempool/cnxk: fix segment fault when parse devargs
raw/cnxk_gpio: fix segment fault when parse devargs
---
v2: according Ferruh's comments:
fix all 'rte_kvargs_process()' bug instances.
only judge value validation.
app/pdump/main.c | 12 ++++++
drivers/baseband/la12xx/bbdev_la12xx.c | 3 ++
drivers/bus/pci/pci_params.c | 2 +
drivers/common/mlx5/mlx5_common.c | 5 +++
drivers/crypto/cnxk/cnxk_cryptodev_devargs.c | 3 ++
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 2 +
drivers/crypto/dpaa_sec/dpaa_sec.c | 3 ++
drivers/crypto/mvsam/rte_mrvl_pmd.c | 6 +++
drivers/crypto/scheduler/scheduler_pmd.c | 21 +++++++++++
drivers/dma/dpaa2/dpaa2_qdma.c | 3 ++
drivers/event/cnxk/cnxk_eventdev.c | 6 +++
drivers/event/cnxk/cnxk_eventdev.h | 6 +++
drivers/event/cnxk/cnxk_tim_evdev.c | 6 +++
drivers/event/dlb2/dlb2.c | 5 ++-
drivers/event/dpaa/dpaa_eventdev.c | 3 ++
drivers/event/octeontx/ssovf_evdev.c | 2 +
drivers/event/opdl/opdl_evdev.c | 9 +++++
drivers/event/sw/sw_evdev.c | 12 ++++++
drivers/mempool/cnxk/cnxk_mempool.c | 3 ++
drivers/net/af_xdp/rte_eth_af_xdp.c | 12 ++++++
drivers/net/ark/ark_ethdev.c | 3 ++
drivers/net/cnxk/cnxk_ethdev_devargs.c | 39 ++++++++++++++++++++
drivers/net/cnxk/cnxk_ethdev_sec.c | 12 ++++++
drivers/net/cxgbe/cxgbe_main.c | 3 ++
drivers/net/dpaa2/dpaa2_ethdev.c | 3 ++
drivers/net/ena/ena_ethdev.c | 6 +++
drivers/net/enic/enic_ethdev.c | 6 +++
drivers/net/fm10k/fm10k_ethdev.c | 3 ++
drivers/net/i40e/i40e_ethdev.c | 15 ++++++++
drivers/net/iavf/iavf_ethdev.c | 6 +++
drivers/net/ice/ice_dcf_ethdev.c | 6 +++
drivers/net/ice/ice_ethdev.c | 6 +++
drivers/net/idpf/idpf_ethdev.c | 6 +++
drivers/net/ionic/ionic_dev_pci.c | 3 ++
drivers/net/mana/mana.c | 3 ++
drivers/net/memif/rte_eth_memif.c | 30 +++++++++++++++
drivers/net/mlx4/mlx4.c | 3 ++
drivers/net/mvneta/mvneta_ethdev.c | 3 ++
drivers/net/mvpp2/mrvl_ethdev.c | 3 ++
drivers/net/mvpp2/mrvl_qos.c | 6 ++-
drivers/net/netvsc/hn_ethdev.c | 3 ++
drivers/net/octeontx/octeontx_ethdev.c | 3 ++
drivers/net/pcap/pcap_ethdev.c | 18 ++++++++-
drivers/net/pfe/pfe_ethdev.c | 3 ++
drivers/net/qede/qede_ethdev.c | 3 ++
drivers/net/ring/rte_eth_ring.c | 6 +++
drivers/net/sfc/sfc.c | 3 ++
drivers/net/sfc/sfc_ev.c | 3 ++
drivers/net/sfc/sfc_kvargs.c | 6 +++
drivers/raw/cnxk_gpio/cnxk_gpio.c | 6 +++
lib/ethdev/rte_class_eth.c | 6 +++
51 files changed, 345 insertions(+), 4 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 01/44] app/pdump: fix segment fault when parse args
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 02/44] ethdev: " Chengwen Feng
` (43 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Reshma Pattan, Stephen Hemminger; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse --pdump args with 'only keys'
(e.g. 'port,queue=*').
Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
app/pdump/main.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/app/pdump/main.c b/app/pdump/main.c
index c6cf9d9c87..ff6940e2e5 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -170,6 +170,9 @@ parse_device_id(const char *key __rte_unused, const char *value,
{
struct pdump_tuples *pt = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
pt->device_id = strdup(value);
pt->dump_by_type = DEVICE_ID;
@@ -182,6 +185,9 @@ parse_queue(const char *key __rte_unused, const char *value, void *extra_args)
unsigned long n;
struct pdump_tuples *pt = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (!strcmp(value, "*"))
pt->queue = RTE_PDUMP_ALL_QUEUES;
else {
@@ -197,6 +203,9 @@ parse_rxtxdev(const char *key, const char *value, void *extra_args)
struct pdump_tuples *pt = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (!strcmp(key, PDUMP_RX_DEV_ARG)) {
strlcpy(pt->rx_dev, value, sizeof(pt->rx_dev));
/* identify the tx stream type for pcap vdev */
@@ -220,6 +229,9 @@ parse_uint_value(const char *key, const char *value, void *extra_args)
char *end;
int ret = 0;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
v = extra_args;
t = strtoul(value, &end, 10);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 02/44] ethdev: fix segment fault when parse args
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 01/44] app/pdump: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-04-09 8:10 ` Andrew Rybchenko
2023-03-20 9:20 ` [PATCH v2 03/44] net/memif: fix segment fault when parse devargs Chengwen Feng
` (42 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Andrew Rybchenko; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse args with 'only keys'
(e.g. 'mac,representor').
Fixes: c10cdce180a6 ("ethdev: support MAC address as iterator filter")
Fixes: a7d3c6271d55 ("ethdev: support representor id as iterator filter")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/ethdev/rte_class_eth.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c
index b61dae849d..b9fc25348b 100644
--- a/lib/ethdev/rte_class_eth.c
+++ b/lib/ethdev/rte_class_eth.c
@@ -46,6 +46,9 @@ eth_mac_cmp(const char *key __rte_unused,
struct rte_eth_dev_info dev_info;
uint32_t index;
+ if (value == NULL)
+ return -EINVAL;
+
/* Parse devargs MAC address. */
if (rte_ether_unformat_addr(value, &mac) < 0)
return -1; /* invalid devargs value */
@@ -72,6 +75,9 @@ eth_representor_cmp(const char *key __rte_unused,
if ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0)
return -1; /* not a representor port */
+ if (value == NULL)
+ return -EINVAL;
+
/* Parse devargs representor values. */
values = strdup(value);
if (values == NULL)
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 03/44] net/memif: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 01/44] app/pdump: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 02/44] ethdev: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 04/44] net/pcap: " Chengwen Feng
` (41 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Jakub Grajciar, Ferruh Yigit; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
Fixes: 2f865ed07bb6 ("net/memif: use abstract socket address")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/memif/rte_eth_memif.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index 6a8ff5b4eb..6fafb6de1f 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1720,6 +1720,9 @@ memif_set_role(const char *key __rte_unused, const char *value,
{
enum memif_role_t *role = (enum memif_role_t *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strstr(value, "server") != NULL) {
*role = MEMIF_ROLE_SERVER;
} else if (strstr(value, "client") != NULL) {
@@ -1742,6 +1745,9 @@ memif_set_zc(const char *key __rte_unused, const char *value, void *extra_args)
{
uint32_t *flags = (uint32_t *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strstr(value, "yes") != NULL) {
if (!rte_mcfg_get_single_file_segments()) {
MIF_LOG(ERR, "Zero-copy doesn't support multi-file segments.");
@@ -1762,6 +1768,9 @@ memif_set_id(const char *key __rte_unused, const char *value, void *extra_args)
{
memif_interface_id_t *id = (memif_interface_id_t *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
/* even if parsing fails, 0 is a valid id */
*id = strtoul(value, NULL, 10);
return 0;
@@ -1773,6 +1782,9 @@ memif_set_bs(const char *key __rte_unused, const char *value, void *extra_args)
unsigned long tmp;
uint16_t *pkt_buffer_size = (uint16_t *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
tmp = strtoul(value, NULL, 10);
if (tmp == 0 || tmp > 0xFFFF) {
MIF_LOG(ERR, "Invalid buffer size: %s.", value);
@@ -1789,6 +1801,9 @@ memif_set_rs(const char *key __rte_unused, const char *value, void *extra_args)
memif_log2_ring_size_t *log2_ring_size =
(memif_log2_ring_size_t *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
tmp = strtoul(value, NULL, 10);
if (tmp == 0 || tmp > ETH_MEMIF_MAX_LOG2_RING_SIZE) {
MIF_LOG(ERR, "Invalid ring size: %s (max %u).",
@@ -1840,6 +1855,9 @@ memif_set_socket_filename(const char *key __rte_unused, const char *value,
{
const char **socket_filename = (const char **)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
*socket_filename = value;
return 0;
}
@@ -1849,6 +1867,9 @@ memif_set_is_socket_abstract(const char *key __rte_unused, const char *value, vo
{
uint32_t *flags = (uint32_t *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strstr(value, "yes") != NULL) {
*flags |= ETH_MEMIF_FLAG_SOCKET_ABSTRACT;
} else if (strstr(value, "no") != NULL) {
@@ -1870,6 +1891,9 @@ memif_set_owner(const char *key, const char *value, void *extra_args)
char *end = NULL;
uint32_t *id = (uint32_t *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
val = strtoul(value, &end, 10);
if (*value == '\0' || *end != '\0') {
MIF_LOG(ERR, "Failed to parse %s: %s.", key, value);
@@ -1889,6 +1913,9 @@ memif_set_mac(const char *key __rte_unused, const char *value, void *extra_args)
{
struct rte_ether_addr *ether_addr = (struct rte_ether_addr *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (rte_ether_unformat_addr(value, ether_addr) < 0)
MIF_LOG(WARNING, "Failed to parse mac '%s'.", value);
return 0;
@@ -1899,6 +1926,9 @@ memif_set_secret(const char *key __rte_unused, const char *value, void *extra_ar
{
const char **secret = (const char **)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
*secret = value;
return 0;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 04/44] net/pcap: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (2 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 03/44] net/memif: fix segment fault when parse devargs Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-07-04 3:04 ` Stephen Hemminger
2023-03-20 9:20 ` [PATCH v2 05/44] net/ring: " Chengwen Feng
` (40 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Ido Goshen, Ferruh Yigit,
Juhamatti Kuusisaari, Cian Ferriter
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 4c173302c307 ("pcap: add new driver")
Fixes: 53bf48403409 ("net/pcap: capture only ingress packets from Rx iface")
Fixes: c9507cd0cada ("net/pcap: support physical interface MAC address")
Fixes: a3f5252e5cbd ("net/pcap: enable infinitely Rx a pcap file")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/pcap/pcap_ethdev.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index bfec085045..9dc66e7ee9 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -1034,6 +1034,9 @@ open_rx_pcap(const char *key, const char *value, void *extra_args)
struct pmd_devargs *rx = extra_args;
pcap_t *pcap = NULL;
+ if (value == NULL)
+ return -EINVAL;
+
if (open_single_rx_pcap(pcap_filename, &pcap) < 0)
return -1;
@@ -1056,6 +1059,9 @@ open_tx_pcap(const char *key, const char *value, void *extra_args)
struct pmd_devargs *dumpers = extra_args;
pcap_dumper_t *dumper;
+ if (value == NULL)
+ return -EINVAL;
+
if (open_single_tx_pcap(pcap_filename, &dumper) < 0)
return -1;
@@ -1077,6 +1083,9 @@ open_rx_tx_iface(const char *key, const char *value, void *extra_args)
struct pmd_devargs *tx = extra_args;
pcap_t *pcap = NULL;
+ if (value == NULL)
+ return -EINVAL;
+
if (open_single_iface(iface, &pcap) < 0)
return -1;
@@ -1143,6 +1152,9 @@ open_rx_iface(const char *key, const char *value, void *extra_args)
static inline int
rx_iface_args_process(const char *key, const char *value, void *extra_args)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(key, ETH_PCAP_RX_IFACE_ARG) == 0 ||
strcmp(key, ETH_PCAP_RX_IFACE_IN_ARG) == 0)
return open_rx_iface(key, value, extra_args);
@@ -1156,6 +1168,8 @@ rx_iface_args_process(const char *key, const char *value, void *extra_args)
static int
open_tx_iface(const char *key, const char *value, void *extra_args)
{
+ if (value == NULL)
+ return -EINVAL;
return open_iface(key, value, extra_args);
}
@@ -1163,7 +1177,7 @@ static int
select_phy_mac(const char *key __rte_unused, const char *value,
void *extra_args)
{
- if (extra_args) {
+ if (value != NULL && extra_args != NULL) {
const int phy_mac = atoi(value);
int *enable_phy_mac = extra_args;
@@ -1177,7 +1191,7 @@ static int
get_infinite_rx_arg(const char *key __rte_unused,
const char *value, void *extra_args)
{
- if (extra_args) {
+ if (value != NULL && extra_args != NULL) {
const int infinite_rx = atoi(value);
int *enable_infinite_rx = extra_args;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 05/44] net/ring: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (3 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 04/44] net/pcap: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 06/44] net/sfc: " Chengwen Feng
` (39 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Bruce Richardson, Neil Horman, Ferruh Yigit; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 61934c0956d4 ("ring: convert to use of PMD_REGISTER_DRIVER and fix linking")
Fixes: 96cb19521147 ("net/ring: use EAL APIs in PMD specific API")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/ring/rte_eth_ring.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index e8bc9b6271..88b19e205e 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -562,6 +562,9 @@ static int parse_kvlist(const char *key __rte_unused,
char *node;
char *end;
+ if (value == NULL)
+ return -EINVAL;
+
name = strdup(value);
ret = -EINVAL;
@@ -630,6 +633,9 @@ parse_internal_args(const char *key __rte_unused, const char *value,
void *args;
int ret, n;
+ if (value == NULL)
+ return -EINVAL;
+
/* make sure 'value' is valid pointer length */
if (strnlen(value, ETH_RING_INTERNAL_ARG_MAX_LEN) >=
ETH_RING_INTERNAL_ARG_MAX_LEN) {
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 06/44] net/sfc: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (4 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 05/44] net/ring: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-04-09 8:09 ` Andrew Rybchenko
2023-03-20 9:20 ` [PATCH v2 07/44] net/af_xdp: " Chengwen Feng
` (38 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Andrew Rybchenko, Roman Zhukov, Andrew Lee,
Robert Stonehouse, Andy Moreton, Ferruh Yigit
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 9e7fc8b8f3be ("net/sfc: add device parameter to choose FW variant")
Fixes: c22d3c508e0c ("net/sfc: support parameter to choose performance profile")
Fixes: 63d588ff2692 ("net/sfc: libefx-based driver stub")
Fixes: df1bfde4ff0d ("net/sfc: factor out libefx-based Rx datapath")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/sfc/sfc.c | 3 +++
drivers/net/sfc/sfc_ev.c | 3 +++
drivers/net/sfc/sfc_kvargs.c | 6 ++++++
3 files changed, 12 insertions(+)
diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 22753e3417..d17abefd6c 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -1108,6 +1108,9 @@ sfc_kvarg_fv_variant_handler(__rte_unused const char *key,
{
uint32_t *value = opaque;
+ if (value_str == NULL)
+ return -EINVAL;
+
if (strcasecmp(value_str, SFC_KVARG_FW_VARIANT_DONT_CARE) == 0)
*value = EFX_FW_VARIANT_DONT_CARE;
else if (strcasecmp(value_str, SFC_KVARG_FW_VARIANT_FULL_FEATURED) == 0)
diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c
index f949abbfc3..bf85ee2b8e 100644
--- a/drivers/net/sfc/sfc_ev.c
+++ b/drivers/net/sfc/sfc_ev.c
@@ -955,6 +955,9 @@ sfc_kvarg_perf_profile_handler(__rte_unused const char *key,
{
uint32_t *value = opaque;
+ if (value_str == NULL)
+ return -EINVAL;
+
if (strcasecmp(value_str, SFC_KVARG_PERF_PROFILE_THROUGHPUT) == 0)
*value = EFX_EVQ_FLAGS_TYPE_THROUGHPUT;
else if (strcasecmp(value_str, SFC_KVARG_PERF_PROFILE_LOW_LATENCY) == 0)
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 783cb43ae6..5b3b7fecad 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -85,6 +85,9 @@ sfc_kvarg_bool_handler(__rte_unused const char *key,
};
bool *value = opaque;
+ if (value_str == NULL)
+ return -EINVAL;
+
if (sfc_kvarg_match_value(value_str, true_strs,
RTE_DIM(true_strs)))
*value = true;
@@ -120,6 +123,9 @@ int
sfc_kvarg_string_handler(__rte_unused const char *key,
const char *value_str, void *opaque)
{
+ if (value_str == NULL)
+ return -EINVAL;
+
*(const char **)opaque = value_str;
return 0;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 07/44] net/af_xdp: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (5 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 06/44] net/sfc: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 08/44] net/ark: " Chengwen Feng
` (37 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Ciara Loftus, Qi Zhang, Stephen Hemminger,
Luca Boccassi, Xiaolong Ye, Ferruh Yigit
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
Fixes: 288a85aef192 ("net/af_xdp: enable custom XDP program loading")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/af_xdp/rte_eth_af_xdp.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 2a20a6960c..519a57aeba 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -1897,6 +1897,9 @@ parse_budget_arg(const char *key __rte_unused,
int *i = (int *)extra_args;
char *end;
+ if (value == NULL)
+ return -EINVAL;
+
*i = strtol(value, &end, 10);
if (*i < 0 || *i > UINT16_MAX) {
AF_XDP_LOG(ERR, "Invalid busy_budget %i, must be >= 0 and <= %u\n",
@@ -1915,6 +1918,9 @@ parse_integer_arg(const char *key __rte_unused,
int *i = (int *)extra_args;
char *end;
+ if (value == NULL)
+ return -EINVAL;
+
*i = strtol(value, &end, 10);
if (*i < 0) {
AF_XDP_LOG(ERR, "Argument has to be positive.\n");
@@ -1931,6 +1937,9 @@ parse_name_arg(const char *key __rte_unused,
{
char *name = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strnlen(value, IFNAMSIZ) > IFNAMSIZ - 1) {
AF_XDP_LOG(ERR, "Invalid name %s, should be less than %u bytes.\n",
value, IFNAMSIZ);
@@ -1949,6 +1958,9 @@ parse_prog_arg(const char *key __rte_unused,
{
char *path = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strnlen(value, PATH_MAX) == PATH_MAX) {
AF_XDP_LOG(ERR, "Invalid path %s, should be less than %u bytes.\n",
value, PATH_MAX);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 08/44] net/ark: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (6 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 07/44] net/af_xdp: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 09/44] net/cnxk: " Chengwen Feng
` (36 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Shepard Siegel, Ed Czeck, John Miller,
Ferruh Yigit
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 1502d443d885 ("net/ark: replace compile time log config with runtime")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/ark/ark_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index b2995427c8..8baaffd746 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -898,6 +898,9 @@ process_pktdir_arg(const char *key, const char *value,
struct ark_adapter *ark =
(struct ark_adapter *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
ark->pkt_dir_v = strtol(value, NULL, 16);
ARK_PMD_LOG(DEBUG, "pkt_dir_v = 0x%x\n", ark->pkt_dir_v);
return 0;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 09/44] net/cnxk: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (7 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 08/44] net/ark: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 10/44] net/cxgbe: " Chengwen Feng
` (35 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Nithin Dabilpuram, Kiran Kumar K,
Sunil Kumar Kori, Satha Rao, Jerin Jacob, Satheesh Paul
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 7eabd6c63773 ("net/cnxk: support inline security setup for cn9k")
Fixes: d25433c7a852 ("net/cnxk: add common devargs parsing")
Fixes: df5cf15faaa9 ("net/cnxk: support IPsec rule reservation scheme")
Fixes: 7eabd6c63773 ("net/cnxk: support inline security setup for cn9k")
Fixes: c91d30f46d4c ("net/cnxk: support configuring channel mask via devargs")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/cnxk/cnxk_ethdev_devargs.c | 39 ++++++++++++++++++++++++++
drivers/net/cnxk/cnxk_ethdev_sec.c | 12 ++++++++
2 files changed, 51 insertions(+)
diff --git a/drivers/net/cnxk/cnxk_ethdev_devargs.c b/drivers/net/cnxk/cnxk_ethdev_devargs.c
index e1a0845ece..9dde7937f2 100644
--- a/drivers/net/cnxk/cnxk_ethdev_devargs.c
+++ b/drivers/net/cnxk/cnxk_ethdev_devargs.c
@@ -25,6 +25,9 @@ parse_outb_nb_desc(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = atoi(value);
*(uint16_t *)extra_args = val;
@@ -38,6 +41,9 @@ parse_outb_nb_crypto_qs(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = atoi(value);
if (val < 1 || val > 64)
@@ -54,6 +60,9 @@ parse_ipsec_in_spi_range(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
val = strtoul(value, NULL, 0);
if (errno)
@@ -70,6 +79,9 @@ parse_ipsec_out_max_sa(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
val = strtoul(value, NULL, 0);
if (errno)
@@ -86,6 +98,9 @@ parse_flow_max_priority(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint16_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = atoi(value);
/* Limit the max priority to 32 */
@@ -103,6 +118,9 @@ parse_flow_prealloc_size(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint16_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = atoi(value);
/* Limit the prealloc size to 32 */
@@ -120,6 +138,9 @@ parse_reta_size(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = atoi(value);
if (val <= RTE_ETH_RSS_RETA_SIZE_64)
@@ -144,6 +165,9 @@ parse_pre_l2_hdr_info(const char *key, const char *value, void *extra_args)
char *tok1 = NULL, *tok2 = NULL;
uint16_t off, off_mask, dir;
+ if (value == NULL)
+ return -EINVAL;
+
RTE_SET_USED(key);
off = strtol(value, &tok1, 16);
tok1++;
@@ -164,6 +188,9 @@ parse_flag(const char *key, const char *value, void *extra_args)
{
RTE_SET_USED(key);
+ if (value == NULL)
+ return -EINVAL;
+
*(uint16_t *)extra_args = atoi(value);
return 0;
@@ -175,6 +202,9 @@ parse_sqb_count(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = atoi(value);
*(uint16_t *)extra_args = val;
@@ -188,6 +218,9 @@ parse_meta_bufsize(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
val = strtoul(value, NULL, 0);
if (errno)
@@ -203,6 +236,9 @@ parse_switch_header_type(const char *key, const char *value, void *extra_args)
{
RTE_SET_USED(key);
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "higig2") == 0)
*(uint16_t *)extra_args = ROC_PRIV_FLAGS_HIGIG;
@@ -231,6 +267,9 @@ parse_sdp_channel_mask(const char *key, const char *value, void *extra_args)
uint16_t chan = 0, mask = 0;
char *next = 0;
+ if (value == NULL)
+ return -EINVAL;
+
/* next will point to the separator '/' */
chan = strtol(value, &next, 16);
mask = strtol(++next, 0, 16);
diff --git a/drivers/net/cnxk/cnxk_ethdev_sec.c b/drivers/net/cnxk/cnxk_ethdev_sec.c
index aa8a378a00..6d1fc754b8 100644
--- a/drivers/net/cnxk/cnxk_ethdev_sec.c
+++ b/drivers/net/cnxk/cnxk_ethdev_sec.c
@@ -133,6 +133,9 @@ parse_max_ipsec_rules(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = atoi(value);
if (val < 1 || val > 4095)
@@ -248,6 +251,9 @@ parse_val_u32(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
val = strtoul(value, NULL, 0);
if (errno)
@@ -264,6 +270,9 @@ parse_selftest(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = atoi(value);
*(uint8_t *)extra_args = !!(val == 1);
@@ -277,6 +286,9 @@ parse_inl_cpt_channel(const char *key, const char *value, void *extra_args)
uint16_t chan = 0, mask = 0;
char *next = 0;
+ if (value == NULL)
+ return -EINVAL;
+
/* next will point to the separator '/' */
chan = strtol(value, &next, 16);
mask = strtol(++next, 0, 16);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 10/44] net/cxgbe: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (8 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 09/44] net/cnxk: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 11/44] net/dpaa2: " Chengwen Feng
` (34 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Rahul Lakkireddy, Kumar Sanghvi,
Shagun Agrawal, Karra Satwik
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: cda260a4ac1a ("net/cxgbe: add option to keep outer VLAN tag in QinQ")
Fixes: dd7c9f12762e ("net/cxgbe: separate VF only devargs")
Fixes: 536db938a444 ("net/cxgbe: add devargs to control filtermode and filtermask")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/cxgbe/cxgbe_main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index f8dd833032..2f2acbcf5a 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -746,6 +746,9 @@ void cxgbe_print_port_info(struct adapter *adap)
static int check_devargs_handler(const char *key, const char *value, void *p)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (!strncmp(key, CXGBE_DEVARG_CMN_KEEP_OVLAN, strlen(key)) ||
!strncmp(key, CXGBE_DEVARG_CMN_TX_MODE_LATENCY, strlen(key)) ||
!strncmp(key, CXGBE_DEVARG_VF_FORCE_LINK_UP, strlen(key))) {
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 11/44] net/dpaa2: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (9 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 10/44] net/cxgbe: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 12/44] net/ena: " Chengwen Feng
` (33 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Hemant Agrawal, Sachin Saxena,
Karra Satwik, Rahul Lakkireddy
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 536db938a444 ("net/cxgbe: add devargs to control filtermode and filtermask")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/dpaa2/dpaa2_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 679f33ae1a..c54e10f3b7 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -2545,6 +2545,9 @@ static int
check_devargs_handler(__rte_unused const char *key, const char *value,
__rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "1"))
return -1;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 12/44] net/ena: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (10 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 11/44] net/dpaa2: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 13/44] net/enic: " Chengwen Feng
` (32 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Marcin Wojtas, Michal Krawczyk,
Shai Brandes, Evgeny Schemeilin, Igor Chauskin, Dawid Gorecki,
Guy Tzalik
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: cc0c5d251928 ("net/ena: make Tx completion timeout configurable")
Fixes: 8a7a73f26cc9 ("net/ena: support large LLQ headers")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/ena/ena_ethdev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index efcb163027..82a6c75824 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -3444,6 +3444,9 @@ static int ena_process_uint_devarg(const char *key,
char *str_end;
uint64_t uint_value;
+ if (value == NULL)
+ return -EINVAL;
+
uint_value = strtoull(value, &str_end, 10);
if (value == str_end) {
PMD_INIT_LOG(ERR,
@@ -3482,6 +3485,9 @@ static int ena_process_bool_devarg(const char *key,
struct ena_adapter *adapter = opaque;
bool bool_value;
+ if (value == NULL)
+ return -EINVAL;
+
/* Parse the value. */
if (strcmp(value, "1") == 0) {
bool_value = true;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 13/44] net/enic: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (11 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 12/44] net/ena: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 21:37 ` John Daley (johndale)
2023-03-20 9:20 ` [PATCH v2 14/44] net/fm10k: " Chengwen Feng
` (31 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, John Daley, Hyong Youb Kim; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 93fb21fdbe23 ("net/enic: enable overlay offload for VXLAN and GENEVE")
Fixes: e39c2756e21a ("net/enic: add devarg to specify ingress VLAN rewrite mode")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/enic/enic_ethdev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index cdf0915591..b67016e0a3 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -1148,6 +1148,9 @@ static int enic_parse_zero_one(const char *key,
struct enic *enic;
bool b;
+ if (value == NULL)
+ return -EINVAL;
+
enic = (struct enic *)opaque;
if (strcmp(value, "0") == 0) {
b = false;
@@ -1173,6 +1176,9 @@ static int enic_parse_ig_vlan_rewrite(__rte_unused const char *key,
{
struct enic *enic;
+ if (value == NULL)
+ return -EINVAL;
+
enic = (struct enic *)opaque;
if (strcmp(value, "trunk") == 0) {
/* Trunk mode: always tag */
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 14/44] net/fm10k: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (12 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 13/44] net/enic: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 15/44] net/i40e: " Chengwen Feng
` (30 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Qi Zhang, Xiao Wang, Jing Chen, John McNamara; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 7958b1310d5e ("fm10k: enable FTAG based forwarding")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/fm10k/fm10k_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 8b83063f0a..2096c6ffab 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2873,6 +2873,9 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
static int ftag_check_handler(__rte_unused const char *key,
const char *value, __rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "1"))
return -1;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 15/44] net/i40e: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (13 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 14/44] net/fm10k: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 16/44] net/iavf: " Chengwen Feng
` (29 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Yuying Zhang, Beilei Xing, John McNamara,
Zhe Tao, Jingjing Wu, Xiaolong Ye, Qi Zhang, Alvin Zhang,
Wei Dai
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 79f2248219c0 ("net/i40e: add floating VEB option")
Fixes: cfdfca493cae ("net/i40e: fix multiple driver support")
Fixes: 56270b4208ab ("net/i40e: limit the number of VF messages")
Fixes: ee653bd80044 ("net/i40e: determine number of queues per VF at run time")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/i40e/i40e_ethdev.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 371f42233e..1338b9b92d 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -829,6 +829,9 @@ floating_veb_list_handler(__rte_unused const char *key,
int min, max;
bool *vf_floating_veb = opaque;
+ if (floating_veb_value == NULL)
+ return -EINVAL;
+
while (isblank(*floating_veb_value))
floating_veb_value++;
@@ -921,6 +924,9 @@ i40e_check_floating_handler(__rte_unused const char *key,
const char *value,
__rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "1"))
return -1;
@@ -1258,6 +1264,9 @@ i40e_parse_multi_drv_handler(__rte_unused const char *key,
pf = (struct i40e_pf *)opaque;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
support_multi_driver = strtoul(value, &end, 10);
if (errno != 0 || end == value || *end != 0) {
@@ -1347,6 +1356,9 @@ read_vf_msg_config(__rte_unused const char *key,
{
struct i40e_vf_msg_cfg *cfg = opaque;
+ if (value == NULL)
+ return -EINVAL;
+
if (sscanf(value, "%u@%u:%u", &cfg->max_msg, &cfg->period,
&cfg->ignore_second) != 3) {
memset(cfg, 0, sizeof(*cfg));
@@ -4693,6 +4705,9 @@ static int i40e_pf_parse_vf_queue_number_handler(const char *key,
pf = (struct i40e_pf *)opaque;
RTE_SET_USED(key);
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
num = strtoul(value, &end, 0);
if (errno != 0 || end == value || *end != 0) {
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 16/44] net/iavf: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (14 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 15/44] net/i40e: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 17/44] net/ice: " Chengwen Feng
` (28 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Jingjing Wu, Beilei Xing, Qi Zhang,
Wenjun Wu, Xiaolong Ye, Haiyue Wang
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: b14e8a57b9fe ("net/iavf: support quanta size configuration")
Fixes: 4cce7422dd38 ("net/iavf: stop PCI probe in DCF mode")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/iavf/iavf_ethdev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 3196210f2c..654741b71f 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2185,6 +2185,9 @@ parse_u16(__rte_unused const char *key, const char *value, void *args)
u16 *num = (u16 *)args;
u16 tmp;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
tmp = strtoull(value, NULL, 10);
if (errno || !tmp) {
@@ -2815,6 +2818,9 @@ static int
iavf_dcf_cap_check_handler(__rte_unused const char *key,
const char *value, __rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "dcf"))
return -1;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 17/44] net/ice: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (15 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 16/44] net/iavf: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 18/44] net/idpf: " Chengwen Feng
` (27 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Qiming Yang, Qi Zhang, Zhichao Zeng,
Haiyue Wang, Ray Kinsella
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 9e984bc53bc9 ("net/ice: add option to disable ACL engine in DCF")
Fixes: 7564d5509611 ("net/ice: add DCF hardware initialization")
Fixes: 603beeb970b5 ("net/ice: add safe mode devarg")
Fixes: 79d559de896b ("net/ice: add option for setting HW debug mask")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/ice/ice_dcf_ethdev.c | 6 ++++++
drivers/net/ice/ice_ethdev.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index dcbf2af5b0..9fe712ebd1 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1933,6 +1933,9 @@ static int
ice_dcf_engine_disabled_handler(__rte_unused const char *key,
const char *value, __rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "off"))
return -1;
@@ -1943,6 +1946,9 @@ static int
ice_dcf_cap_check_handler(__rte_unused const char *key,
const char *value, __rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "dcf"))
return -1;
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 9a88cf9796..0917d20515 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -1887,6 +1887,9 @@ parse_bool(const char *key, const char *value, void *args)
char *end;
int num;
+ if (value == NULL)
+ return -EINVAL;
+
num = strtoul(value, &end, 10);
if (num != 0 && num != 1) {
@@ -1906,6 +1909,9 @@ parse_u64(const char *key, const char *value, void *args)
u64 *num = (u64 *)args;
u64 tmp;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
tmp = strtoull(value, NULL, 16);
if (errno) {
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 18/44] net/idpf: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (16 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 17/44] net/ice: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 19/44] net/ionic: " Chengwen Feng
` (26 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Jingjing Wu, Beilei Xing, Junfeng Guo,
Xiao Wang, Wenjun Wu, Xiaoyun Li
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 549343c25db8 ("net/idpf: support device initialization")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/idpf/idpf_ethdev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 46aec6ae37..105dcc8744 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -903,6 +903,9 @@ parse_vport(const char *key, const char *value, void *args)
struct idpf_devargs *devargs = args;
const char *pos = value;
+ if (value == NULL)
+ return -EINVAL;
+
devargs->req_vport_nb = 0;
if (*pos == '[')
@@ -936,6 +939,9 @@ parse_bool(const char *key, const char *value, void *args)
char *end;
int num;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
num = strtoul(value, &end, 10);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 19/44] net/ionic: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (17 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 18/44] net/idpf: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 20/44] net/mana: " Chengwen Feng
` (25 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Andrew Boyer, Neel Patel; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 9de21005e201 ("net/ionic: add Q-in-CMB option")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/ionic/ionic_dev_pci.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ionic/ionic_dev_pci.c b/drivers/net/ionic/ionic_dev_pci.c
index 5e74a6da71..5ba86c7a2e 100644
--- a/drivers/net/ionic/ionic_dev_pci.c
+++ b/drivers/net/ionic/ionic_dev_pci.c
@@ -103,6 +103,9 @@ ionic_pci_devarg_cmb(const char *key __rte_unused, const char *val, void *arg)
{
struct ionic_adapter *adapter = arg;
+ if (val == NULL)
+ return -EINVAL;
+
if (!strcmp(val, "1")) {
IONIC_PRINT(NOTICE, "%s enabled", PMD_IONIC_CMB_KVARG);
adapter->q_in_cmb = true;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 20/44] net/mana: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (18 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 19/44] net/ionic: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-21 22:19 ` Long Li
2023-03-20 9:20 ` [PATCH v2 21/44] net/mlx4: " Chengwen Feng
` (24 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Long Li; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 517ed6e2d590 ("net/mana: add basic driver with build environment")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/mana/mana.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c
index 8a782c0d63..9c097c02ba 100644
--- a/drivers/net/mana/mana.c
+++ b/drivers/net/mana/mana.c
@@ -750,6 +750,9 @@ mana_arg_parse_callback(const char *key, const char *val, void *private)
return 1;
}
+ if (val == NULL)
+ return -EINVAL;
+
ret = rte_ether_unformat_addr(val, &conf->mac_array[conf->index]);
if (ret) {
DRV_LOG(ERR, "Invalid MAC address %s", val);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 21/44] net/mlx4: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (19 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 20/44] net/mana: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 22/44] net/mvneta: " Chengwen Feng
` (23 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Matan Azrad, Viacheslav Ovsiienko,
Adrien Mazarguil, Gaetan Rivet
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 001a520e419f ("net/mlx4: add port parameter")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/mlx4/mlx4.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index a54016f4a2..7c11f3a129 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -521,6 +521,9 @@ mlx4_arg_parse(const char *key, const char *val, struct mlx4_conf *conf)
{
unsigned long tmp;
+ if (val == NULL)
+ return -EINVAL;
+
errno = 0;
tmp = strtoul(val, NULL, 0);
if (errno) {
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 22/44] net/mvneta: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (20 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 21/44] net/mlx4: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:33 ` [EXT] " Liron Himi
2023-03-20 9:20 ` [PATCH v2 23/44] net/mvpp2: " Chengwen Feng
` (22 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Zyta Szpak, Liron Himi, Dmitri Epshtein,
Natalie Samsonov, Andrzej Ostruszka, Yelena Krivosheev
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 4ccc8d770d3b ("net/mvneta: add PMD skeleton")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/mvneta/mvneta_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index d7953ac7cb..babe825ff9 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -91,6 +91,9 @@ mvneta_ifnames_get(const char *key __rte_unused, const char *value,
{
struct mvneta_ifnames *ifnames = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
ifnames->names[ifnames->idx++] = value;
return 0;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 23/44] net/mvpp2: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (21 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 22/44] net/mvneta: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:33 ` [EXT] " Liron Himi
2023-03-20 9:20 ` [PATCH v2 24/44] net/netvsc: " Chengwen Feng
` (21 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Liron Himi, Tomasz Duszynski, Jacek Siuda; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 0ddc9b815b11 ("net/mrvl: add net PMD skeleton")
Fixes: c2b5ae61c07e ("net/mvpp2: support DSA mode")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/mvpp2/mrvl_ethdev.c | 3 +++
drivers/net/mvpp2/mrvl_qos.c | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index 89c83f1c1f..a631d6d9cc 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -3180,6 +3180,9 @@ mrvl_get_ifnames(const char *key __rte_unused, const char *value,
{
struct mrvl_ifnames *ifnames = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
ifnames->names[ifnames->idx++] = value;
return 0;
diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c
index f43217bc58..f217a8d71a 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -656,12 +656,16 @@ int
mrvl_get_cfg(const char *key __rte_unused, const char *path, void *extra_args)
{
struct mrvl_cfg **cfg = extra_args;
- struct rte_cfgfile *file = rte_cfgfile_load(path, 0);
+ struct rte_cfgfile *file;
uint32_t val;
int n, i, ret;
const char *entry;
char sec_name[32];
+ if (path == NULL)
+ return -EINVAL;
+
+ file = rte_cfgfile_load(path, 0);
if (file == NULL) {
MRVL_LOG(ERR, "Cannot load configuration %s\n", path);
return -1;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 24/44] net/netvsc: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (22 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 23/44] net/mvpp2: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-21 22:20 ` Long Li
2023-07-04 3:02 ` Stephen Hemminger
2023-03-20 9:20 ` [PATCH v2 25/44] net/octeontx: " Chengwen Feng
` (20 subsequent siblings)
44 siblings, 2 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Long Li, Stephen Hemminger; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: a25d39a3eb69 ("net/netvsc: allow tuning latency with devargs")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/netvsc/hn_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index d0bbc0a4c0..e13eb03176 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -157,6 +157,9 @@ static int hn_set_parameter(const char *key, const char *value, void *opaque)
char *endp = NULL;
unsigned long v;
+ if (value == NULL)
+ return -EINVAL;
+
v = strtoul(value, &endp, 0);
if (*value == '\0' || *endp != '\0') {
PMD_DRV_LOG(ERR, "invalid parameter %s=%s", key, value);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 25/44] net/octeontx: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (23 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 24/44] net/netvsc: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-04-12 7:54 ` [EXT] " Harman Kalra
2023-03-20 9:20 ` [PATCH v2 26/44] net/pfe: " Chengwen Feng
` (19 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Harman Kalra, Santosh Shukla, Jerin Jacob; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: f7be70e5130e ("net/octeontx: add net device probe and remove")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/octeontx/octeontx_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index d52a3e73d5..d11f359c7b 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -70,6 +70,9 @@ parse_integer_arg(const char *key __rte_unused,
{
int *i = (int *)extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
*i = atoi(value);
if (*i < 0) {
octeontx_log_err("argument has to be positive.");
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 26/44] net/pfe: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (24 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 25/44] net/octeontx: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 27/44] net/qede: " Chengwen Feng
` (18 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Gagandeep Singh, Nipun Gupta, Akhil Goyal; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 67fc3ff97c39 ("net/pfe: introduce basic functions")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/pfe/pfe_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
index 0352a57950..6e09c9443b 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -888,6 +888,9 @@ parse_integer_arg(const char *key __rte_unused,
char *end;
errno = 0;
+ if (value == NULL)
+ return -EINVAL;
+
i = strtol(value, &end, 10);
if (*end != 0 || errno != 0 || i < 0 || i > 1) {
PFE_PMD_ERR("Supported Port IDS are 0 and 1");
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 27/44] net/qede: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (25 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 26/44] net/pfe: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 28/44] baseband/la12xx: " Chengwen Feng
` (17 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Rasesh Mody, Devendra Singh Rawat; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: f64b91b0eb5d ("net/qede: replace config option with run-time arg")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/qede/qede_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index a4923670d6..e1d57723fa 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -1211,6 +1211,9 @@ static int qede_args_check(const char *key, const char *val, void *opaque)
struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
+ if (val == NULL)
+ return -EINVAL;
+
errno = 0;
tmp = strtoul(val, NULL, 0);
if (errno) {
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 28/44] baseband/la12xx: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (26 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 27/44] net/qede: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 29/44] bus/pci: fix segment fault when parse args Chengwen Feng
` (16 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Gagandeep Singh, Hemant Agrawal,
Nicolas Chautru, Akhil Goyal
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 915cdc075dba ("baseband/la12xx: support multiple modems")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/baseband/la12xx/bbdev_la12xx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c b/drivers/baseband/la12xx/bbdev_la12xx.c
index bb754a5395..19c526ddd7 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -936,6 +936,9 @@ parse_integer_arg(const char *key __rte_unused,
int i;
char *end;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
i = strtol(value, &end, 10);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 29/44] bus/pci: fix segment fault when parse args
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (27 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 28/44] baseband/la12xx: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 30/44] common/mlx5: fix segment fault when parse devargs Chengwen Feng
` (15 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Gaetan Rivet; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 4410c1b0c0a2 ("bus/pci: add iteration filter on address")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/bus/pci/pci_params.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c
index d24cc201b8..b8bee6a6c1 100644
--- a/drivers/bus/pci/pci_params.c
+++ b/drivers/bus/pci/pci_params.c
@@ -34,6 +34,8 @@ pci_addr_kv_cmp(const char *key __rte_unused,
struct rte_pci_addr *addr1 = &_addr1;
struct rte_pci_addr *addr2 = _addr2;
+ if (value == NULL)
+ return -EINVAL;
if (rte_pci_addr_parse(value, addr1))
return -1;
return -abs(rte_pci_addr_cmp(addr1, addr2));
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 30/44] common/mlx5: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (28 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 29/44] bus/pci: fix segment fault when parse args Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 31/44] crypto/cnxk: " Chengwen Feng
` (14 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Matan Azrad, Viacheslav Ovsiienko, Xueming Li; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: ad435d320473 ("common/mlx5: add bus-agnostic layer")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/common/mlx5/mlx5_common.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 0ad14a48c7..e4cf829c14 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -365,6 +365,11 @@ devargs_class_handler(__rte_unused const char *key,
char *found;
char *refstr = NULL;
+ if (class_names == NULL) {
+ *ret = -EINVAL;
+ return *ret;
+ }
+
*ret = 0;
scratch = strdup(class_names);
if (scratch == NULL) {
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 31/44] crypto/cnxk: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (29 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 30/44] common/mlx5: fix segment fault when parse devargs Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 32/44] crypto/dpaa_sec: " Chengwen Feng
` (13 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Ankur Dwivedi, Anoob Joseph,
Tejasree Kondoj, Jerin Jacob
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 135e0b71fa30 ("crypto/cnxk: add max queue pairs limit option")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/crypto/cnxk/cnxk_cryptodev_devargs.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c b/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c
index c3e9bdb2d1..936bf8fbf4 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c
@@ -16,6 +16,9 @@ parse_max_qps_limit(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = atoi(value);
if (val < CNXK_MAX_QPS_LIMIT_MIN || val > CNXK_MAX_QPS_LIMIT_MAX)
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 32/44] crypto/dpaa_sec: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (30 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 31/44] crypto/cnxk: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 33/44] crypto/dpaa2_sec: " Chengwen Feng
` (12 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Gagandeep Singh, Hemant Agrawal; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: b1bbf222bef1 ("crypto/dpaa_sec: add debug prints")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/crypto/dpaa_sec/dpaa_sec.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index db52683847..2e2940f011 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -3584,6 +3584,9 @@ static int
check_devargs_handler(__rte_unused const char *key, const char *value,
__rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
dpaa_sec_dp_dump = atoi(value);
if (dpaa_sec_dp_dump > DPAA_SEC_DP_FULL_DUMP) {
DPAA_SEC_WARN("WARN: DPAA_SEC_DP_DUMP_LEVEL is not "
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 33/44] crypto/dpaa2_sec: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (31 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 32/44] crypto/dpaa_sec: " Chengwen Feng
@ 2023-03-20 9:20 ` Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 34/44] crypto/mvsam: " Chengwen Feng
` (11 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:20 UTC (permalink / raw)
To: thomas, ferruh.yigit, Gagandeep Singh, Hemant Agrawal, Nipun Gupta; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 4562de326d30 ("crypto/dpaa2_sec: support ordered queue")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 392bf74856..3b2927361f 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -4242,6 +4242,8 @@ check_devargs_handler(const char *key, const char *value,
if (!strcmp(key, "drv_strict_order")) {
priv->en_loose_ordered = false;
} else if (!strcmp(key, "drv_dump_mode")) {
+ if (value == NULL)
+ return -EINVAL;
dpaa2_sec_dp_dump = atoi(value);
if (dpaa2_sec_dp_dump > DPAA2_SEC_DP_FULL_DUMP) {
DPAA2_SEC_WARN("WARN: DPAA2_SEC_DP_DUMP_LEVEL is not "
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 34/44] crypto/mvsam: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (32 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 33/44] crypto/dpaa2_sec: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-20 9:33 ` [EXT] " Liron Himi
2023-03-20 9:21 ` [PATCH v2 35/44] crypto/scheduler: " Chengwen Feng
` (10 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Michael Shamis, Liron Himi, Pablo de Lara,
Tomasz Duszynski
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 25b05a1c806b ("crypto/mvsam: parse max number of sessions")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/crypto/mvsam/rte_mrvl_pmd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c
index 1641da9ca6..8f99197beb 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c
@@ -1126,6 +1126,9 @@ parse_integer_arg(const char *key __rte_unused,
{
int *i = (int *) extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
*i = atoi(value);
if (*i < 0) {
MRVL_LOG(ERR, "Argument has to be positive!");
@@ -1142,6 +1145,9 @@ parse_name_arg(const char *key __rte_unused,
{
struct rte_cryptodev_pmd_init_params *params = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) {
MRVL_LOG(ERR, "Invalid name %s, should be less than %u bytes!",
value, RTE_CRYPTODEV_NAME_MAX_LEN - 1);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 35/44] crypto/scheduler: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (33 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 34/44] crypto/mvsam: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 36/44] dma/dpaa2: " Chengwen Feng
` (9 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Kai Ji, Pablo de Lara, Fan Zhang,
Kirill Rybalchenko, Declan Doherty
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 503e9c5afb38 ("crypto/scheduler: register as vdev driver")
Fixes: 4c07e0552f0a ("crypto/scheduler: add multicore scheduling mode")
Fixes: a0e805ee086a ("crypto/scheduler: add more options")
Fixes: ee9586dd15fb ("crypto/scheduler: add mode-specific parameter")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/crypto/scheduler/scheduler_pmd.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c
index 9d1ce46622..7fa8bef4f2 100644
--- a/drivers/crypto/scheduler/scheduler_pmd.c
+++ b/drivers/crypto/scheduler/scheduler_pmd.c
@@ -272,6 +272,9 @@ parse_integer_arg(const char *key __rte_unused,
{
int *i = (int *) extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
*i = atoi(value);
if (*i < 0) {
CR_SCHED_LOG(ERR, "Argument has to be positive.");
@@ -338,6 +341,9 @@ parse_corelist_arg(const char *key __rte_unused,
{
struct scheduler_init_params *params = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
params->nb_wc = 0;
const char *token = value;
@@ -367,6 +373,9 @@ parse_name_arg(const char *key __rte_unused,
{
struct rte_cryptodev_pmd_init_params *params = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) {
CR_SCHED_LOG(ERR, "Invalid name %s, should be less than "
"%u bytes.", value,
@@ -386,6 +395,9 @@ parse_worker_arg(const char *key __rte_unused,
{
struct scheduler_init_params *param = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (param->nb_workers >= RTE_CRYPTODEV_SCHEDULER_MAX_NB_WORKERS) {
CR_SCHED_LOG(ERR, "Too many workers.");
return -ENOMEM;
@@ -404,6 +416,9 @@ parse_mode_arg(const char *key __rte_unused,
struct scheduler_init_params *param = extra_args;
uint32_t i;
+ if (value == NULL)
+ return -EINVAL;
+
for (i = 0; i < RTE_DIM(scheduler_mode_map); i++) {
if (strcmp(value, scheduler_mode_map[i].name) == 0) {
param->mode = (enum rte_cryptodev_scheduler_mode)
@@ -427,6 +442,9 @@ parse_mode_param_arg(const char *key __rte_unused,
{
struct scheduler_init_params *param = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
strlcpy(param->mode_param_str, value,
RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN);
@@ -440,6 +458,9 @@ parse_ordering_arg(const char *key __rte_unused,
struct scheduler_init_params *param = extra_args;
uint32_t i;
+ if (value == NULL)
+ return -EINVAL;
+
for (i = 0; i < RTE_DIM(scheduler_ordering_map); i++) {
if (strcmp(value, scheduler_ordering_map[i].name) == 0) {
param->enable_ordering =
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 36/44] dma/dpaa2: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (34 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 35/44] crypto/scheduler: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 37/44] event/cnxk: " Chengwen Feng
` (8 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Gagandeep Singh, Hemant Agrawal, Nipun Gupta; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 9e2f8ca6c224 ("dma/dpaa2: support DMA operations")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/dma/dpaa2/dpaa2_qdma.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/dma/dpaa2/dpaa2_qdma.c b/drivers/dma/dpaa2/dpaa2_qdma.c
index d5a5f08ecc..14c0d28181 100644
--- a/drivers/dma/dpaa2/dpaa2_qdma.c
+++ b/drivers/dma/dpaa2/dpaa2_qdma.c
@@ -1169,6 +1169,9 @@ check_devargs_handler(__rte_unused const char *key,
const char *value,
__rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "1"))
return -1;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 37/44] event/cnxk: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (35 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 36/44] dma/dpaa2: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 38/44] event/dlb2: " Chengwen Feng
` (7 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Pavan Nikhilesh, Shijith Thotton; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 38c2e3240ba8 ("event/cnxk: add option to control SSO HWGRP QoS")
Fixes: 20345cbda6d3 ("event/cnxk: support WQE stashing")
Fixes: 1b06a817b835 ("event/cnxk: add option to disable NPA")
Fixes: e656d40fd12f ("event/cnxk: add option for in-flight buffer count")
Fixes: 8a3d58c189fd ("event/cnxk: add option to control timer adapters")
Fixes: 8bdbae66b299 ("event/cnxk: add external clock support for timer")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/event/cnxk/cnxk_eventdev.c | 6 ++++++
drivers/event/cnxk/cnxk_eventdev.h | 6 ++++++
drivers/event/cnxk/cnxk_tim_evdev.c | 6 ++++++
3 files changed, 18 insertions(+)
diff --git a/drivers/event/cnxk/cnxk_eventdev.c b/drivers/event/cnxk/cnxk_eventdev.c
index cb9ba5d353..970681adfc 100644
--- a/drivers/event/cnxk/cnxk_eventdev.c
+++ b/drivers/event/cnxk/cnxk_eventdev.c
@@ -565,6 +565,9 @@ parse_sso_kvargs_qos_dict(const char *key, const char *value, void *opaque)
{
RTE_SET_USED(key);
+ if (value == NULL)
+ return -EINVAL;
+
/* Dict format [Qx-TAQ-IAQ][Qz-TAQ-IAQ] use '-' cause ',' isn't allowed.
* Everything is expressed in percentages, 0 represents default.
*/
@@ -578,6 +581,9 @@ parse_sso_kvargs_stash_dict(const char *key, const char *value, void *opaque)
{
RTE_SET_USED(key);
+ if (value == NULL)
+ return -EINVAL;
+
/* Dict format [Qx|<stash_offset>|<stash_length>] use '|' cause ','
* isn't allowed.
*/
diff --git a/drivers/event/cnxk/cnxk_eventdev.h b/drivers/event/cnxk/cnxk_eventdev.h
index c7cbd722ab..acd705183c 100644
--- a/drivers/event/cnxk/cnxk_eventdev.h
+++ b/drivers/event/cnxk/cnxk_eventdev.h
@@ -169,6 +169,9 @@ parse_kvargs_flag(const char *key, const char *value, void *opaque)
{
RTE_SET_USED(key);
+ if (value == NULL)
+ return -EINVAL;
+
*(uint8_t *)opaque = !!atoi(value);
return 0;
}
@@ -178,6 +181,9 @@ parse_kvargs_value(const char *key, const char *value, void *opaque)
{
RTE_SET_USED(key);
+ if (value == NULL)
+ return -EINVAL;
+
*(uint32_t *)opaque = (uint32_t)atoi(value);
return 0;
}
diff --git a/drivers/event/cnxk/cnxk_tim_evdev.c b/drivers/event/cnxk/cnxk_tim_evdev.c
index 121480df15..e5450fd9bf 100644
--- a/drivers/event/cnxk/cnxk_tim_evdev.c
+++ b/drivers/event/cnxk/cnxk_tim_evdev.c
@@ -490,6 +490,9 @@ cnxk_tim_parse_kvargs_dict(const char *key, const char *value, void *opaque)
{
RTE_SET_USED(key);
+ if (value == NULL)
+ return -EINVAL;
+
/* Dict format [ring-chunk_sz-disable_npa-enable_stats] use '-' as ','
* isn't allowed. 0 represents default.
*/
@@ -528,6 +531,9 @@ cnxk_tim_parse_kvargs_dsv(const char *key, const char *value, void *opaque)
{
RTE_SET_USED(key);
+ if (value == NULL)
+ return -EINVAL;
+
/* DSV format GPIO-PTP-SYNCE-BTS use '-' as ','
* isn't allowed. 0 represents default.
*/
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 38/44] event/dlb2: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (36 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 37/44] event/cnxk: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-24 16:26 ` Sevincer, Abdullah
2023-03-20 9:21 ` [PATCH v2 39/44] event/dpaa: " Chengwen Feng
` (6 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Timothy McDaniel, Abdullah Sevincer; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 8d1d9070bbe9 ("event/dlb2: optimize producer port probing")
Fixes: bec8901bfe9f ("event/dlb2: support ldb port specific COS")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/event/dlb2/dlb2.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index 60c5cd4804..d436cf852a 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -329,6 +329,9 @@ set_numa_node(const char *key __rte_unused, const char *value, void *opaque)
int *socket_id = opaque;
int ret;
+ if (value == NULL)
+ return -EINVAL;
+
ret = dlb2_string_to_int(socket_id, value);
if (ret < 0)
return ret;
@@ -542,7 +545,7 @@ set_cos_bw(const char *key __rte_unused,
{
struct dlb2_cos_bw *cos_bw = opaque;
- if (opaque == NULL) {
+ if (value == NULL || opaque == NULL) {
DLB2_LOG_ERR("NULL pointer\n");
return -EINVAL;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 39/44] event/dpaa: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (37 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 38/44] event/dlb2: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 40/44] event/octeontx: " Chengwen Feng
` (5 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Hemant Agrawal, Sachin Saxena; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 77b5311d0ece ("event/dpaa: support select based event")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/event/dpaa/dpaa_eventdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/event/dpaa/dpaa_eventdev.c b/drivers/event/dpaa/dpaa_eventdev.c
index 4b3d16735b..0d5593e862 100644
--- a/drivers/event/dpaa/dpaa_eventdev.c
+++ b/drivers/event/dpaa/dpaa_eventdev.c
@@ -959,6 +959,9 @@ static struct eventdev_ops dpaa_eventdev_ops = {
static int flag_check_handler(__rte_unused const char *key,
const char *value, __rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "1"))
return -1;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 40/44] event/octeontx: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (38 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 39/44] event/dpaa: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 41/44] event/opdl: " Chengwen Feng
` (4 subsequent siblings)
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Jerin Jacob, Pavan Nikhilesh; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 3516327e00fd ("event/octeontx: add selftest to device arguments")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/event/octeontx/ssovf_evdev.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 650266b996..b9b5fa8668 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -717,6 +717,8 @@ static int
ssovf_parsekv(const char *key __rte_unused, const char *value, void *opaque)
{
int *flag = opaque;
+ if (value == NULL)
+ return -EINVAL;
*flag = !!atoi(value);
return 0;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 41/44] event/opdl: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (39 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 40/44] event/octeontx: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-23 13:48 ` Liang Ma
2023-03-20 9:21 ` [PATCH v2 42/44] event/sw: " Chengwen Feng
` (3 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Liang Ma, Peter Mccarthy; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 3c7f3dcfb099 ("event/opdl: add PMD main body and helper function")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/event/opdl/opdl_evdev.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index 9ce8b39b60..f90d31aa19 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -580,6 +580,8 @@ static int
assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
{
int *socket_id = opaque;
+ if (value == NULL)
+ return -EINVAL;
*socket_id = atoi(value);
if (*socket_id >= RTE_MAX_NUMA_NODES)
return -1;
@@ -590,6 +592,10 @@ static int
set_do_validation(const char *key __rte_unused, const char *value, void *opaque)
{
int *do_val = opaque;
+
+ if (value == NULL)
+ return -EINVAL;
+
*do_val = atoi(value);
if (*do_val != 0)
*do_val = 1;
@@ -601,6 +607,9 @@ set_do_test(const char *key __rte_unused, const char *value, void *opaque)
{
int *do_test = opaque;
+ if (value == NULL)
+ return -EINVAL;
+
*do_test = atoi(value);
if (*do_test != 0)
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 42/44] event/sw: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (40 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 41/44] event/opdl: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-20 11:58 ` Van Haaren, Harry
2023-03-20 9:21 ` [PATCH v2 43/44] mempool/cnxk: " Chengwen Feng
` (2 subsequent siblings)
44 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Harry van Haaren, Bruce Richardson,
Jerin Jacob, Radu Nicolau
Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: aaa4a221da26 ("event/sw: add new software-only eventdev driver")
Fixes: 70207f35e21f ("event/sw: improve performance")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/event/sw/sw_evdev.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index cfd659d774..524a84c244 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -875,6 +875,8 @@ static int
assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
{
int *socket_id = opaque;
+ if (value == NULL)
+ return -EINVAL;
*socket_id = atoi(value);
if (*socket_id >= RTE_MAX_NUMA_NODES)
return -1;
@@ -885,6 +887,8 @@ static int
set_sched_quanta(const char *key __rte_unused, const char *value, void *opaque)
{
int *quanta = opaque;
+ if (value == NULL)
+ return -EINVAL;
*quanta = atoi(value);
if (*quanta < 0 || *quanta >= 4096)
return -1;
@@ -895,6 +899,8 @@ static int
set_credit_quanta(const char *key __rte_unused, const char *value, void *opaque)
{
int *credit = opaque;
+ if (value == NULL)
+ return -EINVAL;
*credit = atoi(value);
if (*credit < 0 || *credit >= 128)
return -1;
@@ -905,6 +911,8 @@ static int
set_deq_burst_sz(const char *key __rte_unused, const char *value, void *opaque)
{
int *deq_burst_sz = opaque;
+ if (value == NULL)
+ return -EINVAL;
*deq_burst_sz = atoi(value);
if (*deq_burst_sz < 0 || *deq_burst_sz > SCHED_DEQUEUE_MAX_BURST_SIZE)
return -1;
@@ -915,6 +923,8 @@ static int
set_min_burst_sz(const char *key __rte_unused, const char *value, void *opaque)
{
int *min_burst_sz = opaque;
+ if (value == NULL)
+ return -EINVAL;
*min_burst_sz = atoi(value);
if (*min_burst_sz < 0 || *min_burst_sz > SCHED_DEQUEUE_MAX_BURST_SIZE)
return -1;
@@ -925,6 +935,8 @@ static int
set_refill_once(const char *key __rte_unused, const char *value, void *opaque)
{
int *refill_once_per_call = opaque;
+ if (value == NULL)
+ return -EINVAL;
*refill_once_per_call = atoi(value);
if (*refill_once_per_call < 0 || *refill_once_per_call > 1)
return -1;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 43/44] mempool/cnxk: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (41 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 42/44] event/sw: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 44/44] raw/cnxk_gpio: " Chengwen Feng
2023-04-15 1:38 ` [PATCH v2 00/44] fix segment fault when parse args fengchengwen
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Ashwin Sekhar T K, Pavan Nikhilesh; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 0a50a5aad299 ("mempool/cnxk: add device probe/remove")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/mempool/cnxk/cnxk_mempool.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mempool/cnxk/cnxk_mempool.c b/drivers/mempool/cnxk/cnxk_mempool.c
index 78caf987d0..d803e5928d 100644
--- a/drivers/mempool/cnxk/cnxk_mempool.c
+++ b/drivers/mempool/cnxk/cnxk_mempool.c
@@ -36,6 +36,9 @@ parse_max_pools_handler(const char *key, const char *value, void *extra_args)
RTE_SET_USED(key);
uint32_t val;
+ if (value == NULL)
+ return -EINVAL;
+
val = rte_align32pow2(atoi(value));
if (val < npa_aura_size_to_u32(NPA_AURA_SZ_128))
val = 128;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v2 44/44] raw/cnxk_gpio: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (42 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 43/44] mempool/cnxk: " Chengwen Feng
@ 2023-03-20 9:21 ` Chengwen Feng
2023-04-15 1:38 ` [PATCH v2 00/44] fix segment fault when parse args fengchengwen
44 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-03-20 9:21 UTC (permalink / raw)
To: thomas, ferruh.yigit, Jakub Palider, Tomasz Duszynski, Jerin Jacob; +Cc: dev
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: d0b8a4e19131 ("raw/cnxk_gpio: add GPIO driver skeleton")
Fixes: ecc0dd455e9a ("raw/cnxk_gpio: add option to select subset of GPIOs")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/raw/cnxk_gpio/cnxk_gpio.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index e2907c18b5..5a28e307d2 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -67,6 +67,9 @@ cnxk_gpio_parse_arg_gpiochip(const char *key __rte_unused, const char *value,
{
long val;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
val = strtol(value, NULL, 10);
if (errno)
@@ -81,6 +84,9 @@ static int
cnxk_gpio_parse_arg_allowlist(const char *key __rte_unused, const char *value,
void *extra_args __rte_unused)
{
+ if (value == NULL)
+ return -EINVAL;
+
allowlist = strdup(value);
if (!allowlist)
return -ENOMEM;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* RE: [EXT] [PATCH v2 34/44] crypto/mvsam: fix segment fault when parse devargs
2023-03-20 9:21 ` [PATCH v2 34/44] crypto/mvsam: " Chengwen Feng
@ 2023-03-20 9:33 ` Liron Himi
0 siblings, 0 replies; 131+ messages in thread
From: Liron Himi @ 2023-03-20 9:33 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, Michael Shamis,
Pablo de Lara, Tomasz Duszynski
Cc: dev, Liron Himi
Acked-by: Liron Himi <lironh@marvell.com>
-----Original Message-----
From: Chengwen Feng <fengchengwen@huawei.com>
Sent: Monday, 20 March 2023 11:21
To: thomas@monjalon.net; ferruh.yigit@amd.com; Michael Shamis <michaelsh@marvell.com>; Liron Himi <lironh@marvell.com>; Pablo de Lara <pablo.de.lara.guarch@intel.com>; Tomasz Duszynski <tduszynski@marvell.com>
Cc: dev@dpdk.org
Subject: [EXT] [PATCH v2 34/44] crypto/mvsam: fix segment fault when parse devargs
External Email
----------------------------------------------------------------------
The rte_kvargs_process() was used to parse KV pairs, it also supports to parse 'only keys' (e.g. socket_id) type. And the callback function parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 25b05a1c806b ("crypto/mvsam: parse max number of sessions")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/crypto/mvsam/rte_mrvl_pmd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c
index 1641da9ca6..8f99197beb 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c
@@ -1126,6 +1126,9 @@ parse_integer_arg(const char *key __rte_unused, {
int *i = (int *) extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
*i = atoi(value);
if (*i < 0) {
MRVL_LOG(ERR, "Argument has to be positive!"); @@ -1142,6 +1145,9 @@ parse_name_arg(const char *key __rte_unused, {
struct rte_cryptodev_pmd_init_params *params = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) {
MRVL_LOG(ERR, "Invalid name %s, should be less than %u bytes!",
value, RTE_CRYPTODEV_NAME_MAX_LEN - 1);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* RE: [EXT] [PATCH v2 23/44] net/mvpp2: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 23/44] net/mvpp2: " Chengwen Feng
@ 2023-03-20 9:33 ` Liron Himi
0 siblings, 0 replies; 131+ messages in thread
From: Liron Himi @ 2023-03-20 9:33 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, Tomasz Duszynski, Jacek Siuda
Cc: dev, Liron Himi
Acked-by: Liron Himi <lironh@marvell.com>
-----Original Message-----
From: Chengwen Feng <fengchengwen@huawei.com>
Sent: Monday, 20 March 2023 11:21
To: thomas@monjalon.net; ferruh.yigit@amd.com; Liron Himi <lironh@marvell.com>; Tomasz Duszynski <tduszynski@marvell.com>; Jacek Siuda <jck@semihalf.com>
Cc: dev@dpdk.org
Subject: [EXT] [PATCH v2 23/44] net/mvpp2: fix segment fault when parse devargs
External Email
----------------------------------------------------------------------
The rte_kvargs_process() was used to parse KV pairs, it also supports to parse 'only keys' (e.g. socket_id) type. And the callback function parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 0ddc9b815b11 ("net/mrvl: add net PMD skeleton")
Fixes: c2b5ae61c07e ("net/mvpp2: support DSA mode")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/mvpp2/mrvl_ethdev.c | 3 +++
drivers/net/mvpp2/mrvl_qos.c | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 89c83f1c1f..a631d6d9cc 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -3180,6 +3180,9 @@ mrvl_get_ifnames(const char *key __rte_unused, const char *value, {
struct mrvl_ifnames *ifnames = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
ifnames->names[ifnames->idx++] = value;
return 0;
diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c index f43217bc58..f217a8d71a 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -656,12 +656,16 @@ int
mrvl_get_cfg(const char *key __rte_unused, const char *path, void *extra_args) {
struct mrvl_cfg **cfg = extra_args;
- struct rte_cfgfile *file = rte_cfgfile_load(path, 0);
+ struct rte_cfgfile *file;
uint32_t val;
int n, i, ret;
const char *entry;
char sec_name[32];
+ if (path == NULL)
+ return -EINVAL;
+
+ file = rte_cfgfile_load(path, 0);
if (file == NULL) {
MRVL_LOG(ERR, "Cannot load configuration %s\n", path);
return -1;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* RE: [EXT] [PATCH v2 22/44] net/mvneta: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 22/44] net/mvneta: " Chengwen Feng
@ 2023-03-20 9:33 ` Liron Himi
0 siblings, 0 replies; 131+ messages in thread
From: Liron Himi @ 2023-03-20 9:33 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, Zyta Szpak, Dmitri Epshtein,
Natalie Samsonov, Andrzej Ostruszka, Yelena Krivosheev
Cc: dev, Liron Himi
Acked-by: Liron Himi <lironh@marvell.com>
-----Original Message-----
From: Chengwen Feng <fengchengwen@huawei.com>
Sent: Monday, 20 March 2023 11:21
To: thomas@monjalon.net; ferruh.yigit@amd.com; Zyta Szpak <zr@semihalf.com>; Liron Himi <lironh@marvell.com>; Dmitri Epshtein <dima@marvell.com>; Natalie Samsonov <nsamsono@marvell.com>; Andrzej Ostruszka <amo@semihalf.com>; Yelena Krivosheev <yelena@marvell.com>
Cc: dev@dpdk.org
Subject: [EXT] [PATCH v2 22/44] net/mvneta: fix segment fault when parse devargs
External Email
----------------------------------------------------------------------
The rte_kvargs_process() was used to parse KV pairs, it also supports to parse 'only keys' (e.g. socket_id) type. And the callback function parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 4ccc8d770d3b ("net/mvneta: add PMD skeleton")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/mvneta/mvneta_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index d7953ac7cb..babe825ff9 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -91,6 +91,9 @@ mvneta_ifnames_get(const char *key __rte_unused, const char *value, {
struct mvneta_ifnames *ifnames = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
ifnames->names[ifnames->idx++] = value;
return 0;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* RE: [PATCH v2 42/44] event/sw: fix segment fault when parse devargs
2023-03-20 9:21 ` [PATCH v2 42/44] event/sw: " Chengwen Feng
@ 2023-03-20 11:58 ` Van Haaren, Harry
0 siblings, 0 replies; 131+ messages in thread
From: Van Haaren, Harry @ 2023-03-20 11:58 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, Richardson, Bruce,
Jerin Jacob, Nicolau, Radu
Cc: dev
> -----Original Message-----
> From: Chengwen Feng <fengchengwen@huawei.com>
> Sent: Monday, March 20, 2023 9:21 AM
> To: thomas@monjalon.net; ferruh.yigit@amd.com; Van Haaren, Harry
> <harry.van.haaren@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>; Jerin Jacob <jerin.jacob@caviumnetworks.com>;
> Nicolau, Radu <radu.nicolau@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH v2 42/44] event/sw: fix segment fault when parse devargs
>
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: aaa4a221da26 ("event/sw: add new software-only eventdev driver")
> Fixes: 70207f35e21f ("event/sw: improve performance")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v2 13/44] net/enic: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 13/44] net/enic: " Chengwen Feng
@ 2023-03-20 21:37 ` John Daley (johndale)
0 siblings, 0 replies; 131+ messages in thread
From: John Daley (johndale) @ 2023-03-20 21:37 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, Hyong Youb Kim (hyonkim); +Cc: dev
[-- Attachment #1: Type: text/plain, Size: 1869 bytes --]
Reviewed-by: John Daley johndale@cisco.com<mailto:johndale@cisco.com>
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Monday, March 20, 2023 at 2:28 AM
To: thomas@monjalon.net <thomas@monjalon.net>, ferruh.yigit@amd.com <ferruh.yigit@amd.com>, John Daley (johndale) <johndale@cisco.com>, Hyong Youb Kim (hyonkim) <hyonkim@cisco.com>
Cc: dev@dpdk.org <dev@dpdk.org>
Subject: [PATCH v2 13/44] net/enic: fix segment fault when parse devargs
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 93fb21fdbe23 ("net/enic: enable overlay offload for VXLAN and GENEVE")
Fixes: e39c2756e21a ("net/enic: add devarg to specify ingress VLAN rewrite mode")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/enic/enic_ethdev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index cdf0915591..b67016e0a3 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -1148,6 +1148,9 @@ static int enic_parse_zero_one(const char *key,
struct enic *enic;
bool b;
+ if (value == NULL)
+ return -EINVAL;
+
enic = (struct enic *)opaque;
if (strcmp(value, "0") == 0) {
b = false;
@@ -1173,6 +1176,9 @@ static int enic_parse_ig_vlan_rewrite(__rte_unused const char *key,
{
struct enic *enic;
+ if (value == NULL)
+ return -EINVAL;
+
enic = (struct enic *)opaque;
if (strcmp(value, "trunk") == 0) {
/* Trunk mode: always tag */
--
2.17.1
[-- Attachment #2: Type: text/html, Size: 4776 bytes --]
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 0/5] fix segment fault when parse args
2023-03-17 2:43 ` fengchengwen
@ 2023-03-21 13:50 ` Ferruh Yigit
2023-03-22 1:15 ` fengchengwen
0 siblings, 1 reply; 131+ messages in thread
From: Ferruh Yigit @ 2023-03-21 13:50 UTC (permalink / raw)
To: fengchengwen, thomas, Olivier Matz; +Cc: dev, David Marchand
On 3/17/2023 2:43 AM, fengchengwen wrote:
> On 2023/3/17 2:18, Ferruh Yigit wrote:
>> On 3/14/2023 12:48 PM, Chengwen Feng wrote:
>>> The rte_kvargs_process() was used to parse KV pairs, it also supports
>>> to parse 'only keys' (e.g. socket_id) type. And the callback function
>>> parameter 'value' is NULL when parsed 'only keys'.
>>>
>>> It may leads to segment fault when parse args with 'only key', this
>>> patchset fixes rest of them.
>>>
>>> Chengwen Feng (5):
>>> app/pdump: fix segment fault when parse args
>>> net/memif: fix segment fault when parse devargs
>>> net/pcap: fix segment fault when parse devargs
>>> net/ring: fix segment fault when parse devargs
>>> net/sfc: fix segment fault when parse devargs
>>
>> Hi Chengwen,
>>
>> Did you scan all `rte_kvargs_process()` instances?
>
> No, I was just looking at the modules I was concerned about.
> I looked at it briefly, and some modules had the same problem.
>
>>
>>
>> And if there would be a way to tell kvargs that a value is expected (or
>> not) this checks could be done in kvargs layer, I think this also can be
>> to look at.
>
> Yes, the way to tell kvargs may lead to a lot of modifys and also break ABI.
> I also think about just set value = "" when only exist key, It could perfectly solve the above segment scene.
> But it also break the API's behavior.
>
What about having a new API, like `rte_kvargs_process_extended()`,
That gets an additional flag as parameter, which may have values like
following to indicate if key expects a value or not:
ARG_MAY_HAVE_VALUE --> "key=value" OR 'key'
ARG_WITH_VALUE --> "key=value"
ARG_NO_VALUE --> 'key'
Default flag can be 'ARG_MAY_HAVE_VALUE' and it becomes same as
`rte_kvargs_process()`.
This way instead of adding checks, relevant usage can be replaced by
`rte_kvargs_process_extended()`, this requires similar amount of change
but code will be more clean I think.
Do you think does this work?
>
> Or continue fix the exist code (about 10+ place more),
> for new invoking, because the 'arg_handler_t' already well documented (52ab17efdecf935792ee1d0cb749c0dbd536c083),
> they'll take the initiative to prevent this.
>
>
> Hope for more advise for the next.
>
>> .
>>
^ permalink raw reply [flat|nested] 131+ messages in thread
* RE: [PATCH v2 20/44] net/mana: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 20/44] net/mana: " Chengwen Feng
@ 2023-03-21 22:19 ` Long Li
0 siblings, 0 replies; 131+ messages in thread
From: Long Li @ 2023-03-21 22:19 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit; +Cc: dev
> Subject: [PATCH v2 20/44] net/mana: fix segment fault when parse devargs
>
> The rte_kvargs_process() was used to parse KV pairs, it also supports to parse
> 'only keys' (e.g. socket_id) type. And the callback function parameter 'value' is
> NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: 517ed6e2d590 ("net/mana: add basic driver with build environment")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Long Li <longli@microsoft.com>
> ---
> drivers/net/mana/mana.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index
> 8a782c0d63..9c097c02ba 100644
> --- a/drivers/net/mana/mana.c
> +++ b/drivers/net/mana/mana.c
> @@ -750,6 +750,9 @@ mana_arg_parse_callback(const char *key, const char
> *val, void *private)
> return 1;
> }
>
> + if (val == NULL)
> + return -EINVAL;
> +
> ret = rte_ether_unformat_addr(val, &conf->mac_array[conf->index]);
> if (ret) {
> DRV_LOG(ERR, "Invalid MAC address %s", val);
> --
> 2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* RE: [PATCH v2 24/44] net/netvsc: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 24/44] net/netvsc: " Chengwen Feng
@ 2023-03-21 22:20 ` Long Li
2023-07-04 3:02 ` Stephen Hemminger
1 sibling, 0 replies; 131+ messages in thread
From: Long Li @ 2023-03-21 22:20 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, Stephen Hemminger; +Cc: dev
> Subject: [PATCH v2 24/44] net/netvsc: fix segment fault when parse devargs
>
> The rte_kvargs_process() was used to parse KV pairs, it also supports to parse
> 'only keys' (e.g. socket_id) type. And the callback function parameter 'value' is
> NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: a25d39a3eb69 ("net/netvsc: allow tuning latency with devargs")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Thank you.
Acked-by: Long Li <longli@microsoft.com>
> ---
> drivers/net/netvsc/hn_ethdev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
> index d0bbc0a4c0..e13eb03176 100644
> --- a/drivers/net/netvsc/hn_ethdev.c
> +++ b/drivers/net/netvsc/hn_ethdev.c
> @@ -157,6 +157,9 @@ static int hn_set_parameter(const char *key, const
> char *value, void *opaque)
> char *endp = NULL;
> unsigned long v;
>
> + if (value == NULL)
> + return -EINVAL;
> +
> v = strtoul(value, &endp, 0);
> if (*value == '\0' || *endp != '\0') {
> PMD_DRV_LOG(ERR, "invalid parameter %s=%s", key, value);
> --
> 2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 0/5] fix segment fault when parse args
2023-03-21 13:50 ` Ferruh Yigit
@ 2023-03-22 1:15 ` fengchengwen
2023-03-22 8:53 ` Ferruh Yigit
0 siblings, 1 reply; 131+ messages in thread
From: fengchengwen @ 2023-03-22 1:15 UTC (permalink / raw)
To: Ferruh Yigit, thomas, Olivier Matz; +Cc: dev, David Marchand
On 2023/3/21 21:50, Ferruh Yigit wrote:
> On 3/17/2023 2:43 AM, fengchengwen wrote:
>> On 2023/3/17 2:18, Ferruh Yigit wrote:
>>> On 3/14/2023 12:48 PM, Chengwen Feng wrote:
>>>> The rte_kvargs_process() was used to parse KV pairs, it also supports
>>>> to parse 'only keys' (e.g. socket_id) type. And the callback function
>>>> parameter 'value' is NULL when parsed 'only keys'.
>>>>
>>>> It may leads to segment fault when parse args with 'only key', this
>>>> patchset fixes rest of them.
>>>>
>>>> Chengwen Feng (5):
>>>> app/pdump: fix segment fault when parse args
>>>> net/memif: fix segment fault when parse devargs
>>>> net/pcap: fix segment fault when parse devargs
>>>> net/ring: fix segment fault when parse devargs
>>>> net/sfc: fix segment fault when parse devargs
>>>
>>> Hi Chengwen,
>>>
>>> Did you scan all `rte_kvargs_process()` instances?
>>
>> No, I was just looking at the modules I was concerned about.
>> I looked at it briefly, and some modules had the same problem.
>>
>>>
>>>
>>> And if there would be a way to tell kvargs that a value is expected (or
>>> not) this checks could be done in kvargs layer, I think this also can be
>>> to look at.
>>
>> Yes, the way to tell kvargs may lead to a lot of modifys and also break ABI.
>> I also think about just set value = "" when only exist key, It could perfectly solve the above segment scene.
>> But it also break the API's behavior.
>>
>
> What about having a new API, like `rte_kvargs_process_extended()`,
>
> That gets an additional flag as parameter, which may have values like
> following to indicate if key expects a value or not:
> ARG_MAY_HAVE_VALUE --> "key=value" OR 'key'
> ARG_WITH_VALUE --> "key=value"
> ARG_NO_VALUE --> 'key'
>
> Default flag can be 'ARG_MAY_HAVE_VALUE' and it becomes same as
> `rte_kvargs_process()`.
>
> This way instead of adding checks, relevant usage can be replaced by
> `rte_kvargs_process_extended()`, this requires similar amount of change
> but code will be more clean I think.
>
> Do you think does this work?
Yes, it can work.
But I think the introduction of new API adds some complexity.
And a good API definition could more simpler.
>
>
>>
>> Or continue fix the exist code (about 10+ place more),
>> for new invoking, because the 'arg_handler_t' already well documented (52ab17efdecf935792ee1d0cb749c0dbd536c083),
>> they'll take the initiative to prevent this.
>>
>>
>> Hope for more advise for the next.
>>
>>> .
>>>
>
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 0/5] fix segment fault when parse args
2023-03-22 1:15 ` fengchengwen
@ 2023-03-22 8:53 ` Ferruh Yigit
2023-03-22 13:49 ` Thomas Monjalon
0 siblings, 1 reply; 131+ messages in thread
From: Ferruh Yigit @ 2023-03-22 8:53 UTC (permalink / raw)
To: fengchengwen, thomas, Olivier Matz; +Cc: dev, David Marchand
On 3/22/2023 1:15 AM, fengchengwen wrote:
> On 2023/3/21 21:50, Ferruh Yigit wrote:
>> On 3/17/2023 2:43 AM, fengchengwen wrote:
>>> On 2023/3/17 2:18, Ferruh Yigit wrote:
>>>> On 3/14/2023 12:48 PM, Chengwen Feng wrote:
>>>>> The rte_kvargs_process() was used to parse KV pairs, it also supports
>>>>> to parse 'only keys' (e.g. socket_id) type. And the callback function
>>>>> parameter 'value' is NULL when parsed 'only keys'.
>>>>>
>>>>> It may leads to segment fault when parse args with 'only key', this
>>>>> patchset fixes rest of them.
>>>>>
>>>>> Chengwen Feng (5):
>>>>> app/pdump: fix segment fault when parse args
>>>>> net/memif: fix segment fault when parse devargs
>>>>> net/pcap: fix segment fault when parse devargs
>>>>> net/ring: fix segment fault when parse devargs
>>>>> net/sfc: fix segment fault when parse devargs
>>>>
>>>> Hi Chengwen,
>>>>
>>>> Did you scan all `rte_kvargs_process()` instances?
>>>
>>> No, I was just looking at the modules I was concerned about.
>>> I looked at it briefly, and some modules had the same problem.
>>>
>>>>
>>>>
>>>> And if there would be a way to tell kvargs that a value is expected (or
>>>> not) this checks could be done in kvargs layer, I think this also can be
>>>> to look at.
>>>
>>> Yes, the way to tell kvargs may lead to a lot of modifys and also break ABI.
>>> I also think about just set value = "" when only exist key, It could perfectly solve the above segment scene.
>>> But it also break the API's behavior.
>>>
>>
>> What about having a new API, like `rte_kvargs_process_extended()`,
>>
>> That gets an additional flag as parameter, which may have values like
>> following to indicate if key expects a value or not:
>> ARG_MAY_HAVE_VALUE --> "key=value" OR 'key'
>> ARG_WITH_VALUE --> "key=value"
>> ARG_NO_VALUE --> 'key'
>>
>> Default flag can be 'ARG_MAY_HAVE_VALUE' and it becomes same as
>> `rte_kvargs_process()`.
>>
>> This way instead of adding checks, relevant usage can be replaced by
>> `rte_kvargs_process_extended()`, this requires similar amount of change
>> but code will be more clean I think.
>>
>> Do you think does this work?
>
> Yes, it can work.
>
> But I think the introduction of new API adds some complexity.
> And a good API definition could more simpler.
>
Other option is changing existing API, but that may be widely used and
changing it impacts applications, I don't think it worth.
Of course we can live with as it is and add checks to the callback
functions, although I still believe a new 'process()' API is better idea.
>>
>>
>>>
>>> Or continue fix the exist code (about 10+ place more),
>>> for new invoking, because the 'arg_handler_t' already well documented (52ab17efdecf935792ee1d0cb749c0dbd536c083),
>>> they'll take the initiative to prevent this.
>>>
>>>
>>> Hope for more advise for the next.
>>>
>>>> .
>>>>
>>
>> .
>>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 0/5] fix segment fault when parse args
2023-03-22 8:53 ` Ferruh Yigit
@ 2023-03-22 13:49 ` Thomas Monjalon
2023-03-23 11:58 ` fengchengwen
0 siblings, 1 reply; 131+ messages in thread
From: Thomas Monjalon @ 2023-03-22 13:49 UTC (permalink / raw)
To: fengchengwen, Olivier Matz, Ferruh Yigit; +Cc: dev, David Marchand
22/03/2023 09:53, Ferruh Yigit:
> On 3/22/2023 1:15 AM, fengchengwen wrote:
> > On 2023/3/21 21:50, Ferruh Yigit wrote:
> >> On 3/17/2023 2:43 AM, fengchengwen wrote:
> >>> On 2023/3/17 2:18, Ferruh Yigit wrote:
> >>>> On 3/14/2023 12:48 PM, Chengwen Feng wrote:
> >>>>> The rte_kvargs_process() was used to parse KV pairs, it also supports
> >>>>> to parse 'only keys' (e.g. socket_id) type. And the callback function
> >>>>> parameter 'value' is NULL when parsed 'only keys'.
> >>>>>
> >>>>> It may leads to segment fault when parse args with 'only key', this
> >>>>> patchset fixes rest of them.
> >>>>>
> >>>>> Chengwen Feng (5):
> >>>>> app/pdump: fix segment fault when parse args
> >>>>> net/memif: fix segment fault when parse devargs
> >>>>> net/pcap: fix segment fault when parse devargs
> >>>>> net/ring: fix segment fault when parse devargs
> >>>>> net/sfc: fix segment fault when parse devargs
> >>>>
> >>>> Hi Chengwen,
> >>>>
> >>>> Did you scan all `rte_kvargs_process()` instances?
> >>>
> >>> No, I was just looking at the modules I was concerned about.
> >>> I looked at it briefly, and some modules had the same problem.
> >>>
> >>>>
> >>>>
> >>>> And if there would be a way to tell kvargs that a value is expected (or
> >>>> not) this checks could be done in kvargs layer, I think this also can be
> >>>> to look at.
> >>>
> >>> Yes, the way to tell kvargs may lead to a lot of modifys and also break ABI.
> >>> I also think about just set value = "" when only exist key, It could perfectly solve the above segment scene.
> >>> But it also break the API's behavior.
> >>>
> >>
> >> What about having a new API, like `rte_kvargs_process_extended()`,
> >>
> >> That gets an additional flag as parameter, which may have values like
> >> following to indicate if key expects a value or not:
> >> ARG_MAY_HAVE_VALUE --> "key=value" OR 'key'
> >> ARG_WITH_VALUE --> "key=value"
> >> ARG_NO_VALUE --> 'key'
> >>
> >> Default flag can be 'ARG_MAY_HAVE_VALUE' and it becomes same as
> >> `rte_kvargs_process()`.
> >>
> >> This way instead of adding checks, relevant usage can be replaced by
> >> `rte_kvargs_process_extended()`, this requires similar amount of change
> >> but code will be more clean I think.
> >>
> >> Do you think does this work?
> >
> > Yes, it can work.
> >
> > But I think the introduction of new API adds some complexity.
> > And a good API definition could more simpler.
> >
>
> Other option is changing existing API, but that may be widely used and
> changing it impacts applications, I don't think it worth.
I've planned a change in kvargs API 5 years ago and never did it:
From doc/guides/rel_notes/deprecation.rst:
"
* kvargs: The function ``rte_kvargs_process`` will get a new parameter
for returning key match count. It will ease handling of no-match case.
"
> Of course we can live with as it is and add checks to the callback
> functions, although I still believe a new 'process()' API is better idea.
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 0/5] fix segment fault when parse args
2023-03-22 13:49 ` Thomas Monjalon
@ 2023-03-23 11:58 ` fengchengwen
2023-03-23 12:51 ` Thomas Monjalon
0 siblings, 1 reply; 131+ messages in thread
From: fengchengwen @ 2023-03-23 11:58 UTC (permalink / raw)
To: Thomas Monjalon, Olivier Matz, Ferruh Yigit; +Cc: dev, David Marchand
On 2023/3/22 21:49, Thomas Monjalon wrote:
> 22/03/2023 09:53, Ferruh Yigit:
>> On 3/22/2023 1:15 AM, fengchengwen wrote:
>>> On 2023/3/21 21:50, Ferruh Yigit wrote:
>>>> On 3/17/2023 2:43 AM, fengchengwen wrote:
>>>>> On 2023/3/17 2:18, Ferruh Yigit wrote:
>>>>>> On 3/14/2023 12:48 PM, Chengwen Feng wrote:
>>>>>>> The rte_kvargs_process() was used to parse KV pairs, it also supports
>>>>>>> to parse 'only keys' (e.g. socket_id) type. And the callback function
>>>>>>> parameter 'value' is NULL when parsed 'only keys'.
>>>>>>>
>>>>>>> It may leads to segment fault when parse args with 'only key', this
>>>>>>> patchset fixes rest of them.
>>>>>>>
>>>>>>> Chengwen Feng (5):
>>>>>>> app/pdump: fix segment fault when parse args
>>>>>>> net/memif: fix segment fault when parse devargs
>>>>>>> net/pcap: fix segment fault when parse devargs
>>>>>>> net/ring: fix segment fault when parse devargs
>>>>>>> net/sfc: fix segment fault when parse devargs
>>>>>>
>>>>>> Hi Chengwen,
>>>>>>
>>>>>> Did you scan all `rte_kvargs_process()` instances?
>>>>>
>>>>> No, I was just looking at the modules I was concerned about.
>>>>> I looked at it briefly, and some modules had the same problem.
>>>>>
>>>>>>
>>>>>>
>>>>>> And if there would be a way to tell kvargs that a value is expected (or
>>>>>> not) this checks could be done in kvargs layer, I think this also can be
>>>>>> to look at.
>>>>>
>>>>> Yes, the way to tell kvargs may lead to a lot of modifys and also break ABI.
>>>>> I also think about just set value = "" when only exist key, It could perfectly solve the above segment scene.
>>>>> But it also break the API's behavior.
>>>>>
>>>>
>>>> What about having a new API, like `rte_kvargs_process_extended()`,
>>>>
>>>> That gets an additional flag as parameter, which may have values like
>>>> following to indicate if key expects a value or not:
>>>> ARG_MAY_HAVE_VALUE --> "key=value" OR 'key'
>>>> ARG_WITH_VALUE --> "key=value"
>>>> ARG_NO_VALUE --> 'key'
>>>>
>>>> Default flag can be 'ARG_MAY_HAVE_VALUE' and it becomes same as
>>>> `rte_kvargs_process()`.
>>>>
>>>> This way instead of adding checks, relevant usage can be replaced by
>>>> `rte_kvargs_process_extended()`, this requires similar amount of change
>>>> but code will be more clean I think.
>>>>
>>>> Do you think does this work?
>>>
>>> Yes, it can work.
>>>
>>> But I think the introduction of new API adds some complexity.
>>> And a good API definition could more simpler.
>>>
>>
>> Other option is changing existing API, but that may be widely used and
>> changing it impacts applications, I don't think it worth.
>
> I've planned a change in kvargs API 5 years ago and never did it:
>>From doc/guides/rel_notes/deprecation.rst:
> "
> * kvargs: The function ``rte_kvargs_process`` will get a new parameter
> for returning key match count. It will ease handling of no-match case.
> "
I think it's okay to add extra parameter for rte_kvargs_process. But it will
break ABI.
Also I notice patchset was deferred in patchwork.
Does it mean that the new version can't accept until the 23.11 release cycle ?
>
>> Of course we can live with as it is and add checks to the callback
>> functions, although I still believe a new 'process()' API is better idea.
>
>
>
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH 0/5] fix segment fault when parse args
2023-03-23 11:58 ` fengchengwen
@ 2023-03-23 12:51 ` Thomas Monjalon
0 siblings, 0 replies; 131+ messages in thread
From: Thomas Monjalon @ 2023-03-23 12:51 UTC (permalink / raw)
To: Olivier Matz, Ferruh Yigit, fengchengwen; +Cc: dev, David Marchand
23/03/2023 12:58, fengchengwen:
> On 2023/3/22 21:49, Thomas Monjalon wrote:
> > 22/03/2023 09:53, Ferruh Yigit:
> >> On 3/22/2023 1:15 AM, fengchengwen wrote:
> >>> On 2023/3/21 21:50, Ferruh Yigit wrote:
> >>>> On 3/17/2023 2:43 AM, fengchengwen wrote:
> >>>>> On 2023/3/17 2:18, Ferruh Yigit wrote:
> >>>>>> On 3/14/2023 12:48 PM, Chengwen Feng wrote:
> >>>>>>> The rte_kvargs_process() was used to parse KV pairs, it also supports
> >>>>>>> to parse 'only keys' (e.g. socket_id) type. And the callback function
> >>>>>>> parameter 'value' is NULL when parsed 'only keys'.
> >>>>>>>
> >>>>>>> It may leads to segment fault when parse args with 'only key', this
> >>>>>>> patchset fixes rest of them.
> >>>>>>>
> >>>>>>> Chengwen Feng (5):
> >>>>>>> app/pdump: fix segment fault when parse args
> >>>>>>> net/memif: fix segment fault when parse devargs
> >>>>>>> net/pcap: fix segment fault when parse devargs
> >>>>>>> net/ring: fix segment fault when parse devargs
> >>>>>>> net/sfc: fix segment fault when parse devargs
> >>>>>>
> >>>>>> Hi Chengwen,
> >>>>>>
> >>>>>> Did you scan all `rte_kvargs_process()` instances?
> >>>>>
> >>>>> No, I was just looking at the modules I was concerned about.
> >>>>> I looked at it briefly, and some modules had the same problem.
> >>>>>
> >>>>>>
> >>>>>>
> >>>>>> And if there would be a way to tell kvargs that a value is expected (or
> >>>>>> not) this checks could be done in kvargs layer, I think this also can be
> >>>>>> to look at.
> >>>>>
> >>>>> Yes, the way to tell kvargs may lead to a lot of modifys and also break ABI.
> >>>>> I also think about just set value = "" when only exist key, It could perfectly solve the above segment scene.
> >>>>> But it also break the API's behavior.
> >>>>>
> >>>>
> >>>> What about having a new API, like `rte_kvargs_process_extended()`,
> >>>>
> >>>> That gets an additional flag as parameter, which may have values like
> >>>> following to indicate if key expects a value or not:
> >>>> ARG_MAY_HAVE_VALUE --> "key=value" OR 'key'
> >>>> ARG_WITH_VALUE --> "key=value"
> >>>> ARG_NO_VALUE --> 'key'
> >>>>
> >>>> Default flag can be 'ARG_MAY_HAVE_VALUE' and it becomes same as
> >>>> `rte_kvargs_process()`.
> >>>>
> >>>> This way instead of adding checks, relevant usage can be replaced by
> >>>> `rte_kvargs_process_extended()`, this requires similar amount of change
> >>>> but code will be more clean I think.
> >>>>
> >>>> Do you think does this work?
> >>>
> >>> Yes, it can work.
> >>>
> >>> But I think the introduction of new API adds some complexity.
> >>> And a good API definition could more simpler.
> >>>
> >>
> >> Other option is changing existing API, but that may be widely used and
> >> changing it impacts applications, I don't think it worth.
> >
> > I've planned a change in kvargs API 5 years ago and never did it:
> >>From doc/guides/rel_notes/deprecation.rst:
> > "
> > * kvargs: The function ``rte_kvargs_process`` will get a new parameter
> > for returning key match count. It will ease handling of no-match case.
> > "
>
> I think it's okay to add extra parameter for rte_kvargs_process. But it will
> break ABI.
> Also I notice patchset was deferred in patchwork.
>
> Does it mean that the new version can't accept until the 23.11 release cycle ?
It is a bit too late to take a decision in 23.03 cycle.
Let's continue this discussion.
We can either have some fixes in 23.07 or have an ABI breaking change in 23.11.
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v2 41/44] event/opdl: fix segment fault when parse devargs
2023-03-20 9:21 ` [PATCH v2 41/44] event/opdl: " Chengwen Feng
@ 2023-03-23 13:48 ` Liang Ma
0 siblings, 0 replies; 131+ messages in thread
From: Liang Ma @ 2023-03-23 13:48 UTC (permalink / raw)
To: Chengwen Feng; +Cc: thomas, ferruh.yigit, Peter Mccarthy, dev
On Mon, Mar 20, 2023 at 09:21:07AM +0000, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: 3c7f3dcfb099 ("event/opdl: add PMD main body and helper function")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Liang Ma <liangma@liangbit.com>>
> ---
> drivers/event/opdl/opdl_evdev.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
> index 9ce8b39b60..f90d31aa19 100644
> --- a/drivers/event/opdl/opdl_evdev.c
> +++ b/drivers/event/opdl/opdl_evdev.c
> @@ -580,6 +580,8 @@ static int
> assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
> {
> int *socket_id = opaque;
> + if (value == NULL)
> + return -EINVAL;
> *socket_id = atoi(value);
> if (*socket_id >= RTE_MAX_NUMA_NODES)
> return -1;
> @@ -590,6 +592,10 @@ static int
> set_do_validation(const char *key __rte_unused, const char *value, void *opaque)
> {
> int *do_val = opaque;
> +
> + if (value == NULL)
> + return -EINVAL;
> +
> *do_val = atoi(value);
> if (*do_val != 0)
> *do_val = 1;
> @@ -601,6 +607,9 @@ set_do_test(const char *key __rte_unused, const char *value, void *opaque)
> {
> int *do_test = opaque;
>
> + if (value == NULL)
> + return -EINVAL;
> +
> *do_test = atoi(value);
>
> if (*do_test != 0)
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* RE: [PATCH v2 38/44] event/dlb2: fix segment fault when parse devargs
2023-03-20 9:21 ` [PATCH v2 38/44] event/dlb2: " Chengwen Feng
@ 2023-03-24 16:26 ` Sevincer, Abdullah
0 siblings, 0 replies; 131+ messages in thread
From: Sevincer, Abdullah @ 2023-03-24 16:26 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, McDaniel, Timothy; +Cc: dev
Acked-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
-----Original Message-----
From: Chengwen Feng <fengchengwen@huawei.com>
Sent: Monday, March 20, 2023 2:21 AM
To: thomas@monjalon.net; ferruh.yigit@amd.com; McDaniel, Timothy <timothy.mcdaniel@intel.com>; Sevincer, Abdullah <abdullah.sevincer@intel.com>
Cc: dev@dpdk.org
Subject: [PATCH v2 38/44] event/dlb2: fix segment fault when parse devargs
The rte_kvargs_process() was used to parse KV pairs, it also supports to parse 'only keys' (e.g. socket_id) type. And the callback function parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: 8d1d9070bbe9 ("event/dlb2: optimize producer port probing")
Fixes: bec8901bfe9f ("event/dlb2: support ldb port specific COS")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/event/dlb2/dlb2.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c index 60c5cd4804..d436cf852a 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -329,6 +329,9 @@ set_numa_node(const char *key __rte_unused, const char *value, void *opaque)
int *socket_id = opaque;
int ret;
+ if (value == NULL)
+ return -EINVAL;
+
ret = dlb2_string_to_int(socket_id, value);
if (ret < 0)
return ret;
@@ -542,7 +545,7 @@ set_cos_bw(const char *key __rte_unused, {
struct dlb2_cos_bw *cos_bw = opaque;
- if (opaque == NULL) {
+ if (value == NULL || opaque == NULL) {
DLB2_LOG_ERR("NULL pointer\n");
return -EINVAL;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v2 06/44] net/sfc: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 06/44] net/sfc: " Chengwen Feng
@ 2023-04-09 8:09 ` Andrew Rybchenko
0 siblings, 0 replies; 131+ messages in thread
From: Andrew Rybchenko @ 2023-04-09 8:09 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, Roman Zhukov, Andrew Lee,
Robert Stonehouse, Andy Moreton, Ferruh Yigit
Cc: dev
On 3/20/23 12:20, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: 9e7fc8b8f3be ("net/sfc: add device parameter to choose FW variant")
> Fixes: c22d3c508e0c ("net/sfc: support parameter to choose performance profile")
> Fixes: 63d588ff2692 ("net/sfc: libefx-based driver stub")
> Fixes: df1bfde4ff0d ("net/sfc: factor out libefx-based Rx datapath")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v2 02/44] ethdev: fix segment fault when parse args
2023-03-20 9:20 ` [PATCH v2 02/44] ethdev: " Chengwen Feng
@ 2023-04-09 8:10 ` Andrew Rybchenko
0 siblings, 0 replies; 131+ messages in thread
From: Andrew Rybchenko @ 2023-04-09 8:10 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit; +Cc: dev
On 3/20/23 12:20, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse args with 'only keys'
> (e.g. 'mac,representor').
>
> Fixes: c10cdce180a6 ("ethdev: support MAC address as iterator filter")
> Fixes: a7d3c6271d55 ("ethdev: support representor id as iterator filter")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
^ permalink raw reply [flat|nested] 131+ messages in thread
* RE: [EXT] [PATCH v2 25/44] net/octeontx: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 25/44] net/octeontx: " Chengwen Feng
@ 2023-04-12 7:54 ` Harman Kalra
0 siblings, 0 replies; 131+ messages in thread
From: Harman Kalra @ 2023-04-12 7:54 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit; +Cc: dev
Hi,
Thanks for fixing the seg fault.
Acked-by: Harman Kalra <hkalra@marvell.com>
Thanks
Harman
> -----Original Message-----
> From: Chengwen Feng <fengchengwen@huawei.com>
> Sent: Monday, March 20, 2023 2:51 PM
> To: thomas@monjalon.net; ferruh.yigit@amd.com; Harman Kalra
> <hkalra@marvell.com>; Santosh Shukla
> <santosh.shukla@caviumnetworks.com>; Jerin Jacob
> <jerin.jacob@caviumnetworks.com>
> Cc: dev@dpdk.org
> Subject: [EXT] [PATCH v2 25/44] net/octeontx: fix segment fault when parse
> devargs
>
> External Email
>
> ----------------------------------------------------------------------
> The rte_kvargs_process() was used to parse KV pairs, it also supports to
> parse 'only keys' (e.g. socket_id) type. And the callback function parameter
> 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: f7be70e5130e ("net/octeontx: add net device probe and remove")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> drivers/net/octeontx/octeontx_ethdev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/octeontx/octeontx_ethdev.c
> b/drivers/net/octeontx/octeontx_ethdev.c
> index d52a3e73d5..d11f359c7b 100644
> --- a/drivers/net/octeontx/octeontx_ethdev.c
> +++ b/drivers/net/octeontx/octeontx_ethdev.c
> @@ -70,6 +70,9 @@ parse_integer_arg(const char *key __rte_unused, {
> int *i = (int *)extra_args;
>
> + if (value == NULL)
> + return -EINVAL;
> +
> *i = atoi(value);
> if (*i < 0) {
> octeontx_log_err("argument has to be positive.");
> --
> 2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v2 00/44] fix segment fault when parse args
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
` (43 preceding siblings ...)
2023-03-20 9:21 ` [PATCH v2 44/44] raw/cnxk_gpio: " Chengwen Feng
@ 2023-04-15 1:38 ` fengchengwen
2023-04-17 16:37 ` Ferruh Yigit
44 siblings, 1 reply; 131+ messages in thread
From: fengchengwen @ 2023-04-15 1:38 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev
Hi Thomas, Ferruh,
This patch-set get almost 30% ack by PMD's maintainer.
Could it be applied? and squeeze the patch-set is okay.
Another thread talk about a change in kvargs API, we could discuss here.
My opinion:
1) the below PMD has the bug, but there are also many PMD take care of only key situation.
I think it mainly because the API definition is not detailed, but this hole was already
fill by commit: 52ab17efdec.
2) the rte_kvargs_get API, I think we could refine it definition, because it can't identify
invalid keys and only-keys (both of them return NULL), and I suggest add one extra parameter:
const char *rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key, bool *key_exist);
Thanks.
On 2023/3/20 17:20, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> It may leads to segment fault when parse args with 'only key', this
> patchset fixes rest of them.
>
> Chengwen Feng (44):
> app/pdump: fix segment fault when parse args
> ethdev: fix segment fault when parse args
> net/memif: fix segment fault when parse devargs
> net/pcap: fix segment fault when parse devargs
> net/ring: fix segment fault when parse devargs
> net/sfc: fix segment fault when parse devargs
> net/af_xdp: fix segment fault when parse devargs
> net/ark: fix segment fault when parse devargs
> net/cnxk: fix segment fault when parse devargs
> net/cxgbe: fix segment fault when parse devargs
> net/dpaa2: fix segment fault when parse devargs
> net/ena: fix segment fault when parse devargs
> net/enic: fix segment fault when parse devargs
> net/fm10k: fix segment fault when parse devargs
> net/i40e: fix segment fault when parse devargs
> net/iavf: fix segment fault when parse devargs
> net/ice: fix segment fault when parse devargs
> net/idpf: fix segment fault when parse devargs
> net/ionic: fix segment fault when parse devargs
> net/mana: fix segment fault when parse devargs
> net/mlx4: fix segment fault when parse devargs
> net/mvneta: fix segment fault when parse devargs
> net/mvpp2: fix segment fault when parse devargs
> net/netvsc: fix segment fault when parse devargs
> net/octeontx: fix segment fault when parse devargs
> net/pfe: fix segment fault when parse devargs
> net/qede: fix segment fault when parse devargs
> baseband/la12xx: fix segment fault when parse devargs
> bus/pci: fix segment fault when parse args
> common/mlx5: fix segment fault when parse devargs
> crypto/cnxk: fix segment fault when parse devargs
> crypto/dpaa_sec: fix segment fault when parse devargs
> crypto/dpaa2_sec: fix segment fault when parse devargs
> crypto/mvsam: fix segment fault when parse devargs
> crypto/scheduler: fix segment fault when parse devargs
> dma/dpaa2: fix segment fault when parse devargs
> event/cnxk: fix segment fault when parse devargs
> event/dlb2: fix segment fault when parse devargs
> event/dpaa: fix segment fault when parse devargs
> event/octeontx: fix segment fault when parse devargs
> event/opdl: fix segment fault when parse devargs
> event/sw: fix segment fault when parse devargs
> mempool/cnxk: fix segment fault when parse devargs
> raw/cnxk_gpio: fix segment fault when parse devargs
>
> ---
> v2: according Ferruh's comments:
> fix all 'rte_kvargs_process()' bug instances.
> only judge value validation.
>
> app/pdump/main.c | 12 ++++++
> drivers/baseband/la12xx/bbdev_la12xx.c | 3 ++
> drivers/bus/pci/pci_params.c | 2 +
> drivers/common/mlx5/mlx5_common.c | 5 +++
> drivers/crypto/cnxk/cnxk_cryptodev_devargs.c | 3 ++
> drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 2 +
> drivers/crypto/dpaa_sec/dpaa_sec.c | 3 ++
> drivers/crypto/mvsam/rte_mrvl_pmd.c | 6 +++
> drivers/crypto/scheduler/scheduler_pmd.c | 21 +++++++++++
> drivers/dma/dpaa2/dpaa2_qdma.c | 3 ++
> drivers/event/cnxk/cnxk_eventdev.c | 6 +++
> drivers/event/cnxk/cnxk_eventdev.h | 6 +++
> drivers/event/cnxk/cnxk_tim_evdev.c | 6 +++
> drivers/event/dlb2/dlb2.c | 5 ++-
> drivers/event/dpaa/dpaa_eventdev.c | 3 ++
> drivers/event/octeontx/ssovf_evdev.c | 2 +
> drivers/event/opdl/opdl_evdev.c | 9 +++++
> drivers/event/sw/sw_evdev.c | 12 ++++++
> drivers/mempool/cnxk/cnxk_mempool.c | 3 ++
> drivers/net/af_xdp/rte_eth_af_xdp.c | 12 ++++++
> drivers/net/ark/ark_ethdev.c | 3 ++
> drivers/net/cnxk/cnxk_ethdev_devargs.c | 39 ++++++++++++++++++++
> drivers/net/cnxk/cnxk_ethdev_sec.c | 12 ++++++
> drivers/net/cxgbe/cxgbe_main.c | 3 ++
> drivers/net/dpaa2/dpaa2_ethdev.c | 3 ++
> drivers/net/ena/ena_ethdev.c | 6 +++
> drivers/net/enic/enic_ethdev.c | 6 +++
> drivers/net/fm10k/fm10k_ethdev.c | 3 ++
> drivers/net/i40e/i40e_ethdev.c | 15 ++++++++
> drivers/net/iavf/iavf_ethdev.c | 6 +++
> drivers/net/ice/ice_dcf_ethdev.c | 6 +++
> drivers/net/ice/ice_ethdev.c | 6 +++
> drivers/net/idpf/idpf_ethdev.c | 6 +++
> drivers/net/ionic/ionic_dev_pci.c | 3 ++
> drivers/net/mana/mana.c | 3 ++
> drivers/net/memif/rte_eth_memif.c | 30 +++++++++++++++
> drivers/net/mlx4/mlx4.c | 3 ++
> drivers/net/mvneta/mvneta_ethdev.c | 3 ++
> drivers/net/mvpp2/mrvl_ethdev.c | 3 ++
> drivers/net/mvpp2/mrvl_qos.c | 6 ++-
> drivers/net/netvsc/hn_ethdev.c | 3 ++
> drivers/net/octeontx/octeontx_ethdev.c | 3 ++
> drivers/net/pcap/pcap_ethdev.c | 18 ++++++++-
> drivers/net/pfe/pfe_ethdev.c | 3 ++
> drivers/net/qede/qede_ethdev.c | 3 ++
> drivers/net/ring/rte_eth_ring.c | 6 +++
> drivers/net/sfc/sfc.c | 3 ++
> drivers/net/sfc/sfc_ev.c | 3 ++
> drivers/net/sfc/sfc_kvargs.c | 6 +++
> drivers/raw/cnxk_gpio/cnxk_gpio.c | 6 +++
> lib/ethdev/rte_class_eth.c | 6 +++
> 51 files changed, 345 insertions(+), 4 deletions(-)
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v2 00/44] fix segment fault when parse args
2023-04-15 1:38 ` [PATCH v2 00/44] fix segment fault when parse args fengchengwen
@ 2023-04-17 16:37 ` Ferruh Yigit
2023-10-31 20:46 ` Stephen Hemminger
0 siblings, 1 reply; 131+ messages in thread
From: Ferruh Yigit @ 2023-04-17 16:37 UTC (permalink / raw)
To: fengchengwen, thomas; +Cc: dev
On 4/15/2023 2:38 AM, fengchengwen wrote:
> Hi Thomas, Ferruh,
>
> This patch-set get almost 30% ack by PMD's maintainer.
> Could it be applied? and squeeze the patch-set is okay.
>
Hi Chengwen,
The patch is trivial and safe on its own, so for me having enough ack or
not is not what blocks the set.
As we discussed before, instead of adding NULL checks to the callbacks,
it is better to handle this in the kvargs API level, that discussion is
holding this patchset back.
According result of discussion we may prefer to not merge this patch at all.
> Another thread talk about a change in kvargs API, we could discuss here.
> My opinion:
> 1) the below PMD has the bug, but there are also many PMD take care of only key situation.
> I think it mainly because the API definition is not detailed, but this hole was already
> fill by commit: 52ab17efdec.
Ack
> 2) the rte_kvargs_get API, I think we could refine it definition, because it can't identify
> invalid keys and only-keys (both of them return NULL), and I suggest add one extra parameter:
> const char *rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key, bool *key_exist);
>
I am not clear why to update `rte_kvargs_get()`, and how to benefit from
this update.
My suggestion was to update kvargs API to let user of API define if
'key' should have a 'value' or not, similar to done in `getopt()` API.
One option can be to update `rte_kvargs_parse()` API to recognize a
special char in "const char *const valid_keys[]" to know if value
expected or not, and API can do internal checks based on this information.
To reduce the impact of change, no special char in the valid_keys string
may mean key expects a value (I think this is the most common case), and
in this case if "value == NULL" API can return an error.
But if there is a special char at the end, lets say '-', key doesn't
need a value and having "value == NULL" is accepted.
Again this is similar to ':' char in the `getopt()` API, but meaning is
reverse.
Above is just an option, there can be another solution by to updating
`rte_kvargs_process()` API, only this may be more disruptive.
Any other solution is welcomed.
> Thanks.
>
> On 2023/3/20 17:20, Chengwen Feng wrote:
>> The rte_kvargs_process() was used to parse KV pairs, it also supports
>> to parse 'only keys' (e.g. socket_id) type. And the callback function
>> parameter 'value' is NULL when parsed 'only keys'.
>>
>> It may leads to segment fault when parse args with 'only key', this
>> patchset fixes rest of them.
>>
>> Chengwen Feng (44):
>> app/pdump: fix segment fault when parse args
>> ethdev: fix segment fault when parse args
>> net/memif: fix segment fault when parse devargs
>> net/pcap: fix segment fault when parse devargs
>> net/ring: fix segment fault when parse devargs
>> net/sfc: fix segment fault when parse devargs
>> net/af_xdp: fix segment fault when parse devargs
>> net/ark: fix segment fault when parse devargs
>> net/cnxk: fix segment fault when parse devargs
>> net/cxgbe: fix segment fault when parse devargs
>> net/dpaa2: fix segment fault when parse devargs
>> net/ena: fix segment fault when parse devargs
>> net/enic: fix segment fault when parse devargs
>> net/fm10k: fix segment fault when parse devargs
>> net/i40e: fix segment fault when parse devargs
>> net/iavf: fix segment fault when parse devargs
>> net/ice: fix segment fault when parse devargs
>> net/idpf: fix segment fault when parse devargs
>> net/ionic: fix segment fault when parse devargs
>> net/mana: fix segment fault when parse devargs
>> net/mlx4: fix segment fault when parse devargs
>> net/mvneta: fix segment fault when parse devargs
>> net/mvpp2: fix segment fault when parse devargs
>> net/netvsc: fix segment fault when parse devargs
>> net/octeontx: fix segment fault when parse devargs
>> net/pfe: fix segment fault when parse devargs
>> net/qede: fix segment fault when parse devargs
>> baseband/la12xx: fix segment fault when parse devargs
>> bus/pci: fix segment fault when parse args
>> common/mlx5: fix segment fault when parse devargs
>> crypto/cnxk: fix segment fault when parse devargs
>> crypto/dpaa_sec: fix segment fault when parse devargs
>> crypto/dpaa2_sec: fix segment fault when parse devargs
>> crypto/mvsam: fix segment fault when parse devargs
>> crypto/scheduler: fix segment fault when parse devargs
>> dma/dpaa2: fix segment fault when parse devargs
>> event/cnxk: fix segment fault when parse devargs
>> event/dlb2: fix segment fault when parse devargs
>> event/dpaa: fix segment fault when parse devargs
>> event/octeontx: fix segment fault when parse devargs
>> event/opdl: fix segment fault when parse devargs
>> event/sw: fix segment fault when parse devargs
>> mempool/cnxk: fix segment fault when parse devargs
>> raw/cnxk_gpio: fix segment fault when parse devargs
>>
>> ---
>> v2: according Ferruh's comments:
>> fix all 'rte_kvargs_process()' bug instances.
>> only judge value validation.
>>
>> app/pdump/main.c | 12 ++++++
>> drivers/baseband/la12xx/bbdev_la12xx.c | 3 ++
>> drivers/bus/pci/pci_params.c | 2 +
>> drivers/common/mlx5/mlx5_common.c | 5 +++
>> drivers/crypto/cnxk/cnxk_cryptodev_devargs.c | 3 ++
>> drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 2 +
>> drivers/crypto/dpaa_sec/dpaa_sec.c | 3 ++
>> drivers/crypto/mvsam/rte_mrvl_pmd.c | 6 +++
>> drivers/crypto/scheduler/scheduler_pmd.c | 21 +++++++++++
>> drivers/dma/dpaa2/dpaa2_qdma.c | 3 ++
>> drivers/event/cnxk/cnxk_eventdev.c | 6 +++
>> drivers/event/cnxk/cnxk_eventdev.h | 6 +++
>> drivers/event/cnxk/cnxk_tim_evdev.c | 6 +++
>> drivers/event/dlb2/dlb2.c | 5 ++-
>> drivers/event/dpaa/dpaa_eventdev.c | 3 ++
>> drivers/event/octeontx/ssovf_evdev.c | 2 +
>> drivers/event/opdl/opdl_evdev.c | 9 +++++
>> drivers/event/sw/sw_evdev.c | 12 ++++++
>> drivers/mempool/cnxk/cnxk_mempool.c | 3 ++
>> drivers/net/af_xdp/rte_eth_af_xdp.c | 12 ++++++
>> drivers/net/ark/ark_ethdev.c | 3 ++
>> drivers/net/cnxk/cnxk_ethdev_devargs.c | 39 ++++++++++++++++++++
>> drivers/net/cnxk/cnxk_ethdev_sec.c | 12 ++++++
>> drivers/net/cxgbe/cxgbe_main.c | 3 ++
>> drivers/net/dpaa2/dpaa2_ethdev.c | 3 ++
>> drivers/net/ena/ena_ethdev.c | 6 +++
>> drivers/net/enic/enic_ethdev.c | 6 +++
>> drivers/net/fm10k/fm10k_ethdev.c | 3 ++
>> drivers/net/i40e/i40e_ethdev.c | 15 ++++++++
>> drivers/net/iavf/iavf_ethdev.c | 6 +++
>> drivers/net/ice/ice_dcf_ethdev.c | 6 +++
>> drivers/net/ice/ice_ethdev.c | 6 +++
>> drivers/net/idpf/idpf_ethdev.c | 6 +++
>> drivers/net/ionic/ionic_dev_pci.c | 3 ++
>> drivers/net/mana/mana.c | 3 ++
>> drivers/net/memif/rte_eth_memif.c | 30 +++++++++++++++
>> drivers/net/mlx4/mlx4.c | 3 ++
>> drivers/net/mvneta/mvneta_ethdev.c | 3 ++
>> drivers/net/mvpp2/mrvl_ethdev.c | 3 ++
>> drivers/net/mvpp2/mrvl_qos.c | 6 ++-
>> drivers/net/netvsc/hn_ethdev.c | 3 ++
>> drivers/net/octeontx/octeontx_ethdev.c | 3 ++
>> drivers/net/pcap/pcap_ethdev.c | 18 ++++++++-
>> drivers/net/pfe/pfe_ethdev.c | 3 ++
>> drivers/net/qede/qede_ethdev.c | 3 ++
>> drivers/net/ring/rte_eth_ring.c | 6 +++
>> drivers/net/sfc/sfc.c | 3 ++
>> drivers/net/sfc/sfc_ev.c | 3 ++
>> drivers/net/sfc/sfc_kvargs.c | 6 +++
>> drivers/raw/cnxk_gpio/cnxk_gpio.c | 6 +++
>> lib/ethdev/rte_class_eth.c | 6 +++
>> 51 files changed, 345 insertions(+), 4 deletions(-)
>>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v2 24/44] net/netvsc: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 24/44] net/netvsc: " Chengwen Feng
2023-03-21 22:20 ` Long Li
@ 2023-07-04 3:02 ` Stephen Hemminger
1 sibling, 0 replies; 131+ messages in thread
From: Stephen Hemminger @ 2023-07-04 3:02 UTC (permalink / raw)
To: Chengwen Feng; +Cc: thomas, ferruh.yigit, Long Li, Stephen Hemminger, dev
On Mon, 20 Mar 2023 09:20:50 +0000
Chengwen Feng <fengchengwen@huawei.com> wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: a25d39a3eb69 ("net/netvsc: allow tuning latency with devargs")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v2 04/44] net/pcap: fix segment fault when parse devargs
2023-03-20 9:20 ` [PATCH v2 04/44] net/pcap: " Chengwen Feng
@ 2023-07-04 3:04 ` Stephen Hemminger
0 siblings, 0 replies; 131+ messages in thread
From: Stephen Hemminger @ 2023-07-04 3:04 UTC (permalink / raw)
To: Chengwen Feng
Cc: thomas, ferruh.yigit, Ido Goshen, Ferruh Yigit,
Juhamatti Kuusisaari, Cian Ferriter, dev
On Mon, 20 Mar 2023 09:20:30 +0000
Chengwen Feng <fengchengwen@huawei.com> wrote:
> The rte_kvargs_process() was used to parse KV pairs, it also supports
> to parse 'only keys' (e.g. socket_id) type. And the callback function
> parameter 'value' is NULL when parsed 'only keys'.
>
> This patch fixes segment fault when parse input args with 'only keys'.
>
> Fixes: 4c173302c307 ("pcap: add new driver")
> Fixes: 53bf48403409 ("net/pcap: capture only ingress packets from Rx iface")
> Fixes: c9507cd0cada ("net/pcap: support physical interface MAC address")
> Fixes: a3f5252e5cbd ("net/pcap: enable infinitely Rx a pcap file")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v2 00/44] fix segment fault when parse args
2023-04-17 16:37 ` Ferruh Yigit
@ 2023-10-31 20:46 ` Stephen Hemminger
0 siblings, 0 replies; 131+ messages in thread
From: Stephen Hemminger @ 2023-10-31 20:46 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: fengchengwen, thomas, dev
On Mon, 17 Apr 2023 17:37:46 +0100
Ferruh Yigit <ferruh.yigit@amd.com> wrote:
> From: Ferruh Yigit <ferruh.yigit@amd.com>
> To: fengchengwen <fengchengwen@huawei.com>, thomas@monjalon.net
> Cc: dev@dpdk.org
> Subject: Re: [PATCH v2 00/44] fix segment fault when parse args
> Date: Mon, 17 Apr 2023 17:37:46 +0100
> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
> Thunderbird/102.10.0
>
> On 4/15/2023 2:38 AM, fengchengwen wrote:
> > Hi Thomas, Ferruh,
> >
> > This patch-set get almost 30% ack by PMD's maintainer.
> > Could it be applied? and squeeze the patch-set is okay.
> >
>
> Hi Chengwen,
>
> The patch is trivial and safe on its own, so for me having enough ack or
> not is not what blocks the set.
>
> As we discussed before, instead of adding NULL checks to the callbacks,
> it is better to handle this in the kvargs API level, that discussion is
> holding this patchset back.
>
> According result of discussion we may prefer to not merge this patch at all.
Agree. Hitting so many places, and not sure that all of them are covered, is
an indicator it should be solved at higher level.
^ permalink raw reply [flat|nested] 131+ messages in thread
* [RFC] kvargs: don't pass parse handler a NULL pointer
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
` (6 preceding siblings ...)
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
@ 2023-10-31 20:58 ` Stephen Hemminger
2023-11-01 1:16 ` fengchengwen
2023-11-03 7:38 ` [PATCH v3 0/5] fix segment fault when parse args Chengwen Feng
` (3 subsequent siblings)
11 siblings, 1 reply; 131+ messages in thread
From: Stephen Hemminger @ 2023-10-31 20:58 UTC (permalink / raw)
To: dev; +Cc: fengchengwen, Stephen Hemminger
There is class of problems in current DPDK where rte_kvargs
is used a key/value pair is passed without an associated value.
Currently, this can cause a NULL dereference in the rte_kvargs_process
handler.
Reported-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/kvargs/rte_kvargs.c | 3 +++
lib/kvargs/rte_kvargs.h | 3 +++
2 files changed, 6 insertions(+)
diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c
index c77bb82feb..5481f58584 100644
--- a/lib/kvargs/rte_kvargs.c
+++ b/lib/kvargs/rte_kvargs.c
@@ -185,6 +185,9 @@ rte_kvargs_process(const struct rte_kvargs *kvlist,
for (i = 0; i < kvlist->count; i++) {
pair = &kvlist->pairs[i];
if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
+ if (pair->value == NULL)
+ return -1;
+
if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
return -1;
}
diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
index 4900b750bc..fd9a3238f0 100644
--- a/lib/kvargs/rte_kvargs.h
+++ b/lib/kvargs/rte_kvargs.h
@@ -178,6 +178,9 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
* handler function with the for a given arg_name passing the value on the
* dictionary for that key and a given extra argument.
*
+ * If no value was specified with the given key, then this
+ * function will return -1 and the handlere will not be called.
+ *
* @param kvlist
* The rte_kvargs structure. No error if NULL.
* @param key_match
--
2.41.0
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [RFC] kvargs: don't pass parse handler a NULL pointer
2023-10-31 20:58 ` [RFC] kvargs: don't pass parse handler a NULL pointer Stephen Hemminger
@ 2023-11-01 1:16 ` fengchengwen
0 siblings, 0 replies; 131+ messages in thread
From: fengchengwen @ 2023-11-01 1:16 UTC (permalink / raw)
To: Stephen Hemminger, dev; +Cc: Thomas Monjalon, Ferruh Yigit
There are a few only-key situation which use rte_kvargs_process to process, If we make
this change, the above case will fail.
Actually I locally make similar change plus a new API (rte_kvargs_process_opt), this
new API will cover key/value and only-key match, while rte_kvargs_process make restrict
only work for key/value match.
I didn't send the patches because it too late for adding this new API due to already RC1.
/**
* Call a handler function for each key/value or only-key matching the key
*
* For each key/value or only-key association that matches the given key, calls
* the handler function with the for a given arg_name passing the value on the
* dictionary for that key and a given extra argument.
*
* @param kvlist
* The rte_kvargs structure. No error if NULL.
* @param key_match
* The key on which the handler should be called, or NULL to process handler
* on all associations
* @param handler
* The function to call for each matching key
* @param opaque_arg
* A pointer passed unchanged to the handler
*
* @return
* - 0 on success
* - Negative on error
*/
int rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
const char *key_match, arg_handler_t handler, void *opaque_arg);
On 2023/11/1 4:58, Stephen Hemminger wrote:
> There is class of problems in current DPDK where rte_kvargs
> is used a key/value pair is passed without an associated value.
> Currently, this can cause a NULL dereference in the rte_kvargs_process
> handler.
>
> Reported-by: Chengwen Feng <fengchengwen@huawei.com>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> lib/kvargs/rte_kvargs.c | 3 +++
> lib/kvargs/rte_kvargs.h | 3 +++
> 2 files changed, 6 insertions(+)
>
> diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c
> index c77bb82feb..5481f58584 100644
> --- a/lib/kvargs/rte_kvargs.c
> +++ b/lib/kvargs/rte_kvargs.c
> @@ -185,6 +185,9 @@ rte_kvargs_process(const struct rte_kvargs *kvlist,
> for (i = 0; i < kvlist->count; i++) {
> pair = &kvlist->pairs[i];
> if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
> + if (pair->value == NULL)
> + return -1;
> +
> if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
> return -1;
> }
> diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
> index 4900b750bc..fd9a3238f0 100644
> --- a/lib/kvargs/rte_kvargs.h
> +++ b/lib/kvargs/rte_kvargs.h
> @@ -178,6 +178,9 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
> * handler function with the for a given arg_name passing the value on the
> * dictionary for that key and a given extra argument.
> *
> + * If no value was specified with the given key, then this
> + * function will return -1 and the handlere will not be called.
> + *
> * @param kvlist
> * The rte_kvargs structure. No error if NULL.
> * @param key_match
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v3 0/5] fix segment fault when parse args
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
` (7 preceding siblings ...)
2023-10-31 20:58 ` [RFC] kvargs: don't pass parse handler a NULL pointer Stephen Hemminger
@ 2023-11-03 7:38 ` Chengwen Feng
2023-11-03 7:38 ` [PATCH v3 1/5] kvargs: add one new process API Chengwen Feng
` (5 more replies)
2023-11-05 5:45 ` [PATCH v4 " Chengwen Feng
` (2 subsequent siblings)
11 siblings, 6 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-11-03 7:38 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
it also supports to parse only-key (e.g. socket_id). But many drivers's
callback can only handle key-value, it will segment fault if handles
only-key. so the patchset [1] was introduced.
Because the patchset [1] modified too much drivers, therefore:
1) A new API rte_kvargs_process_opt() was introduced, it inherits the
function of rte_kvargs_process() which could parse both key-value and
only-key.
2) Constraint the rte_kvargs_process() can only parse key-value.
This patchset also include one bugfix for kvargs of mvneta driver.
[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
Chengwen Feng (5):
kvargs: add one new process API
net/af_packet: use new API to parse kvargs
net/sfc: use new API to parse kvargs
net/tap: use new API to parse kvargs
net/mvneta: fix possible out-of-bounds write
drivers/common/sfc_efx/sfc_efx.c | 4 ++--
drivers/net/af_packet/rte_eth_af_packet.c | 4 ++--
drivers/net/mvneta/mvneta_ethdev.c | 3 +++
drivers/net/sfc/sfc_kvargs.c | 2 +-
drivers/net/tap/rte_eth_tap.c | 26 ++++++++++----------
lib/kvargs/rte_kvargs.c | 29 ++++++++++++++++++++++-
lib/kvargs/rte_kvargs.h | 28 ++++++++++++++++++++++
lib/kvargs/version.map | 3 +++
8 files changed, 80 insertions(+), 19 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v3 1/5] kvargs: add one new process API
2023-11-03 7:38 ` [PATCH v3 0/5] fix segment fault when parse args Chengwen Feng
@ 2023-11-03 7:38 ` Chengwen Feng
2023-11-03 13:09 ` Ferruh Yigit
2023-11-03 7:38 ` [PATCH v3 2/5] net/af_packet: use new API to parse kvargs Chengwen Feng
` (4 subsequent siblings)
5 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-11-03 7:38 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
it also supports to parse only-key (e.g. socket_id). But many drivers's
callback can only handle key-value, it will segment fault if handles
only-key. so the patchset [1] was introduced.
Because the patchset [1] modified too much drivers, therefore:
1) A new API rte_kvargs_process_opt() was introduced, it inherits the
function of rte_kvargs_process() which could parse both key-value and
only-key.
2) Constraint the rte_kvargs_process() can only parse key-value.
[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/kvargs/rte_kvargs.c | 29 ++++++++++++++++++++++++++++-
lib/kvargs/rte_kvargs.h | 28 ++++++++++++++++++++++++++++
lib/kvargs/version.map | 3 +++
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c
index c77bb82feb..5ce8664238 100644
--- a/lib/kvargs/rte_kvargs.c
+++ b/lib/kvargs/rte_kvargs.c
@@ -168,7 +168,7 @@ rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match)
}
/*
- * For each matching key, call the given handler function.
+ * For each matching key in key/value, call the given handler function.
*/
int
rte_kvargs_process(const struct rte_kvargs *kvlist,
@@ -179,6 +179,33 @@ rte_kvargs_process(const struct rte_kvargs *kvlist,
const struct rte_kvargs_pair *pair;
unsigned i;
+ if (kvlist == NULL)
+ return 0;
+
+ for (i = 0; i < kvlist->count; i++) {
+ pair = &kvlist->pairs[i];
+ if (pair->value == NULL)
+ continue;
+ if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
+ if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
+ return -1;
+ }
+ }
+ return 0;
+}
+
+/*
+ * For each matching key in key/value or only-key, call the given handler function.
+ */
+int
+rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg)
+{
+ const struct rte_kvargs_pair *pair;
+ unsigned int i;
+
if (kvlist == NULL)
return 0;
diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
index 4900b750bc..522e83f757 100644
--- a/lib/kvargs/rte_kvargs.h
+++ b/lib/kvargs/rte_kvargs.h
@@ -195,6 +195,34 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
int rte_kvargs_process(const struct rte_kvargs *kvlist,
const char *key_match, arg_handler_t handler, void *opaque_arg);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Call a handler function for each key/value or only-key matching the key
+ *
+ * For each key/value or only-key association that matches the given key, calls
+ * the handler function with the for a given arg_name passing the value on the
+ * dictionary for that key and a given extra argument.
+ *
+ * @param kvlist
+ * The rte_kvargs structure. No error if NULL.
+ * @param key_match
+ * The key on which the handler should be called, or NULL to process handler
+ * on all associations
+ * @param handler
+ * The function to call for each matching key
+ * @param opaque_arg
+ * A pointer passed unchanged to the handler
+ *
+ * @return
+ * - 0 on success
+ * - Negative on error
+ */
+__rte_experimental
+int rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
+ const char *key_match, arg_handler_t handler, void *opaque_arg);
+
/**
* Count the number of associations matching the given key
*
diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map
index 387a94e725..15d482e9b3 100644
--- a/lib/kvargs/version.map
+++ b/lib/kvargs/version.map
@@ -16,4 +16,7 @@ EXPERIMENTAL {
# added in 21.11
rte_kvargs_get_with_value;
+
+ # added in 23.11
+ rte_kvargs_process_opt;
};
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v3 2/5] net/af_packet: use new API to parse kvargs
2023-11-03 7:38 ` [PATCH v3 0/5] fix segment fault when parse args Chengwen Feng
2023-11-03 7:38 ` [PATCH v3 1/5] kvargs: add one new process API Chengwen Feng
@ 2023-11-03 7:38 ` Chengwen Feng
2023-11-03 13:11 ` Ferruh Yigit
2023-11-03 7:38 ` [PATCH v3 3/5] net/sfc: " Chengwen Feng
` (3 subsequent siblings)
5 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-11-03 7:38 UTC (permalink / raw)
To: thomas, ferruh.yigit, John W. Linville; +Cc: dev, stephen
This driver don't care about the 'iface' value, it should use
rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/af_packet/rte_eth_af_packet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 397a32db58..54a9f5f746 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -1096,8 +1096,8 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev)
*/
if (rte_kvargs_count(kvlist, ETH_AF_PACKET_IFACE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist, ETH_AF_PACKET_IFACE_ARG,
- &open_packet_iface, &sockfd);
+ ret = rte_kvargs_process_opt(kvlist, ETH_AF_PACKET_IFACE_ARG,
+ &open_packet_iface, &sockfd);
if (ret < 0)
goto exit;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v3 3/5] net/sfc: use new API to parse kvargs
2023-11-03 7:38 ` [PATCH v3 0/5] fix segment fault when parse args Chengwen Feng
2023-11-03 7:38 ` [PATCH v3 1/5] kvargs: add one new process API Chengwen Feng
2023-11-03 7:38 ` [PATCH v3 2/5] net/af_packet: use new API to parse kvargs Chengwen Feng
@ 2023-11-03 7:38 ` Chengwen Feng
2023-11-03 13:23 ` Ferruh Yigit
2023-11-03 7:38 ` [PATCH v3 4/5] net/tap: " Chengwen Feng
` (2 subsequent siblings)
5 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-11-03 7:38 UTC (permalink / raw)
To: thomas, ferruh.yigit, Andrew Rybchenko; +Cc: dev, stephen
The sfc_kvargs_process() and sfc_efx_dev_class_get() function could
handle both key=value and only-key, so they should use
rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/common/sfc_efx/sfc_efx.c | 4 ++--
drivers/net/sfc/sfc_kvargs.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
index 2dc5545760..3ebac909f1 100644
--- a/drivers/common/sfc_efx/sfc_efx.c
+++ b/drivers/common/sfc_efx/sfc_efx.c
@@ -52,8 +52,8 @@ sfc_efx_dev_class_get(struct rte_devargs *devargs)
return dev_class;
if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
- rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
- sfc_efx_kvarg_dev_class_handler, &dev_class);
+ rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
+ sfc_efx_kvarg_dev_class_handler, &dev_class);
}
rte_kvargs_free(kvargs);
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 783cb43ae6..24bb896179 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -70,7 +70,7 @@ sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
if (sa->kvargs == NULL)
return 0;
- return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
+ return -rte_kvargs_process_opt(sa->kvargs, key_match, handler, opaque_arg);
}
int
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v3 4/5] net/tap: use new API to parse kvargs
2023-11-03 7:38 ` [PATCH v3 0/5] fix segment fault when parse args Chengwen Feng
` (2 preceding siblings ...)
2023-11-03 7:38 ` [PATCH v3 3/5] net/sfc: " Chengwen Feng
@ 2023-11-03 7:38 ` Chengwen Feng
2023-11-03 13:34 ` Ferruh Yigit
2023-11-03 7:38 ` [PATCH v3 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
2023-11-03 13:41 ` [PATCH v3 0/5] fix segment fault when parse args Ferruh Yigit
5 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-11-03 7:38 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
This driver could handles both key=value and only-key kvargs, so it
should use rte_kvargs_process_opt() instead of rte_kvargs_process() to
parse.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/tap/rte_eth_tap.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index b25a52655f..8b35de0a7a 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2342,7 +2342,7 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
+ ret = rte_kvargs_process_opt(kvlist,
ETH_TAP_IFACE_ARG,
&set_interface_name,
tun_name);
@@ -2546,28 +2546,28 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
- ETH_TAP_IFACE_ARG,
- &set_interface_name,
- tap_name);
+ ret = rte_kvargs_process_opt(kvlist,
+ ETH_TAP_IFACE_ARG,
+ &set_interface_name,
+ tap_name);
if (ret == -1)
goto leave;
}
if (rte_kvargs_count(kvlist, ETH_TAP_REMOTE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
- ETH_TAP_REMOTE_ARG,
- &set_remote_iface,
- remote_iface);
+ ret = rte_kvargs_process_opt(kvlist,
+ ETH_TAP_REMOTE_ARG,
+ &set_remote_iface,
+ remote_iface);
if (ret == -1)
goto leave;
}
if (rte_kvargs_count(kvlist, ETH_TAP_MAC_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
- ETH_TAP_MAC_ARG,
- &set_mac_type,
- &user_mac);
+ ret = rte_kvargs_process_opt(kvlist,
+ ETH_TAP_MAC_ARG,
+ &set_mac_type,
+ &user_mac);
if (ret == -1)
goto leave;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v3 5/5] net/mvneta: fix possible out-of-bounds write
2023-11-03 7:38 ` [PATCH v3 0/5] fix segment fault when parse args Chengwen Feng
` (3 preceding siblings ...)
2023-11-03 7:38 ` [PATCH v3 4/5] net/tap: " Chengwen Feng
@ 2023-11-03 7:38 ` Chengwen Feng
2023-11-03 13:39 ` Ferruh Yigit
2023-11-03 13:41 ` [PATCH v3 0/5] fix segment fault when parse args Ferruh Yigit
5 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-11-03 7:38 UTC (permalink / raw)
To: thomas, ferruh.yigit, Zyta Szpak, Liron Himi, Ferruh Yigit,
Andrzej Ostruszka, Dmitri Epshtein, Yelena Krivosheev,
Natalie Samsonov
Cc: dev, stephen
The mvneta_ifnames_get() function will save 'iface' value to ifnames,
it will out-of-bounds write if passed many iface pairs (e.g.
'iface=xxx,iface=xxx,...').
Fixes: 4ccc8d770d3b ("net/mvneta: add PMD skeleton")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/mvneta/mvneta_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index daa69e533a..8032a712f4 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -91,6 +91,9 @@ mvneta_ifnames_get(const char *key __rte_unused, const char *value,
{
struct mvneta_ifnames *ifnames = extra_args;
+ if (ifnames->idx >= NETA_NUM_ETH_PPIO)
+ return -EINVAL;
+
ifnames->names[ifnames->idx++] = value;
return 0;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 1/5] kvargs: add one new process API
2023-11-03 7:38 ` [PATCH v3 1/5] kvargs: add one new process API Chengwen Feng
@ 2023-11-03 13:09 ` Ferruh Yigit
2023-11-05 5:55 ` fengchengwen
0 siblings, 1 reply; 131+ messages in thread
From: Ferruh Yigit @ 2023-11-03 13:09 UTC (permalink / raw)
To: Chengwen Feng, thomas; +Cc: dev, stephen
On 11/3/2023 7:38 AM, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
> it also supports to parse only-key (e.g. socket_id). But many drivers's
> callback can only handle key-value, it will segment fault if handles
> only-key. so the patchset [1] was introduced.
>
> Because the patchset [1] modified too much drivers, therefore:
> 1) A new API rte_kvargs_process_opt() was introduced, it inherits the
> function of rte_kvargs_process() which could parse both key-value and
> only-key.
> 2) Constraint the rte_kvargs_process() can only parse key-value.
>
Hi Chengwen,
This works, but behavior change in 'rte_kvargs_process()' can hit some
exiting users who handles both "key=value" and "key" cases.
Other option is to keep 'rte_kvargs_process()' behavior same but add a
new API like 'rte_kvargs_process_safe()' that checks "value == NULL"
case, but this requires more existing code to change and in this option
existing users doesn't get the benefit of the NULL check by default.
Assuming number of the users that use 'rte_kvargs_process()' for
"key=value" is majority, OK to continue with your change, but please
document this in the release notes to highlight.
> [1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> lib/kvargs/rte_kvargs.c | 29 ++++++++++++++++++++++++++++-
> lib/kvargs/rte_kvargs.h | 28 ++++++++++++++++++++++++++++
> lib/kvargs/version.map | 3 +++
> 3 files changed, 59 insertions(+), 1 deletion(-)
>
> diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c
> index c77bb82feb..5ce8664238 100644
> --- a/lib/kvargs/rte_kvargs.c
> +++ b/lib/kvargs/rte_kvargs.c
> @@ -168,7 +168,7 @@ rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match)
> }
>
> /*
> - * For each matching key, call the given handler function.
> + * For each matching key in key/value, call the given handler function.
> */
> int
> rte_kvargs_process(const struct rte_kvargs *kvlist,
> @@ -179,6 +179,33 @@ rte_kvargs_process(const struct rte_kvargs *kvlist,
> const struct rte_kvargs_pair *pair;
> unsigned i;
>
> + if (kvlist == NULL)
> + return 0;
> +
I think it should return error here, ignoring arg silently with success
can cause trouble in the application. If error returned, at least
application can know argument not provided as it should be (value is
missing).
> + for (i = 0; i < kvlist->count; i++) {
> + pair = &kvlist->pairs[i];
> + if (pair->value == NULL)
> + continue;
> + if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
> + if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
> + return -1;
> + }
> + }
> + return 0;
> +}
> +
'rte_kvargs_process()' & 'rte_kvargs_process_opt()' implementations are
very similar, to reduce duplication what about create
'rte_kvargs_process_common()' static function and both use this common
with different parameter?
> +/*
> + * For each matching key in key/value or only-key, call the given handler function.
> + */
> +int
> +rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
> + const char *key_match,
> + arg_handler_t handler,
> + void *opaque_arg)
> +{
> + const struct rte_kvargs_pair *pair;
> + unsigned int i;
> +
> if (kvlist == NULL)
> return 0;
>
> diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
> index 4900b750bc..522e83f757 100644
> --- a/lib/kvargs/rte_kvargs.h
> +++ b/lib/kvargs/rte_kvargs.h
> @@ -195,6 +195,34 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
> int rte_kvargs_process(const struct rte_kvargs *kvlist,
> const char *key_match, arg_handler_t handler, void *opaque_arg);
>
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change without prior notice.
> + *
> + * Call a handler function for each key/value or only-key matching the key
> + *
>
In API documentation, the difference between 'rte_kvargs_process_opt()'
& 'rte_kvargs_process()' is, 'rte_kvargs_process()' doesn't have "or
only-key", this is easy to miss.
Can you please add more not to 'rte_kvargs_process()' saying on
"only-key" case it returns error?
> + * For each key/value or only-key association that matches the given key, calls
> + * the handler function with the for a given arg_name passing the value on the
> + * dictionary for that key and a given extra argument.
> + *
> + * @param kvlist
> + * The rte_kvargs structure. No error if NULL.
> + * @param key_match
> + * The key on which the handler should be called, or NULL to process handler
> + * on all associations
> + * @param handler
> + * The function to call for each matching key
> + * @param opaque_arg
> + * A pointer passed unchanged to the handler
> + *
> + * @return
> + * - 0 on success
> + * - Negative on error
> + */
> +__rte_experimental
> +int rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
> + const char *key_match, arg_handler_t handler, void *opaque_arg);
> +
>
I am not sure about the API name, 'rte_kvargs_process_opt()', what is
'opt' here, "optional"?
What about 'rte_kvargs_process_unsafe()', not quite strong on this too
but not able to come with better one, please feel free to try other
alternatives.
> /**
> * Count the number of associations matching the given key
> *
> diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map
> index 387a94e725..15d482e9b3 100644
> --- a/lib/kvargs/version.map
> +++ b/lib/kvargs/version.map
> @@ -16,4 +16,7 @@ EXPERIMENTAL {
>
> # added in 21.11
> rte_kvargs_get_with_value;
> +
> + # added in 23.11
> + rte_kvargs_process_opt;
> };
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 2/5] net/af_packet: use new API to parse kvargs
2023-11-03 7:38 ` [PATCH v3 2/5] net/af_packet: use new API to parse kvargs Chengwen Feng
@ 2023-11-03 13:11 ` Ferruh Yigit
2023-11-05 5:56 ` fengchengwen
0 siblings, 1 reply; 131+ messages in thread
From: Ferruh Yigit @ 2023-11-03 13:11 UTC (permalink / raw)
To: Chengwen Feng, thomas, John W. Linville; +Cc: dev, stephen
On 11/3/2023 7:38 AM, Chengwen Feng wrote:
> This driver don't care about the 'iface' value, it should use
> rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> drivers/net/af_packet/rte_eth_af_packet.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
> index 397a32db58..54a9f5f746 100644
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -1096,8 +1096,8 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev)
> */
> if (rte_kvargs_count(kvlist, ETH_AF_PACKET_IFACE_ARG) == 1) {
>
> - ret = rte_kvargs_process(kvlist, ETH_AF_PACKET_IFACE_ARG,
> - &open_packet_iface, &sockfd);
> + ret = rte_kvargs_process_opt(kvlist, ETH_AF_PACKET_IFACE_ARG,
> + &open_packet_iface, &sockfd);
> if (ret < 0)
> goto exit;
> }
lets not update this driver, I think it is using kvargs
unconventionally, 'iface' requires argument but driver parses it
directly from kvargs.
We can fix kvargs usage more properly instead of this change, I am
taking a mental note for this.
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 3/5] net/sfc: use new API to parse kvargs
2023-11-03 7:38 ` [PATCH v3 3/5] net/sfc: " Chengwen Feng
@ 2023-11-03 13:23 ` Ferruh Yigit
0 siblings, 0 replies; 131+ messages in thread
From: Ferruh Yigit @ 2023-11-03 13:23 UTC (permalink / raw)
To: Chengwen Feng, thomas, Andrew Rybchenko; +Cc: dev, stephen
On 11/3/2023 7:38 AM, Chengwen Feng wrote:
> The sfc_kvargs_process() and sfc_efx_dev_class_get() function could
> handle both key=value and only-key, so they should use
> rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> drivers/common/sfc_efx/sfc_efx.c | 4 ++--
> drivers/net/sfc/sfc_kvargs.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
> index 2dc5545760..3ebac909f1 100644
> --- a/drivers/common/sfc_efx/sfc_efx.c
> +++ b/drivers/common/sfc_efx/sfc_efx.c
> @@ -52,8 +52,8 @@ sfc_efx_dev_class_get(struct rte_devargs *devargs)
> return dev_class;
>
> if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
> - rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
> - sfc_efx_kvarg_dev_class_handler, &dev_class);
> + rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
> + sfc_efx_kvarg_dev_class_handler, &dev_class);
> }
>
> rte_kvargs_free(kvargs);
> diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
> index 783cb43ae6..24bb896179 100644
> --- a/drivers/net/sfc/sfc_kvargs.c
> +++ b/drivers/net/sfc/sfc_kvargs.c
> @@ -70,7 +70,7 @@ sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
> if (sa->kvargs == NULL)
> return 0;
>
> - return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
> + return -rte_kvargs_process_opt(sa->kvargs, key_match, handler, opaque_arg);
> }
>
> int
looks good to me
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 4/5] net/tap: use new API to parse kvargs
2023-11-03 7:38 ` [PATCH v3 4/5] net/tap: " Chengwen Feng
@ 2023-11-03 13:34 ` Ferruh Yigit
2023-11-05 5:57 ` fengchengwen
0 siblings, 1 reply; 131+ messages in thread
From: Ferruh Yigit @ 2023-11-03 13:34 UTC (permalink / raw)
To: Chengwen Feng, thomas; +Cc: dev, stephen
On 11/3/2023 7:38 AM, Chengwen Feng wrote:
> This driver could handles both key=value and only-key kvargs, so it
> should use rte_kvargs_process_opt() instead of rte_kvargs_process() to
> parse.
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> drivers/net/tap/rte_eth_tap.c | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index b25a52655f..8b35de0a7a 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -2342,7 +2342,7 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
> kvlist = rte_kvargs_parse(params, valid_arguments);
> if (kvlist) {
> if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
> - ret = rte_kvargs_process(kvlist,
> + ret = rte_kvargs_process_opt(kvlist,
> ETH_TAP_IFACE_ARG,
> &set_interface_name,
> tun_name);
> @@ -2546,28 +2546,28 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
> kvlist = rte_kvargs_parse(params, valid_arguments);
> if (kvlist) {
> if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
> - ret = rte_kvargs_process(kvlist,
> - ETH_TAP_IFACE_ARG,
> - &set_interface_name,
> - tap_name);
> + ret = rte_kvargs_process_opt(kvlist,
> + ETH_TAP_IFACE_ARG,
> + &set_interface_name,
> + tap_name);
> if (ret == -1)
> goto leave;
> }
>
> if (rte_kvargs_count(kvlist, ETH_TAP_REMOTE_ARG) == 1) {
> - ret = rte_kvargs_process(kvlist,
> - ETH_TAP_REMOTE_ARG,
> - &set_remote_iface,
> - remote_iface);
> + ret = rte_kvargs_process_opt(kvlist,
> + ETH_TAP_REMOTE_ARG,
> + &set_remote_iface,
> + remote_iface);
>
As far as I can see, "remote" arg without value is not valid, but driver
handles this case as if "remote" arg is not provided at all. I think it
is reasonable to keep using 'rte_kvargs_process()', and fail if 'value'
is not provided.
> if (ret == -1)
> goto leave;
> }
>
> if (rte_kvargs_count(kvlist, ETH_TAP_MAC_ARG) == 1) {
> - ret = rte_kvargs_process(kvlist,
> - ETH_TAP_MAC_ARG,
> - &set_mac_type,
> - &user_mac);
> + ret = rte_kvargs_process_opt(kvlist,
> + ETH_TAP_MAC_ARG,
> + &set_mac_type,
> + &user_mac);
same here, 'rte_kvargs_process()' can be used, there is no point to give
"mac" keyword without value, that is same as not providing "mac" keyword
at all, so this can fail to notify user either provide a mac or remove
the argument.
I think current logic is to handle "value==null" case, otherwise this is
not a valid usecase.
> if (ret == -1)
> goto leave;
> }
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 5/5] net/mvneta: fix possible out-of-bounds write
2023-11-03 7:38 ` [PATCH v3 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
@ 2023-11-03 13:39 ` Ferruh Yigit
0 siblings, 0 replies; 131+ messages in thread
From: Ferruh Yigit @ 2023-11-03 13:39 UTC (permalink / raw)
To: Chengwen Feng, thomas, Zyta Szpak, Liron Himi, Ferruh Yigit,
Andrzej Ostruszka, Dmitri Epshtein, Yelena Krivosheev,
Natalie Samsonov
Cc: dev, stephen
On 11/3/2023 7:38 AM, Chengwen Feng wrote:
> The mvneta_ifnames_get() function will save 'iface' value to ifnames,
> it will out-of-bounds write if passed many iface pairs (e.g.
> 'iface=xxx,iface=xxx,...').
>
> Fixes: 4ccc8d770d3b ("net/mvneta: add PMD skeleton")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 0/5] fix segment fault when parse args
2023-11-03 7:38 ` [PATCH v3 0/5] fix segment fault when parse args Chengwen Feng
` (4 preceding siblings ...)
2023-11-03 7:38 ` [PATCH v3 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
@ 2023-11-03 13:41 ` Ferruh Yigit
2023-11-05 5:50 ` fengchengwen
5 siblings, 1 reply; 131+ messages in thread
From: Ferruh Yigit @ 2023-11-03 13:41 UTC (permalink / raw)
To: Chengwen Feng, thomas; +Cc: dev, stephen
On 11/3/2023 7:38 AM, Chengwen Feng wrote:
> The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
> it also supports to parse only-key (e.g. socket_id). But many drivers's
> callback can only handle key-value, it will segment fault if handles
> only-key. so the patchset [1] was introduced.
>
> Because the patchset [1] modified too much drivers, therefore:
> 1) A new API rte_kvargs_process_opt() was introduced, it inherits the
> function of rte_kvargs_process() which could parse both key-value and
> only-key.
> 2) Constraint the rte_kvargs_process() can only parse key-value.
>
> This patchset also include one bugfix for kvargs of mvneta driver.
>
> [1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
>
> Chengwen Feng (5):
> kvargs: add one new process API
> net/af_packet: use new API to parse kvargs
> net/sfc: use new API to parse kvargs
> net/tap: use new API to parse kvargs
> net/mvneta: fix possible out-of-bounds write
>
Hi Chengwen,
I checked the driver code updates above, but it is hard to know if there
are more missing, each requires investigating one by one.
Perhaps it can be easier to trace back from your original patch [1] and
update the ones that doesn't need "value == NULL" check, I assume this
is what you did.
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v4 0/5] fix segment fault when parse args
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
` (8 preceding siblings ...)
2023-11-03 7:38 ` [PATCH v3 0/5] fix segment fault when parse args Chengwen Feng
@ 2023-11-05 5:45 ` Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 1/5] kvargs: add one new process API Chengwen Feng
` (4 more replies)
2023-11-06 7:31 ` [PATCH v5 0/5] fix segment fault when parse args Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 0/4] " Chengwen Feng
11 siblings, 5 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-11-05 5:45 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
it also supports to parse only-key (e.g. socket_id). But many drivers's
callback can only handle key-value, it will segment fault if handles
only-key. so the patchset [1] was introduced.
Because the patchset [1] modified too much drivers, therefore:
1) A new API rte_kvargs_process_opt() was introduced, it inherits the
function of rte_kvargs_process() which could parse both key-value and
only-key.
2) Constraint the rte_kvargs_process() can only parse key-value.
This patchset also include one bugfix for kvargs of mvneta driver.
[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
Chengwen Feng (5):
kvargs: add one new process API
net/sfc: use new API to parse kvargs
net/tap: use new API to parse kvargs
common/nfp: use new API to parse kvargs
net/mvneta: fix possible out-of-bounds write
---
v4: refine API's define and impl which address Ferruh's comments.
add common/nfp change commit.
v3: introduce new API instead of modify too many drivers which address
Ferruh's comments.
doc/guides/rel_notes/release_23_11.rst | 13 ++++++++
drivers/common/nfp/nfp_common_pci.c | 4 +--
drivers/common/sfc_efx/sfc_efx.c | 4 +--
drivers/net/mvneta/mvneta_ethdev.c | 3 ++
drivers/net/sfc/sfc_kvargs.c | 2 +-
drivers/net/tap/rte_eth_tap.c | 10 +++---
lib/kvargs/rte_kvargs.c | 43 ++++++++++++++++++++------
lib/kvargs/rte_kvargs.h | 37 ++++++++++++++++++++--
lib/kvargs/version.map | 3 ++
9 files changed, 97 insertions(+), 22 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v4 1/5] kvargs: add one new process API
2023-11-05 5:45 ` [PATCH v4 " Chengwen Feng
@ 2023-11-05 5:45 ` Chengwen Feng
2023-11-06 3:18 ` Stephen Hemminger
2023-11-05 5:45 ` [PATCH v4 2/5] net/sfc: use new API to parse kvargs Chengwen Feng
` (3 subsequent siblings)
4 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-11-05 5:45 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
The rte_kvargs_process() was used to handle key=value (e.g.
socket_id=0), it also supports to handle only-key (e.g. socket_id).
But many drivers's callback can only handle key=value, it will segment
fault if handles only-key. so the patchset [1] was introduced.
Because the patchset [1] modified too much drivers, therefore:
1) A new API rte_kvargs_process_opt() was introduced, it inherits the
function of rte_kvargs_process() which could handle both key=value and
only-key cases.
2) Constraint the rte_kvargs_process() can only handle key=value cases,
it will return -1 when handle only-key case (that is the matched key's
value is NULL).
This patch also make sure the rte_kvargs_process_opt() and
rte_kvargs_process() API both return -1 when the kvlist parameter is
NULL.
[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
doc/guides/rel_notes/release_23_11.rst | 13 ++++++++
lib/kvargs/rte_kvargs.c | 43 ++++++++++++++++++++------
lib/kvargs/rte_kvargs.h | 37 ++++++++++++++++++++--
lib/kvargs/version.map | 3 ++
4 files changed, 84 insertions(+), 12 deletions(-)
diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index 249e5939e1..ea7b758b20 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -137,6 +137,19 @@ New Features
a group's miss actions, which are the actions to be performed on packets
that didn't match any of the flow rules in the group.
+* **Updated kvargs process API.**
+
+ * Introduced rte_kvargs_process_opt() API, which inherits the function
+ of rte_kvargs_process() and could handle both key=value and only-key
+ cases.
+
+ * Constraint rte_kvargs_process() API can only handle key=value cases,
+ it will return -1 when handle only-key case (that is the matched key's
+ value is NULL).
+
+ * Make sure rte_kvargs_process_opt() and rte_kvargs_process() API both
+ return -1 when the kvlist parameter is NULL.
+
* **Updated Amazon ena (Elastic Network Adapter) net driver.**
* Upgraded ENA HAL to latest version.
diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c
index c77bb82feb..adc47f8898 100644
--- a/lib/kvargs/rte_kvargs.c
+++ b/lib/kvargs/rte_kvargs.c
@@ -167,31 +167,56 @@ rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match)
return ret;
}
-/*
- * For each matching key, call the given handler function.
- */
-int
-rte_kvargs_process(const struct rte_kvargs *kvlist,
- const char *key_match,
- arg_handler_t handler,
- void *opaque_arg)
+static int
+kvargs_process_common(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg,
+ bool support_only_key)
{
const struct rte_kvargs_pair *pair;
unsigned i;
if (kvlist == NULL)
- return 0;
+ return -1;
for (i = 0; i < kvlist->count; i++) {
pair = &kvlist->pairs[i];
if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
+ if (!support_only_key && pair->value == NULL)
+ return -1;
if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
return -1;
}
}
+
return 0;
}
+/*
+ * For each matching key in key/value, call the given handler function.
+ */
+int
+rte_kvargs_process(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg)
+{
+ return kvargs_process_common(kvlist, key_match, handler, opaque_arg, false);
+}
+
+/*
+ * For each matching key in key/value or only-key, call the given handler function.
+ */
+int
+rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg)
+{
+ return kvargs_process_common(kvlist, key_match, handler, opaque_arg, true);
+}
+
/* free the rte_kvargs structure */
void
rte_kvargs_free(struct rte_kvargs *kvlist)
diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
index 4900b750bc..ad0b609ad7 100644
--- a/lib/kvargs/rte_kvargs.h
+++ b/lib/kvargs/rte_kvargs.h
@@ -172,14 +172,17 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
const char *key, const char *value);
/**
- * Call a handler function for each key/value matching the key
+ * Call a handler function for each key=value matching the key
*
- * For each key/value association that matches the given key, calls the
+ * For each key=value association that matches the given key, calls the
* handler function with the for a given arg_name passing the value on the
* dictionary for that key and a given extra argument.
*
+ * @note Compared to @see rte_kvargs_process_opt, this API will return -1
+ * when handle only-key case (that is the matched key's value is NULL).
+ *
* @param kvlist
- * The rte_kvargs structure. No error if NULL.
+ * The rte_kvargs structure.
* @param key_match
* The key on which the handler should be called, or NULL to process handler
* on all associations
@@ -195,6 +198,34 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
int rte_kvargs_process(const struct rte_kvargs *kvlist,
const char *key_match, arg_handler_t handler, void *opaque_arg);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Call a handler function for each key=value or only-key matching the key
+ *
+ * For each key=value or only-key association that matches the given key, calls
+ * the handler function with the for a given arg_name passing the value on the
+ * dictionary for that key and a given extra argument.
+ *
+ * @param kvlist
+ * The rte_kvargs structure.
+ * @param key_match
+ * The key on which the handler should be called, or NULL to process handler
+ * on all associations
+ * @param handler
+ * The function to call for each matching key
+ * @param opaque_arg
+ * A pointer passed unchanged to the handler
+ *
+ * @return
+ * - 0 on success
+ * - Negative on error
+ */
+__rte_experimental
+int rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
+ const char *key_match, arg_handler_t handler, void *opaque_arg);
+
/**
* Count the number of associations matching the given key
*
diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map
index 387a94e725..15d482e9b3 100644
--- a/lib/kvargs/version.map
+++ b/lib/kvargs/version.map
@@ -16,4 +16,7 @@ EXPERIMENTAL {
# added in 21.11
rte_kvargs_get_with_value;
+
+ # added in 23.11
+ rte_kvargs_process_opt;
};
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v4 2/5] net/sfc: use new API to parse kvargs
2023-11-05 5:45 ` [PATCH v4 " Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 1/5] kvargs: add one new process API Chengwen Feng
@ 2023-11-05 5:45 ` Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 3/5] net/tap: " Chengwen Feng
` (2 subsequent siblings)
4 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-11-05 5:45 UTC (permalink / raw)
To: thomas, ferruh.yigit, Andrew Rybchenko; +Cc: dev, stephen
The sfc_kvargs_process() and sfc_efx_dev_class_get() function could
handle both key=value and only-key, so they should use
rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/common/sfc_efx/sfc_efx.c | 4 ++--
drivers/net/sfc/sfc_kvargs.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
index 2dc5545760..3ebac909f1 100644
--- a/drivers/common/sfc_efx/sfc_efx.c
+++ b/drivers/common/sfc_efx/sfc_efx.c
@@ -52,8 +52,8 @@ sfc_efx_dev_class_get(struct rte_devargs *devargs)
return dev_class;
if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
- rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
- sfc_efx_kvarg_dev_class_handler, &dev_class);
+ rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
+ sfc_efx_kvarg_dev_class_handler, &dev_class);
}
rte_kvargs_free(kvargs);
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 783cb43ae6..24bb896179 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -70,7 +70,7 @@ sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
if (sa->kvargs == NULL)
return 0;
- return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
+ return -rte_kvargs_process_opt(sa->kvargs, key_match, handler, opaque_arg);
}
int
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v4 3/5] net/tap: use new API to parse kvargs
2023-11-05 5:45 ` [PATCH v4 " Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 1/5] kvargs: add one new process API Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 2/5] net/sfc: use new API to parse kvargs Chengwen Feng
@ 2023-11-05 5:45 ` Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 4/5] common/nfp: " Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
4 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-11-05 5:45 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
Some kvargs could be key=value or only-key, it should use
rte_kvargs_process_opt() instead of rte_kvargs_process() to handle
these kvargs.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/tap/rte_eth_tap.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index b41fa971cb..cdb52cf408 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2292,7 +2292,7 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
+ ret = rte_kvargs_process_opt(kvlist,
ETH_TAP_IFACE_ARG,
&set_interface_name,
tun_name);
@@ -2496,10 +2496,10 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
- ETH_TAP_IFACE_ARG,
- &set_interface_name,
- tap_name);
+ ret = rte_kvargs_process_opt(kvlist,
+ ETH_TAP_IFACE_ARG,
+ &set_interface_name,
+ tap_name);
if (ret == -1)
goto leave;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v4 4/5] common/nfp: use new API to parse kvargs
2023-11-05 5:45 ` [PATCH v4 " Chengwen Feng
` (2 preceding siblings ...)
2023-11-05 5:45 ` [PATCH v4 3/5] net/tap: " Chengwen Feng
@ 2023-11-05 5:45 ` Chengwen Feng
2023-11-06 3:19 ` Stephen Hemminger
2023-11-05 5:45 ` [PATCH v4 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
4 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-11-05 5:45 UTC (permalink / raw)
To: thomas, ferruh.yigit, Chaoyong He; +Cc: dev, stephen
The nfp_parse_class_options() function could handle both key=value and
only-key, so it should use rte_kvargs_process_opt() instead of
rte_kvargs_process() to parse.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/common/nfp/nfp_common_pci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
index 723035d0f7..ac0a363992 100644
--- a/drivers/common/nfp/nfp_common_pci.c
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -171,8 +171,8 @@ nfp_parse_class_options(const struct rte_devargs *devargs)
return dev_class;
if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
- rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
- nfp_kvarg_dev_class_handler, &dev_class);
+ rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
+ nfp_kvarg_dev_class_handler, &dev_class);
}
rte_kvargs_free(kvargs);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v4 5/5] net/mvneta: fix possible out-of-bounds write
2023-11-05 5:45 ` [PATCH v4 " Chengwen Feng
` (3 preceding siblings ...)
2023-11-05 5:45 ` [PATCH v4 4/5] common/nfp: " Chengwen Feng
@ 2023-11-05 5:45 ` Chengwen Feng
4 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-11-05 5:45 UTC (permalink / raw)
To: thomas, ferruh.yigit, Zyta Szpak, Liron Himi, Yelena Krivosheev,
Andrzej Ostruszka, Ferruh Yigit, Natalie Samsonov
Cc: dev, stephen
The mvneta_ifnames_get() function will save 'iface' value to ifnames,
it will out-of-bounds write if passed many iface pairs (e.g.
'iface=xxx,iface=xxx,...').
Fixes: 4ccc8d770d3b ("net/mvneta: add PMD skeleton")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
drivers/net/mvneta/mvneta_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index daa69e533a..8032a712f4 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -91,6 +91,9 @@ mvneta_ifnames_get(const char *key __rte_unused, const char *value,
{
struct mvneta_ifnames *ifnames = extra_args;
+ if (ifnames->idx >= NETA_NUM_ETH_PPIO)
+ return -EINVAL;
+
ifnames->names[ifnames->idx++] = value;
return 0;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 0/5] fix segment fault when parse args
2023-11-03 13:41 ` [PATCH v3 0/5] fix segment fault when parse args Ferruh Yigit
@ 2023-11-05 5:50 ` fengchengwen
0 siblings, 0 replies; 131+ messages in thread
From: fengchengwen @ 2023-11-05 5:50 UTC (permalink / raw)
To: Ferruh Yigit, thomas; +Cc: dev, stephen
Hi Ferruh,
On 2023/11/3 21:41, Ferruh Yigit wrote:
> On 11/3/2023 7:38 AM, Chengwen Feng wrote:
>> The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
>> it also supports to parse only-key (e.g. socket_id). But many drivers's
>> callback can only handle key-value, it will segment fault if handles
>> only-key. so the patchset [1] was introduced.
>>
>> Because the patchset [1] modified too much drivers, therefore:
>> 1) A new API rte_kvargs_process_opt() was introduced, it inherits the
>> function of rte_kvargs_process() which could parse both key-value and
>> only-key.
>> 2) Constraint the rte_kvargs_process() can only parse key-value.
>>
>> This patchset also include one bugfix for kvargs of mvneta driver.
>>
>> [1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
>>
>> Chengwen Feng (5):
>> kvargs: add one new process API
>> net/af_packet: use new API to parse kvargs
>> net/sfc: use new API to parse kvargs
>> net/tap: use new API to parse kvargs
>> net/mvneta: fix possible out-of-bounds write
>>
>
> Hi Chengwen,
>
> I checked the driver code updates above, but it is hard to know if there
> are more missing, each requires investigating one by one.
> Perhaps it can be easier to trace back from your original patch [1] and
> update the ones that doesn't need "value == NULL" check, I assume this
> is what you did.
There are 51 files modified in v2 [1], there will about 80 rte_kvargs_process() invoke in current git (stats by command [2]).
Exclude kvargs lib and it's test and part comment, there are 30 file was not in v2:
drivers/baseband/null/bbdev_null.c ---already treat NULL value as a error
drivers/baseband/turbo_sw/bbdev_turbo_software.c ---already treat NULL value as a error
drivers/bus/ifpga/ifpga_bus.c ---already treat NULL value as a error
drivers/common/nfp/nfp_common_pci.c ---could handle NULL value
drivers/common/sfc_efx/sfc_efx.c ---could handle NULL value
drivers/dma/skeleton/skeleton_dmadev.c ---already treat NULL value as a error
drivers/ml/cnxk/cn10k_ml_dev.c ---part treat NULL value as a error, other segment fault when with NULL value
drivers/ml/cnxk/mvtvm_ml_dev.c ---segment fault when with NULL value
drivers/net/af_packet/rte_eth_af_packet.c ---don't care about value, suggested don't change in v3's comment
drivers/net/bnxt/bnxt_ethdev.c ---already treat NULL value as a error
drivers/net/bonding/rte_eth_bond_pmd.c ---already treat NULL value as a error
drivers/net/cpfl/cpfl_ethdev.c ---segment fault when with NULL value
drivers/net/failsafe/failsafe_args.c ---already treat NULL value as a error
drivers/net/hns3/hns3_common.c ---already treat NULL value as a error
drivers/net/ixgbe/ixgbe_ethdev.c ---already treat NULL value as a error
drivers/net/null/rte_eth_null.c ---already treat NULL value as a error
drivers/net/softnic/rte_eth_softnic.c ---already treat NULL value as a error
drivers/net/tap/rte_eth_tap.c ---could handle NULL value
drivers/net/txgbe/txgbe_ethdev.c ---already treat NULL value as a error
drivers/net/vhost/rte_eth_vhost.c ---already treat NULL value as a error
drivers/net/virtio/virtio_ethdev.c ---already treat NULL value as a error
drivers/net/virtio/virtio_pci_ethdev.c ---already treat NULL value as a error
drivers/net/virtio/virtio_user_ethdev.c ---already treat NULL value as a error
drivers/raw/ifpga/ifpga_rawdev.c ---already treat NULL value as a error
drivers/raw/skeleton/skeleton_rawdev.c ---already treat NULL value as a error
drivers/vdpa/ifc/ifcvf_vdpa.c ---already treat NULL value as a error
drivers/vdpa/sfc/sfc_vdpa_filter.c ---already treat NULL value as a error
lib/compressdev/rte_compressdev_pmd.c ---already treat NULL value as a error
lib/cryptodev/cryptodev_pmd.c ---already treat NULL value as a error
lib/ethdev/rte_ethdev_telemetry.c ---already treat NULL value as a error
so we should only process three drivers: common/nfp, sfc, tap, and these are what v4 doing.
[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
[2] grep -rn "rte_kvargs_process(" | cut -d ":" -f 1 | sort | uniq -c | wc -l
Thanks
Chengwen
>
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 1/5] kvargs: add one new process API
2023-11-03 13:09 ` Ferruh Yigit
@ 2023-11-05 5:55 ` fengchengwen
0 siblings, 0 replies; 131+ messages in thread
From: fengchengwen @ 2023-11-05 5:55 UTC (permalink / raw)
To: Ferruh Yigit, thomas; +Cc: dev, stephen
Hi Ferruh,
On 2023/11/3 21:09, Ferruh Yigit wrote:
> On 11/3/2023 7:38 AM, Chengwen Feng wrote:
>> The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
>> it also supports to parse only-key (e.g. socket_id). But many drivers's
>> callback can only handle key-value, it will segment fault if handles
>> only-key. so the patchset [1] was introduced.
>>
>> Because the patchset [1] modified too much drivers, therefore:
>> 1) A new API rte_kvargs_process_opt() was introduced, it inherits the
>> function of rte_kvargs_process() which could parse both key-value and
>> only-key.
>> 2) Constraint the rte_kvargs_process() can only parse key-value.
>>
>
> Hi Chengwen,
>
> This works, but behavior change in 'rte_kvargs_process()' can hit some
> exiting users who handles both "key=value" and "key" cases.
>
> Other option is to keep 'rte_kvargs_process()' behavior same but add a
> new API like 'rte_kvargs_process_safe()' that checks "value == NULL"
> case, but this requires more existing code to change and in this option
> existing users doesn't get the benefit of the NULL check by default.
>
>
> Assuming number of the users that use 'rte_kvargs_process()' for
> "key=value" is majority, OK to continue with your change, but please
> document this in the release notes to highlight.
Thanks, already fix in v4
>
>
>
>> [1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
>>
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> ---
>> lib/kvargs/rte_kvargs.c | 29 ++++++++++++++++++++++++++++-
>> lib/kvargs/rte_kvargs.h | 28 ++++++++++++++++++++++++++++
>> lib/kvargs/version.map | 3 +++
>> 3 files changed, 59 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c
>> index c77bb82feb..5ce8664238 100644
>> --- a/lib/kvargs/rte_kvargs.c
>> +++ b/lib/kvargs/rte_kvargs.c
>> @@ -168,7 +168,7 @@ rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match)
>> }
>>
>> /*
>> - * For each matching key, call the given handler function.
>> + * For each matching key in key/value, call the given handler function.
>> */
>> int
>> rte_kvargs_process(const struct rte_kvargs *kvlist,
>> @@ -179,6 +179,33 @@ rte_kvargs_process(const struct rte_kvargs *kvlist,
>> const struct rte_kvargs_pair *pair;
>> unsigned i;
>>
>> + if (kvlist == NULL)
>> + return 0;
>> +
>
> I think it should return error here, ignoring arg silently with success
> can cause trouble in the application. If error returned, at least
> application can know argument not provided as it should be (value is
> missing).
fix in v4.
>
>
>> + for (i = 0; i < kvlist->count; i++) {
>> + pair = &kvlist->pairs[i];
>> + if (pair->value == NULL)
>> + continue;
>> + if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
>> + if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
>> + return -1;
>> + }
>> + }
>> + return 0;
>> +}
>> +
>
> 'rte_kvargs_process()' & 'rte_kvargs_process_opt()' implementations are
> very similar, to reduce duplication what about create
> 'rte_kvargs_process_common()' static function and both use this common
> with different parameter?
nice catch, fix in v4.
>
>
>> +/*
>> + * For each matching key in key/value or only-key, call the given handler function.
>> + */
>> +int
>> +rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
>> + const char *key_match,
>> + arg_handler_t handler,
>> + void *opaque_arg)
>> +{
>> + const struct rte_kvargs_pair *pair;
>> + unsigned int i;
>> +
>> if (kvlist == NULL)
>> return 0;
>>
>> diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
>> index 4900b750bc..522e83f757 100644
>> --- a/lib/kvargs/rte_kvargs.h
>> +++ b/lib/kvargs/rte_kvargs.h
>> @@ -195,6 +195,34 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
>> int rte_kvargs_process(const struct rte_kvargs *kvlist,
>> const char *key_match, arg_handler_t handler, void *opaque_arg);
>>
>> +/**
>> + * @warning
>> + * @b EXPERIMENTAL: this API may change without prior notice.
>> + *
>> + * Call a handler function for each key/value or only-key matching the key
>> + *
>>
>
> In API documentation, the difference between 'rte_kvargs_process_opt()'
> & 'rte_kvargs_process()' is, 'rte_kvargs_process()' doesn't have "or
> only-key", this is easy to miss.
> Can you please add more not to 'rte_kvargs_process()' saying on
> "only-key" case it returns error?
add one @note in v4.
>
>
>> + * For each key/value or only-key association that matches the given key, calls
>> + * the handler function with the for a given arg_name passing the value on the
>> + * dictionary for that key and a given extra argument.
>> + *
>> + * @param kvlist
>> + * The rte_kvargs structure. No error if NULL.
>> + * @param key_match
>> + * The key on which the handler should be called, or NULL to process handler
>> + * on all associations
>> + * @param handler
>> + * The function to call for each matching key
>> + * @param opaque_arg
>> + * A pointer passed unchanged to the handler
>> + *
>> + * @return
>> + * - 0 on success
>> + * - Negative on error
>> + */
>> +__rte_experimental
>> +int rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
>> + const char *key_match, arg_handler_t handler, void *opaque_arg);
>> +
>>
>
> I am not sure about the API name, 'rte_kvargs_process_opt()', what is
> 'opt' here, "optional"?
Yes, it mean optional of value is valid or NULL.
> What about 'rte_kvargs_process_unsafe()', not quite strong on this too
> but not able to come with better one, please feel free to try other
> alternatives.
also have no better name, so keep the same with v3.
Thanks
Chengwen
>
>
>> /**
>> * Count the number of associations matching the given key
>> *
>> diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map
>> index 387a94e725..15d482e9b3 100644
>> --- a/lib/kvargs/version.map
>> +++ b/lib/kvargs/version.map
>> @@ -16,4 +16,7 @@ EXPERIMENTAL {
>>
>> # added in 21.11
>> rte_kvargs_get_with_value;
>> +
>> + # added in 23.11
>> + rte_kvargs_process_opt;
>> };
>
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 2/5] net/af_packet: use new API to parse kvargs
2023-11-03 13:11 ` Ferruh Yigit
@ 2023-11-05 5:56 ` fengchengwen
0 siblings, 0 replies; 131+ messages in thread
From: fengchengwen @ 2023-11-05 5:56 UTC (permalink / raw)
To: Ferruh Yigit, thomas, John W. Linville; +Cc: dev, stephen
Hi Ferruh,
On 2023/11/3 21:11, Ferruh Yigit wrote:
> On 11/3/2023 7:38 AM, Chengwen Feng wrote:
>> This driver don't care about the 'iface' value, it should use
>> rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
>>
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> ---
>> drivers/net/af_packet/rte_eth_af_packet.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
>> index 397a32db58..54a9f5f746 100644
>> --- a/drivers/net/af_packet/rte_eth_af_packet.c
>> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
>> @@ -1096,8 +1096,8 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev)
>> */
>> if (rte_kvargs_count(kvlist, ETH_AF_PACKET_IFACE_ARG) == 1) {
>>
>> - ret = rte_kvargs_process(kvlist, ETH_AF_PACKET_IFACE_ARG,
>> - &open_packet_iface, &sockfd);
>> + ret = rte_kvargs_process_opt(kvlist, ETH_AF_PACKET_IFACE_ARG,
>> + &open_packet_iface, &sockfd);
>> if (ret < 0)
>> goto exit;
>> }
>
> lets not update this driver, I think it is using kvargs
> unconventionally, 'iface' requires argument but driver parses it
> directly from kvargs.
>
> We can fix kvargs usage more properly instead of this change, I am
> taking a mental note for this.
got, it was droped from v4.
Thanks
Chengwen
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v3 4/5] net/tap: use new API to parse kvargs
2023-11-03 13:34 ` Ferruh Yigit
@ 2023-11-05 5:57 ` fengchengwen
0 siblings, 0 replies; 131+ messages in thread
From: fengchengwen @ 2023-11-05 5:57 UTC (permalink / raw)
To: Ferruh Yigit, thomas; +Cc: dev, stephen
Hi Ferruh,
Thanks for deepin, both fix in v4.
On 2023/11/3 21:34, Ferruh Yigit wrote:
> On 11/3/2023 7:38 AM, Chengwen Feng wrote:
>> This driver could handles both key=value and only-key kvargs, so it
>> should use rte_kvargs_process_opt() instead of rte_kvargs_process() to
>> parse.
>>
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> ---
>> drivers/net/tap/rte_eth_tap.c | 26 +++++++++++++-------------
>> 1 file changed, 13 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
>> index b25a52655f..8b35de0a7a 100644
>> --- a/drivers/net/tap/rte_eth_tap.c
>> +++ b/drivers/net/tap/rte_eth_tap.c
>> @@ -2342,7 +2342,7 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
>> kvlist = rte_kvargs_parse(params, valid_arguments);
>> if (kvlist) {
>> if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
>> - ret = rte_kvargs_process(kvlist,
>> + ret = rte_kvargs_process_opt(kvlist,
>> ETH_TAP_IFACE_ARG,
>> &set_interface_name,
>> tun_name);
>> @@ -2546,28 +2546,28 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
>> kvlist = rte_kvargs_parse(params, valid_arguments);
>> if (kvlist) {
>> if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
>> - ret = rte_kvargs_process(kvlist,
>> - ETH_TAP_IFACE_ARG,
>> - &set_interface_name,
>> - tap_name);
>> + ret = rte_kvargs_process_opt(kvlist,
>> + ETH_TAP_IFACE_ARG,
>> + &set_interface_name,
>> + tap_name);
>> if (ret == -1)
>> goto leave;
>> }
>>
>> if (rte_kvargs_count(kvlist, ETH_TAP_REMOTE_ARG) == 1) {
>> - ret = rte_kvargs_process(kvlist,
>> - ETH_TAP_REMOTE_ARG,
>> - &set_remote_iface,
>> - remote_iface);
>> + ret = rte_kvargs_process_opt(kvlist,
>> + ETH_TAP_REMOTE_ARG,
>> + &set_remote_iface,
>> + remote_iface);
>>
>
> As far as I can see, "remote" arg without value is not valid, but driver
> handles this case as if "remote" arg is not provided at all. I think it
> is reasonable to keep using 'rte_kvargs_process()', and fail if 'value'
> is not provided.
>
>
>> if (ret == -1)
>> goto leave;
>> }
>>
>> if (rte_kvargs_count(kvlist, ETH_TAP_MAC_ARG) == 1) {
>> - ret = rte_kvargs_process(kvlist,
>> - ETH_TAP_MAC_ARG,
>> - &set_mac_type,
>> - &user_mac);
>> + ret = rte_kvargs_process_opt(kvlist,
>> + ETH_TAP_MAC_ARG,
>> + &set_mac_type,
>> + &user_mac);
>
> same here, 'rte_kvargs_process()' can be used, there is no point to give
> "mac" keyword without value, that is same as not providing "mac" keyword
> at all, so this can fail to notify user either provide a mac or remove
> the argument.
>
> I think current logic is to handle "value==null" case, otherwise this is
> not a valid usecase.
>
>> if (ret == -1)
>> goto leave;
>> }
>
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v4 1/5] kvargs: add one new process API
2023-11-05 5:45 ` [PATCH v4 1/5] kvargs: add one new process API Chengwen Feng
@ 2023-11-06 3:18 ` Stephen Hemminger
2023-11-06 7:13 ` fengchengwen
0 siblings, 1 reply; 131+ messages in thread
From: Stephen Hemminger @ 2023-11-06 3:18 UTC (permalink / raw)
To: Chengwen Feng; +Cc: thomas, ferruh.yigit, dev
On Sun, 5 Nov 2023 05:45:35 +0000
Chengwen Feng <fengchengwen@huawei.com> wrote:
> +* **Updated kvargs process API.**
> +
> + * Introduced rte_kvargs_process_opt() API, which inherits the function
> + of rte_kvargs_process() and could handle both key=value and only-key
> + cases.
> +
> + * Constraint rte_kvargs_process() API can only handle key=value cases,
> + it will return -1 when handle only-key case (that is the matched key's
> + value is NULL).
> +
Looks good but may I suggest some alternatives.
Since this is an API and ABI change as was not announced, maybe a little late
in the process for this release. And since unlikely to go in 23.11 need to do something
better in 24.03.
What about changing the args to rte_kvargs_process() to add an additional default
value. Most callers don't have a default (use key-value) but the ones that take only-key
would pass the default value.
Then use ABI versioning to add the new arg and you would not have to introduce
a new function. And add a legacy API version that does what current code does.
All the drivers in DPDK would get the new API/ABI but any customer apps using rte_kvargs_process()
would get the old version.
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v4 4/5] common/nfp: use new API to parse kvargs
2023-11-05 5:45 ` [PATCH v4 4/5] common/nfp: " Chengwen Feng
@ 2023-11-06 3:19 ` Stephen Hemminger
2023-11-06 7:22 ` fengchengwen
0 siblings, 1 reply; 131+ messages in thread
From: Stephen Hemminger @ 2023-11-06 3:19 UTC (permalink / raw)
To: Chengwen Feng; +Cc: thomas, ferruh.yigit, Chaoyong He, dev
On Sun, 5 Nov 2023 05:45:38 +0000
Chengwen Feng <fengchengwen@huawei.com> wrote:
> if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
> - rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
> - nfp_kvarg_dev_class_handler, &dev_class);
> + rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
> + nfp_kvarg_dev_class_handler, &dev_class);
> }
Since kvargs_process() already does a scan, the kvargs_count() cause an extra pass.
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v4 1/5] kvargs: add one new process API
2023-11-06 3:18 ` Stephen Hemminger
@ 2023-11-06 7:13 ` fengchengwen
2023-11-06 16:19 ` Stephen Hemminger
0 siblings, 1 reply; 131+ messages in thread
From: fengchengwen @ 2023-11-06 7:13 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: thomas, ferruh.yigit, dev
Hi Stephen,
On 2023/11/6 11:18, Stephen Hemminger wrote:
> On Sun, 5 Nov 2023 05:45:35 +0000
> Chengwen Feng <fengchengwen@huawei.com> wrote:
>
>> +* **Updated kvargs process API.**
>> +
>> + * Introduced rte_kvargs_process_opt() API, which inherits the function
>> + of rte_kvargs_process() and could handle both key=value and only-key
>> + cases.
>> +
>> + * Constraint rte_kvargs_process() API can only handle key=value cases,
>> + it will return -1 when handle only-key case (that is the matched key's
>> + value is NULL).
>> +
>
> Looks good but may I suggest some alternatives.
>
> Since this is an API and ABI change as was not announced, maybe a little late
> in the process for this release. And since unlikely to go in 23.11 need to do something
> better in 24.03.
>
> What about changing the args to rte_kvargs_process() to add an additional default
> value. Most callers don't have a default (use key-value) but the ones that take only-key
> would pass the default value.
The API definition changed, it may need modify most drivers.
Although it's a little late, better continue current.
Thanks
Chengwen
>
> Then use ABI versioning to add the new arg and you would not have to introduce
> a new function. And add a legacy API version that does what current code does.
>
> All the drivers in DPDK would get the new API/ABI but any customer apps using rte_kvargs_process()
> would get the old version.
>
>
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v4 4/5] common/nfp: use new API to parse kvargs
2023-11-06 3:19 ` Stephen Hemminger
@ 2023-11-06 7:22 ` fengchengwen
0 siblings, 0 replies; 131+ messages in thread
From: fengchengwen @ 2023-11-06 7:22 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: thomas, ferruh.yigit, Chaoyong He, dev
Hi Stephen,
On 2023/11/6 11:19, Stephen Hemminger wrote:
> On Sun, 5 Nov 2023 05:45:38 +0000
> Chengwen Feng <fengchengwen@huawei.com> wrote:
>
>> if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
>> - rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
>> - nfp_kvarg_dev_class_handler, &dev_class);
>> + rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
>> + nfp_kvarg_dev_class_handler, &dev_class);
>> }
>
> Since kvargs_process() already does a scan, the kvargs_count() cause an extra pass.
will fix in v5
Thanks
Chengwen
>
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v5 0/5] fix segment fault when parse args
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
` (9 preceding siblings ...)
2023-11-05 5:45 ` [PATCH v4 " Chengwen Feng
@ 2023-11-06 7:31 ` Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 1/5] kvargs: add one new process API Chengwen Feng
` (5 more replies)
2024-10-09 4:50 ` [PATCH v6 0/4] " Chengwen Feng
11 siblings, 6 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-11-06 7:31 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
it also supports to parse only-key (e.g. socket_id). But many drivers's
callback can only handle key-value, it will segment fault if handles
only-key. so the patchset [1] was introduced.
Because the patchset [1] modified too much drivers, therefore:
1) A new API rte_kvargs_process_opt() was introduced, it inherits the
function of rte_kvargs_process() which could parse both key-value and
only-key.
2) Constraint the rte_kvargs_process() can only parse key-value.
This patchset also include one bugfix for kvargs of mvneta driver.
[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
Chengwen Feng (5):
kvargs: add one new process API
net/sfc: use new API to parse kvargs
net/tap: use new API to parse kvargs
common/nfp: use new API to parse kvargs
net/mvneta: fix possible out-of-bounds write
---
v5: remove redundant of rte_kvargs_count of 4/5 commit which address
Stephen's comment.
v4: refine API's define and impl which address Ferruh's comments.
add common/nfp change commit.
v3: introduce new API instead of modify too many drivers which address
Ferruh's comments.
doc/guides/rel_notes/release_23_11.rst | 13 ++++++++
drivers/common/nfp/nfp_common_pci.c | 6 ++--
drivers/common/sfc_efx/sfc_efx.c | 4 +--
drivers/net/mvneta/mvneta_ethdev.c | 3 ++
drivers/net/sfc/sfc_kvargs.c | 2 +-
drivers/net/tap/rte_eth_tap.c | 10 +++---
lib/kvargs/rte_kvargs.c | 43 ++++++++++++++++++++------
lib/kvargs/rte_kvargs.h | 37 ++++++++++++++++++++--
lib/kvargs/version.map | 3 ++
9 files changed, 97 insertions(+), 24 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v5 1/5] kvargs: add one new process API
2023-11-06 7:31 ` [PATCH v5 0/5] fix segment fault when parse args Chengwen Feng
@ 2023-11-06 7:31 ` Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 2/5] net/sfc: use new API to parse kvargs Chengwen Feng
` (4 subsequent siblings)
5 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-11-06 7:31 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
The rte_kvargs_process() was used to handle key=value (e.g.
socket_id=0), it also supports to handle only-key (e.g. socket_id).
But many drivers's callback can only handle key=value, it will segment
fault if handles only-key. so the patchset [1] was introduced.
Because the patchset [1] modified too much drivers, therefore:
1) A new API rte_kvargs_process_opt() was introduced, it inherits the
function of rte_kvargs_process() which could handle both key=value and
only-key cases.
2) Constraint the rte_kvargs_process() can only handle key=value cases,
it will return -1 when handle only-key case (that is the matched key's
value is NULL).
This patch also make sure the rte_kvargs_process_opt() and
rte_kvargs_process() API both return -1 when the kvlist parameter is
NULL.
[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
doc/guides/rel_notes/release_23_11.rst | 13 ++++++++
lib/kvargs/rte_kvargs.c | 43 ++++++++++++++++++++------
lib/kvargs/rte_kvargs.h | 37 ++++++++++++++++++++--
lib/kvargs/version.map | 3 ++
4 files changed, 84 insertions(+), 12 deletions(-)
diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index 2213aeae7b..8db3bbbd2f 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -142,6 +142,19 @@ New Features
a group's miss actions, which are the actions to be performed on packets
that didn't match any of the flow rules in the group.
+* **Updated kvargs process API.**
+
+ * Introduced rte_kvargs_process_opt() API, which inherits the function
+ of rte_kvargs_process() and could handle both key=value and only-key
+ cases.
+
+ * Constraint rte_kvargs_process() API can only handle key=value cases,
+ it will return -1 when handle only-key case (that is the matched key's
+ value is NULL).
+
+ * Make sure rte_kvargs_process_opt() and rte_kvargs_process() API both
+ return -1 when the kvlist parameter is NULL.
+
* **Updated Amazon ena (Elastic Network Adapter) net driver.**
* Upgraded ENA HAL to latest version.
diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c
index c77bb82feb..adc47f8898 100644
--- a/lib/kvargs/rte_kvargs.c
+++ b/lib/kvargs/rte_kvargs.c
@@ -167,31 +167,56 @@ rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match)
return ret;
}
-/*
- * For each matching key, call the given handler function.
- */
-int
-rte_kvargs_process(const struct rte_kvargs *kvlist,
- const char *key_match,
- arg_handler_t handler,
- void *opaque_arg)
+static int
+kvargs_process_common(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg,
+ bool support_only_key)
{
const struct rte_kvargs_pair *pair;
unsigned i;
if (kvlist == NULL)
- return 0;
+ return -1;
for (i = 0; i < kvlist->count; i++) {
pair = &kvlist->pairs[i];
if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
+ if (!support_only_key && pair->value == NULL)
+ return -1;
if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
return -1;
}
}
+
return 0;
}
+/*
+ * For each matching key in key/value, call the given handler function.
+ */
+int
+rte_kvargs_process(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg)
+{
+ return kvargs_process_common(kvlist, key_match, handler, opaque_arg, false);
+}
+
+/*
+ * For each matching key in key/value or only-key, call the given handler function.
+ */
+int
+rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg)
+{
+ return kvargs_process_common(kvlist, key_match, handler, opaque_arg, true);
+}
+
/* free the rte_kvargs structure */
void
rte_kvargs_free(struct rte_kvargs *kvlist)
diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
index 4900b750bc..ad0b609ad7 100644
--- a/lib/kvargs/rte_kvargs.h
+++ b/lib/kvargs/rte_kvargs.h
@@ -172,14 +172,17 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
const char *key, const char *value);
/**
- * Call a handler function for each key/value matching the key
+ * Call a handler function for each key=value matching the key
*
- * For each key/value association that matches the given key, calls the
+ * For each key=value association that matches the given key, calls the
* handler function with the for a given arg_name passing the value on the
* dictionary for that key and a given extra argument.
*
+ * @note Compared to @see rte_kvargs_process_opt, this API will return -1
+ * when handle only-key case (that is the matched key's value is NULL).
+ *
* @param kvlist
- * The rte_kvargs structure. No error if NULL.
+ * The rte_kvargs structure.
* @param key_match
* The key on which the handler should be called, or NULL to process handler
* on all associations
@@ -195,6 +198,34 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
int rte_kvargs_process(const struct rte_kvargs *kvlist,
const char *key_match, arg_handler_t handler, void *opaque_arg);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Call a handler function for each key=value or only-key matching the key
+ *
+ * For each key=value or only-key association that matches the given key, calls
+ * the handler function with the for a given arg_name passing the value on the
+ * dictionary for that key and a given extra argument.
+ *
+ * @param kvlist
+ * The rte_kvargs structure.
+ * @param key_match
+ * The key on which the handler should be called, or NULL to process handler
+ * on all associations
+ * @param handler
+ * The function to call for each matching key
+ * @param opaque_arg
+ * A pointer passed unchanged to the handler
+ *
+ * @return
+ * - 0 on success
+ * - Negative on error
+ */
+__rte_experimental
+int rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
+ const char *key_match, arg_handler_t handler, void *opaque_arg);
+
/**
* Count the number of associations matching the given key
*
diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map
index 387a94e725..15d482e9b3 100644
--- a/lib/kvargs/version.map
+++ b/lib/kvargs/version.map
@@ -16,4 +16,7 @@ EXPERIMENTAL {
# added in 21.11
rte_kvargs_get_with_value;
+
+ # added in 23.11
+ rte_kvargs_process_opt;
};
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v5 2/5] net/sfc: use new API to parse kvargs
2023-11-06 7:31 ` [PATCH v5 0/5] fix segment fault when parse args Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 1/5] kvargs: add one new process API Chengwen Feng
@ 2023-11-06 7:31 ` Chengwen Feng
2023-11-06 10:28 ` Andrew Rybchenko
2023-11-06 7:31 ` [PATCH v5 3/5] net/tap: " Chengwen Feng
` (3 subsequent siblings)
5 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-11-06 7:31 UTC (permalink / raw)
To: thomas, ferruh.yigit, Andrew Rybchenko; +Cc: dev, stephen
The sfc_kvargs_process() and sfc_efx_dev_class_get() function could
handle both key=value and only-key, so they should use
rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/common/sfc_efx/sfc_efx.c | 4 ++--
drivers/net/sfc/sfc_kvargs.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
index 2dc5545760..3ebac909f1 100644
--- a/drivers/common/sfc_efx/sfc_efx.c
+++ b/drivers/common/sfc_efx/sfc_efx.c
@@ -52,8 +52,8 @@ sfc_efx_dev_class_get(struct rte_devargs *devargs)
return dev_class;
if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
- rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
- sfc_efx_kvarg_dev_class_handler, &dev_class);
+ rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
+ sfc_efx_kvarg_dev_class_handler, &dev_class);
}
rte_kvargs_free(kvargs);
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 783cb43ae6..24bb896179 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -70,7 +70,7 @@ sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
if (sa->kvargs == NULL)
return 0;
- return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
+ return -rte_kvargs_process_opt(sa->kvargs, key_match, handler, opaque_arg);
}
int
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v5 3/5] net/tap: use new API to parse kvargs
2023-11-06 7:31 ` [PATCH v5 0/5] fix segment fault when parse args Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 1/5] kvargs: add one new process API Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 2/5] net/sfc: use new API to parse kvargs Chengwen Feng
@ 2023-11-06 7:31 ` Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 4/5] common/nfp: " Chengwen Feng
` (2 subsequent siblings)
5 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-11-06 7:31 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
Some kvargs could be key=value or only-key, it should use
rte_kvargs_process_opt() instead of rte_kvargs_process() to handle
these kvargs.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/tap/rte_eth_tap.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index b41fa971cb..cdb52cf408 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2292,7 +2292,7 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
+ ret = rte_kvargs_process_opt(kvlist,
ETH_TAP_IFACE_ARG,
&set_interface_name,
tun_name);
@@ -2496,10 +2496,10 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
- ETH_TAP_IFACE_ARG,
- &set_interface_name,
- tap_name);
+ ret = rte_kvargs_process_opt(kvlist,
+ ETH_TAP_IFACE_ARG,
+ &set_interface_name,
+ tap_name);
if (ret == -1)
goto leave;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v5 4/5] common/nfp: use new API to parse kvargs
2023-11-06 7:31 ` [PATCH v5 0/5] fix segment fault when parse args Chengwen Feng
` (2 preceding siblings ...)
2023-11-06 7:31 ` [PATCH v5 3/5] net/tap: " Chengwen Feng
@ 2023-11-06 7:31 ` Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
2024-10-05 1:19 ` [PATCH v5 0/5] fix segment fault when parse args Stephen Hemminger
5 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2023-11-06 7:31 UTC (permalink / raw)
To: thomas, ferruh.yigit, Chaoyong He; +Cc: dev, stephen
The nfp_parse_class_options() function could handle both key=value and
only-key, so it should use rte_kvargs_process_opt() instead of
rte_kvargs_process() to parse.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/common/nfp/nfp_common_pci.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
index 723035d0f7..5c36052f9d 100644
--- a/drivers/common/nfp/nfp_common_pci.c
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -170,10 +170,8 @@ nfp_parse_class_options(const struct rte_devargs *devargs)
if (kvargs == NULL)
return dev_class;
- if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
- rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
- nfp_kvarg_dev_class_handler, &dev_class);
- }
+ rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
+ nfp_kvarg_dev_class_handler, &dev_class);
rte_kvargs_free(kvargs);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v5 5/5] net/mvneta: fix possible out-of-bounds write
2023-11-06 7:31 ` [PATCH v5 0/5] fix segment fault when parse args Chengwen Feng
` (3 preceding siblings ...)
2023-11-06 7:31 ` [PATCH v5 4/5] common/nfp: " Chengwen Feng
@ 2023-11-06 7:31 ` Chengwen Feng
2023-11-21 2:11 ` lihuisong (C)
2024-10-05 1:19 ` [PATCH v5 0/5] fix segment fault when parse args Stephen Hemminger
5 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2023-11-06 7:31 UTC (permalink / raw)
To: thomas, ferruh.yigit, Zyta Szpak, Liron Himi, Ferruh Yigit,
Yelena Krivosheev, Dmitri Epshtein, Andrzej Ostruszka
Cc: dev, stephen
The mvneta_ifnames_get() function will save 'iface' value to ifnames,
it will out-of-bounds write if passed many iface pairs (e.g.
'iface=xxx,iface=xxx,...').
Fixes: 4ccc8d770d3b ("net/mvneta: add PMD skeleton")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
drivers/net/mvneta/mvneta_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index daa69e533a..8032a712f4 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -91,6 +91,9 @@ mvneta_ifnames_get(const char *key __rte_unused, const char *value,
{
struct mvneta_ifnames *ifnames = extra_args;
+ if (ifnames->idx >= NETA_NUM_ETH_PPIO)
+ return -EINVAL;
+
ifnames->names[ifnames->idx++] = value;
return 0;
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v5 2/5] net/sfc: use new API to parse kvargs
2023-11-06 7:31 ` [PATCH v5 2/5] net/sfc: use new API to parse kvargs Chengwen Feng
@ 2023-11-06 10:28 ` Andrew Rybchenko
2023-11-06 12:29 ` fengchengwen
0 siblings, 1 reply; 131+ messages in thread
From: Andrew Rybchenko @ 2023-11-06 10:28 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit; +Cc: dev, stephen, Vijay Kumar Srivastava
On 11/6/23 10:31, Chengwen Feng wrote:
> The sfc_kvargs_process() and sfc_efx_dev_class_get() function could
> handle both key=value and only-key, so they should use
> rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> drivers/common/sfc_efx/sfc_efx.c | 4 ++--
> drivers/net/sfc/sfc_kvargs.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
> index 2dc5545760..3ebac909f1 100644
> --- a/drivers/common/sfc_efx/sfc_efx.c
> +++ b/drivers/common/sfc_efx/sfc_efx.c
> @@ -52,8 +52,8 @@ sfc_efx_dev_class_get(struct rte_devargs *devargs)
> return dev_class;
>
> if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
> - rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
> - sfc_efx_kvarg_dev_class_handler, &dev_class);
> + rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
> + sfc_efx_kvarg_dev_class_handler, &dev_class);
LGTM from code point of view, but I'm not sure that I understand the
idea behind handling NULL value in sfc_efx_kvarg_dev_class_handler().
Cc: Vijay
> }
>
> rte_kvargs_free(kvargs);
> diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
> index 783cb43ae6..24bb896179 100644
> --- a/drivers/net/sfc/sfc_kvargs.c
> +++ b/drivers/net/sfc/sfc_kvargs.c
> @@ -70,7 +70,7 @@ sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
> if (sa->kvargs == NULL)
> return 0;
>
> - return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
> + return -rte_kvargs_process_opt(sa->kvargs, key_match, handler, opaque_arg);
It looks wrong to me since many handlers do not handle NULL string
gracefully. As I understand some handlers where fixed to avoid crash
and correct fix would be to keep rte_kvargs_process() and remove
unnecessary checks for NULL string value.
> }
>
> int
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v5 2/5] net/sfc: use new API to parse kvargs
2023-11-06 10:28 ` Andrew Rybchenko
@ 2023-11-06 12:29 ` fengchengwen
2023-11-07 7:18 ` Andrew Rybchenko
0 siblings, 1 reply; 131+ messages in thread
From: fengchengwen @ 2023-11-06 12:29 UTC (permalink / raw)
To: Andrew Rybchenko, thomas, ferruh.yigit
Cc: dev, stephen, Vijay Kumar Srivastava
Hi Andrew,
On 2023/11/6 18:28, Andrew Rybchenko wrote:
> On 11/6/23 10:31, Chengwen Feng wrote:
>> The sfc_kvargs_process() and sfc_efx_dev_class_get() function could
>> handle both key=value and only-key, so they should use
>> rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
>>
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> ---
>> drivers/common/sfc_efx/sfc_efx.c | 4 ++--
>> drivers/net/sfc/sfc_kvargs.c | 2 +-
>> 2 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
>> index 2dc5545760..3ebac909f1 100644
>> --- a/drivers/common/sfc_efx/sfc_efx.c
>> +++ b/drivers/common/sfc_efx/sfc_efx.c
>> @@ -52,8 +52,8 @@ sfc_efx_dev_class_get(struct rte_devargs *devargs)
>> return dev_class;
>> if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
>> - rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
>> - sfc_efx_kvarg_dev_class_handler, &dev_class);
>> + rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
>> + sfc_efx_kvarg_dev_class_handler, &dev_class);
>
> LGTM from code point of view, but I'm not sure that I understand the
> idea behind handling NULL value in sfc_efx_kvarg_dev_class_handler().
>
> Cc: Vijay
>
>> }
>> rte_kvargs_free(kvargs);
>> diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
>> index 783cb43ae6..24bb896179 100644
>> --- a/drivers/net/sfc/sfc_kvargs.c
>> +++ b/drivers/net/sfc/sfc_kvargs.c
>> @@ -70,7 +70,7 @@ sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
>> if (sa->kvargs == NULL)
>> return 0;
>> - return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
>> + return -rte_kvargs_process_opt(sa->kvargs, key_match, handler, opaque_arg);
>
> It looks wrong to me since many handlers do not handle NULL string gracefully. As I understand some handlers where fixed to avoid crash
> and correct fix would be to keep rte_kvargs_process() and remove
> unnecessary checks for NULL string value.
The scope is large, I suggest creates a new patchset later which remove unnecessary checks for NULL string value.
>
>> }
>> int
>
> .
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v4 1/5] kvargs: add one new process API
2023-11-06 7:13 ` fengchengwen
@ 2023-11-06 16:19 ` Stephen Hemminger
2023-11-07 3:21 ` fengchengwen
0 siblings, 1 reply; 131+ messages in thread
From: Stephen Hemminger @ 2023-11-06 16:19 UTC (permalink / raw)
To: fengchengwen; +Cc: thomas, ferruh.yigit, dev
On Mon, 6 Nov 2023 15:13:35 +0800
fengchengwen <fengchengwen@huawei.com> wrote:
> >> +
> >
> > Looks good but may I suggest some alternatives.
> >
> > Since this is an API and ABI change as was not announced, maybe a little late
> > in the process for this release. And since unlikely to go in 23.11 need to do something
> > better in 24.03.
> >
> > What about changing the args to rte_kvargs_process() to add an additional default
> > value. Most callers don't have a default (use key-value) but the ones that take only-key
> > would pass the default value.
>
> The API definition changed, it may need modify most drivers.
>
> Although it's a little late, better continue current.
>
> Thanks
> Chengwen
Looking ahead, I would like to replace all of EAL args and KVargs processing
with something more like the python parseargs library. The API is cleaner and
incorporating the help with arg parsing is a real benefit. Thomas also suggested
integrating help in the arg parsing.
Something like: https://github.com/cofyc/argparse
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v4 1/5] kvargs: add one new process API
2023-11-06 16:19 ` Stephen Hemminger
@ 2023-11-07 3:21 ` fengchengwen
0 siblings, 0 replies; 131+ messages in thread
From: fengchengwen @ 2023-11-07 3:21 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: thomas, ferruh.yigit, dev
Hi Stephen,
On 2023/11/7 0:19, Stephen Hemminger wrote:
> On Mon, 6 Nov 2023 15:13:35 +0800
> fengchengwen <fengchengwen@huawei.com> wrote:
>
>>>> +
>>>
>>> Looks good but may I suggest some alternatives.
>>>
>>> Since this is an API and ABI change as was not announced, maybe a little late
>>> in the process for this release. And since unlikely to go in 23.11 need to do something
>>> better in 24.03.
>>>
>>> What about changing the args to rte_kvargs_process() to add an additional default
>>> value. Most callers don't have a default (use key-value) but the ones that take only-key
>>> would pass the default value.
>>
>> The API definition changed, it may need modify most drivers.
>>
>> Although it's a little late, better continue current.
>>
>> Thanks
>> Chengwen
>
> Looking ahead, I would like to replace all of EAL args and KVargs processing
> with something more like the python parseargs library. The API is cleaner and
> incorporating the help with arg parsing is a real benefit. Thomas also suggested
> integrating help in the arg parsing.
>
> Something like: https://github.com/cofyc/argparse
The argparse is great, especial it integrate help in the arg parsing, which could help
for parse args.
I will propose a argparse library RFC later, and we could both work on it.
As for this commit, I think it has difference: the KV pair was not separated by spaces,
So for: dpdk-testpmd -a 0000:7d:00.0,a=1,b=2,c=3 --file-prefix=feng
We could parse 'a' has value: 0000:7d:00.0,a=1,b=2,c=3
'file-prefix' has value: feng
by argparse.
and then use kvargs to parse a=1,b=2,c=3.
Thanks
Chengwen
>
> .
>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v5 2/5] net/sfc: use new API to parse kvargs
2023-11-06 12:29 ` fengchengwen
@ 2023-11-07 7:18 ` Andrew Rybchenko
0 siblings, 0 replies; 131+ messages in thread
From: Andrew Rybchenko @ 2023-11-07 7:18 UTC (permalink / raw)
To: fengchengwen, thomas, ferruh.yigit; +Cc: dev, stephen, Vijay Kumar Srivastava
On 11/6/23 15:29, fengchengwen wrote:
> Hi Andrew,
>
> On 2023/11/6 18:28, Andrew Rybchenko wrote:
>> On 11/6/23 10:31, Chengwen Feng wrote:
>>> The sfc_kvargs_process() and sfc_efx_dev_class_get() function could
>>> handle both key=value and only-key, so they should use
>>> rte_kvargs_process_opt() instead of rte_kvargs_process() to parse.
>>>
>>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>>> ---
>>> drivers/common/sfc_efx/sfc_efx.c | 4 ++--
>>> drivers/net/sfc/sfc_kvargs.c | 2 +-
>>> 2 files changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
>>> index 2dc5545760..3ebac909f1 100644
>>> --- a/drivers/common/sfc_efx/sfc_efx.c
>>> +++ b/drivers/common/sfc_efx/sfc_efx.c
>>> @@ -52,8 +52,8 @@ sfc_efx_dev_class_get(struct rte_devargs *devargs)
>>> return dev_class;
>>> if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
>>> - rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
>>> - sfc_efx_kvarg_dev_class_handler, &dev_class);
>>> + rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
>>> + sfc_efx_kvarg_dev_class_handler, &dev_class);
>>
>> LGTM from code point of view, but I'm not sure that I understand the
>> idea behind handling NULL value in sfc_efx_kvarg_dev_class_handler().
>>
>> Cc: Vijay
>>
>>> }
>>> rte_kvargs_free(kvargs);
>>> diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
>>> index 783cb43ae6..24bb896179 100644
>>> --- a/drivers/net/sfc/sfc_kvargs.c
>>> +++ b/drivers/net/sfc/sfc_kvargs.c
>>> @@ -70,7 +70,7 @@ sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
>>> if (sa->kvargs == NULL)
>>> return 0;
>>> - return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
>>> + return -rte_kvargs_process_opt(sa->kvargs, key_match, handler, opaque_arg);
>>
>> It looks wrong to me since many handlers do not handle NULL string gracefully. As I understand some handlers where fixed to avoid crash
>> and correct fix would be to keep rte_kvargs_process() and remove
>> unnecessary checks for NULL string value.
>
> The scope is large, I suggest creates a new patchset later which remove unnecessary checks for NULL string value.
I just want to highlight that it will not make this patch correct. So,
Nack
>
>>
>>> }
>>> int
>>
>> .
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v5 5/5] net/mvneta: fix possible out-of-bounds write
2023-11-06 7:31 ` [PATCH v5 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
@ 2023-11-21 2:11 ` lihuisong (C)
0 siblings, 0 replies; 131+ messages in thread
From: lihuisong (C) @ 2023-11-21 2:11 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, Zyta Szpak, Liron Himi,
Ferruh Yigit, Yelena Krivosheev, Dmitri Epshtein,
Andrzej Ostruszka
Cc: dev, stephen
Acked-by: Huisong Li <lihuisong@huawei.com>
在 2023/11/6 15:31, Chengwen Feng 写道:
> The mvneta_ifnames_get() function will save 'iface' value to ifnames,
> it will out-of-bounds write if passed many iface pairs (e.g.
> 'iface=xxx,iface=xxx,...').
>
> Fixes: 4ccc8d770d3b ("net/mvneta: add PMD skeleton")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
> ---
> drivers/net/mvneta/mvneta_ethdev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
> index daa69e533a..8032a712f4 100644
> --- a/drivers/net/mvneta/mvneta_ethdev.c
> +++ b/drivers/net/mvneta/mvneta_ethdev.c
> @@ -91,6 +91,9 @@ mvneta_ifnames_get(const char *key __rte_unused, const char *value,
> {
> struct mvneta_ifnames *ifnames = extra_args;
>
> + if (ifnames->idx >= NETA_NUM_ETH_PPIO)
> + return -EINVAL;
> +
> ifnames->names[ifnames->idx++] = value;
>
> return 0;
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v5 0/5] fix segment fault when parse args
2023-11-06 7:31 ` [PATCH v5 0/5] fix segment fault when parse args Chengwen Feng
` (4 preceding siblings ...)
2023-11-06 7:31 ` [PATCH v5 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
@ 2024-10-05 1:19 ` Stephen Hemminger
2024-10-09 4:55 ` fengchengwen
5 siblings, 1 reply; 131+ messages in thread
From: Stephen Hemminger @ 2024-10-05 1:19 UTC (permalink / raw)
To: Chengwen Feng; +Cc: thomas, ferruh.yigit, dev
On Mon, 6 Nov 2023 07:31:19 +0000
Chengwen Feng <fengchengwen@huawei.com> wrote:
> The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
> it also supports to parse only-key (e.g. socket_id). But many drivers's
> callback can only handle key-value, it will segment fault if handles
> only-key. so the patchset [1] was introduced.
>
> Because the patchset [1] modified too much drivers, therefore:
> 1) A new API rte_kvargs_process_opt() was introduced, it inherits the
> function of rte_kvargs_process() which could parse both key-value and
> only-key.
> 2) Constraint the rte_kvargs_process() can only parse key-value.
>
> This patchset also include one bugfix for kvargs of mvneta driver.
>
> [1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
>
> Chengwen Feng (5):
> kvargs: add one new process API
> net/sfc: use new API to parse kvargs
> net/tap: use new API to parse kvargs
> common/nfp: use new API to parse kvargs
> net/mvneta: fix possible out-of-bounds write
Not sure why the patchset never got more attention.
Yes it is a real bug, and this looks like a reasonable way to address it.
It does need to be rebased to current 24.11 tree to have a chance,
and would be good to add more documentation to the API and remove
cases in drivers that have unnecessary NULL checks after this.
But those changes can be follow ups.
Also the mvneta patch probably should be sent as separate it does
not depend on anything here.
Bottom line resubmit it, and I will ack the new version.
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v6 0/4] fix segment fault when parse args
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
` (10 preceding siblings ...)
2023-11-06 7:31 ` [PATCH v5 0/5] fix segment fault when parse args Chengwen Feng
@ 2024-10-09 4:50 ` Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 1/4] kvargs: add one new process API Chengwen Feng
` (4 more replies)
11 siblings, 5 replies; 131+ messages in thread
From: Chengwen Feng @ 2024-10-09 4:50 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
it also supports to parse only-key (e.g. socket_id). But many drivers's
callback can only handle key-value, it will segment fault if handles
only-key. so the patchset [1] was introduced.
Because the patchset [1] modified too much drivers, therefore:
1) A new API rte_kvargs_process_opt() was introduced, it inherits the
function of rte_kvargs_process() which could parse both key-value and
only-key.
2) Constraint the rte_kvargs_process() can only parse key-value.
[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
Chengwen Feng (4):
kvargs: add one new process API
net/sfc: use new API to parse kvargs
net/tap: use new API to parse kvargs
common/nfp: use new API to parse kvargs
---
v6: rebase to 24.11, refine net/sfc modification, make mvneta as an
independent commit which address Stephen's comment.
v5: remove redundant of rte_kvargs_count of 4/5 commit which address
Stephen's comment.
v4: refine API's define and impl which address Ferruh's comments.
add common/nfp change commit.
v3: introduce new API instead of modify too many drivers which address
Ferruh's comments.
doc/guides/rel_notes/release_24_11.rst | 13 ++++++++
drivers/common/nfp/nfp_common_pci.c | 6 ++--
drivers/common/sfc_efx/sfc_efx.c | 3 --
drivers/net/sfc/sfc_ethdev.c | 12 +++----
drivers/net/sfc/sfc_kvargs.c | 12 ++++++-
drivers/net/sfc/sfc_kvargs.h | 2 ++
drivers/net/tap/rte_eth_tap.c | 10 +++---
lib/kvargs/rte_kvargs.c | 43 ++++++++++++++++++++------
lib/kvargs/rte_kvargs.h | 39 +++++++++++++++++++++--
lib/kvargs/version.map | 7 +++++
10 files changed, 116 insertions(+), 31 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v6 1/4] kvargs: add one new process API
2024-10-09 4:50 ` [PATCH v6 0/4] " Chengwen Feng
@ 2024-10-09 4:50 ` Chengwen Feng
2024-10-10 2:50 ` Ferruh Yigit
2024-10-09 4:50 ` [PATCH v6 2/4] net/sfc: use new API to parse kvargs Chengwen Feng
` (3 subsequent siblings)
4 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2024-10-09 4:50 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev, stephen
The rte_kvargs_process() was used to handle key=value (e.g.
socket_id=0), it also supports to handle only-key (e.g. socket_id).
But many drivers's callback can only handle key=value, it will segment
fault if handles only-key. so the patchset [1] was introduced.
Because the patchset [1] modified too much drivers, therefore:
1) A new API rte_kvargs_process_opt() was introduced, it inherits the
function of rte_kvargs_process() which could handle both key=value and
only-key cases.
2) Constraint the rte_kvargs_process() can only handle key=value cases,
it will return -1 when handle only-key case (that is the matched key's
value is NULL).
This patch also make sure the rte_kvargs_process_opt() and
rte_kvargs_process() API both return -1 when the kvlist parameter is
NULL.
[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
doc/guides/rel_notes/release_24_11.rst | 13 ++++++++
lib/kvargs/rte_kvargs.c | 43 ++++++++++++++++++++------
lib/kvargs/rte_kvargs.h | 39 +++++++++++++++++++++--
lib/kvargs/version.map | 7 +++++
4 files changed, 90 insertions(+), 12 deletions(-)
diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst
index e0a9aa55a1..873f0639dc 100644
--- a/doc/guides/rel_notes/release_24_11.rst
+++ b/doc/guides/rel_notes/release_24_11.rst
@@ -96,6 +96,19 @@ API Changes
Also, make sure to start the actual text at the margin.
=======================================================
+* **Updated kvargs process API.**
+
+ * Introduced rte_kvargs_process_opt() API, which inherits the function
+ of rte_kvargs_process() and could handle both key=value and only-key
+ cases.
+
+ * Constraint rte_kvargs_process() API can only handle key=value cases,
+ it will return -1 when handle only-key case (that is the matched key's
+ value is NULL).
+
+ * Make sure rte_kvargs_process_opt() and rte_kvargs_process() API both
+ return -1 when the kvlist parameter is NULL.
+
ABI Changes
-----------
diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c
index c77bb82feb..b02f22f5a2 100644
--- a/lib/kvargs/rte_kvargs.c
+++ b/lib/kvargs/rte_kvargs.c
@@ -167,31 +167,56 @@ rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match)
return ret;
}
-/*
- * For each matching key, call the given handler function.
- */
-int
-rte_kvargs_process(const struct rte_kvargs *kvlist,
- const char *key_match,
- arg_handler_t handler,
- void *opaque_arg)
+static int
+kvargs_process_common(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg,
+ bool support_only_key)
{
const struct rte_kvargs_pair *pair;
unsigned i;
if (kvlist == NULL)
- return 0;
+ return -1;
for (i = 0; i < kvlist->count; i++) {
pair = &kvlist->pairs[i];
if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
+ if (!support_only_key && pair->value == NULL)
+ return -1;
if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
return -1;
}
}
+
return 0;
}
+/*
+ * For each matching key in key=value, call the given handler function.
+ */
+int
+rte_kvargs_process(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg)
+{
+ return kvargs_process_common(kvlist, key_match, handler, opaque_arg, false);
+}
+
+/*
+ * For each matching key in key=value or only-key, call the given handler function.
+ */
+int
+rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
+ const char *key_match,
+ arg_handler_t handler,
+ void *opaque_arg)
+{
+ return kvargs_process_common(kvlist, key_match, handler, opaque_arg, true);
+}
+
/* free the rte_kvargs structure */
void
rte_kvargs_free(struct rte_kvargs *kvlist)
diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
index b0d1301c61..b37cd4902f 100644
--- a/lib/kvargs/rte_kvargs.h
+++ b/lib/kvargs/rte_kvargs.h
@@ -6,6 +6,8 @@
#ifndef _RTE_KVARGS_H_
#define _RTE_KVARGS_H_
+#include <rte_compat.h>
+
/**
* @file
* RTE Argument parsing
@@ -166,14 +168,17 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
const char *key, const char *value);
/**
- * Call a handler function for each key/value matching the key
+ * Call a handler function for each key=value matching the key
*
- * For each key/value association that matches the given key, calls the
+ * For each key=value association that matches the given key, calls the
* handler function with the for a given arg_name passing the value on the
* dictionary for that key and a given extra argument.
*
+ * @note Compared to @see rte_kvargs_process_opt, this API will return -1
+ * when handle only-key case (that is the matched key's value is NULL).
+ *
* @param kvlist
- * The rte_kvargs structure. No error if NULL.
+ * The rte_kvargs structure.
* @param key_match
* The key on which the handler should be called, or NULL to process handler
* on all associations
@@ -189,6 +194,34 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
int rte_kvargs_process(const struct rte_kvargs *kvlist,
const char *key_match, arg_handler_t handler, void *opaque_arg);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Call a handler function for each key=value or only-key matching the key
+ *
+ * For each key=value or only-key association that matches the given key, calls
+ * the handler function with the for a given arg_name passing the value on the
+ * dictionary for that key and a given extra argument.
+ *
+ * @param kvlist
+ * The rte_kvargs structure.
+ * @param key_match
+ * The key on which the handler should be called, or NULL to process handler
+ * on all associations
+ * @param handler
+ * The function to call for each matching key
+ * @param opaque_arg
+ * A pointer passed unchanged to the handler
+ *
+ * @return
+ * - 0 on success
+ * - Negative on error
+ */
+__rte_experimental
+int rte_kvargs_process_opt(const struct rte_kvargs *kvlist,
+ const char *key_match, arg_handler_t handler, void *opaque_arg);
+
/**
* Count the number of associations matching the given key
*
diff --git a/lib/kvargs/version.map b/lib/kvargs/version.map
index b50f1a97a1..178f476236 100644
--- a/lib/kvargs/version.map
+++ b/lib/kvargs/version.map
@@ -11,3 +11,10 @@ DPDK_25 {
local: *;
};
+
+EXPERIMENTAL {
+ global:
+
+ # added in 24.11
+ rte_kvargs_process_opt;
+};
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v6 2/4] net/sfc: use new API to parse kvargs
2024-10-09 4:50 ` [PATCH v6 0/4] " Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 1/4] kvargs: add one new process API Chengwen Feng
@ 2024-10-09 4:50 ` Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 3/4] net/tap: " Chengwen Feng
` (2 subsequent siblings)
4 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2024-10-09 4:50 UTC (permalink / raw)
To: thomas, ferruh.yigit, Andrew Rybchenko; +Cc: dev, stephen
Add sfc_kvargs_process_opt() function to handle only-key case, and
remove redundancy NULL judgement of value because the rte_kvargs_process
(which invoked in sfc_kvargs_process()) will handle it.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/common/sfc_efx/sfc_efx.c | 3 ---
drivers/net/sfc/sfc_ethdev.c | 12 ++++++------
drivers/net/sfc/sfc_kvargs.c | 12 +++++++++++-
drivers/net/sfc/sfc_kvargs.h | 2 ++
4 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
index 5eeffb065b..458efacba5 100644
--- a/drivers/common/sfc_efx/sfc_efx.c
+++ b/drivers/common/sfc_efx/sfc_efx.c
@@ -23,9 +23,6 @@ sfc_efx_kvarg_dev_class_handler(__rte_unused const char *key,
{
enum sfc_efx_dev_class *dev_class = opaque;
- if (class_str == NULL)
- return *dev_class;
-
if (strcmp(class_str, "vdpa") == 0) {
*dev_class = SFC_EFX_DEV_CLASS_VDPA;
} else if (strcmp(class_str, "net") == 0) {
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 3480a51642..89444f0b4a 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -2835,8 +2835,8 @@ sfc_eth_dev_set_ops(struct rte_eth_dev *dev)
if (encp->enc_rx_es_super_buffer_supported)
avail_caps |= SFC_DP_HW_FW_CAP_RX_ES_SUPER_BUFFER;
- rc = sfc_kvargs_process(sa, SFC_KVARG_RX_DATAPATH,
- sfc_kvarg_string_handler, &rx_name);
+ rc = sfc_kvargs_process_opt(sa, SFC_KVARG_RX_DATAPATH,
+ sfc_kvarg_string_handler, &rx_name);
if (rc != 0)
goto fail_kvarg_rx_datapath;
@@ -2878,8 +2878,8 @@ sfc_eth_dev_set_ops(struct rte_eth_dev *dev)
sfc_notice(sa, "use %s Rx datapath", sas->dp_rx_name);
- rc = sfc_kvargs_process(sa, SFC_KVARG_TX_DATAPATH,
- sfc_kvarg_string_handler, &tx_name);
+ rc = sfc_kvargs_process_opt(sa, SFC_KVARG_TX_DATAPATH,
+ sfc_kvarg_string_handler, &tx_name);
if (rc != 0)
goto fail_kvarg_tx_datapath;
@@ -3073,8 +3073,8 @@ sfc_parse_switch_mode(struct sfc_adapter *sa, bool has_representors)
sfc_log_init(sa, "entry");
- rc = sfc_kvargs_process(sa, SFC_KVARG_SWITCH_MODE,
- sfc_kvarg_string_handler, &switch_mode);
+ rc = sfc_kvargs_process_opt(sa, SFC_KVARG_SWITCH_MODE,
+ sfc_kvarg_string_handler, &switch_mode);
if (rc != 0)
goto fail_kvargs;
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 783cb43ae6..eb36fa98ca 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -73,6 +73,16 @@ sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
}
+int
+sfc_kvargs_process_opt(struct sfc_adapter *sa, const char *key_match,
+ arg_handler_t handler, void *opaque_arg)
+{
+ if (sa->kvargs == NULL)
+ return 0;
+
+ return -rte_kvargs_process_opt(sa->kvargs, key_match, handler, opaque_arg);
+}
+
int
sfc_kvarg_bool_handler(__rte_unused const char *key,
const char *value_str, void *opaque)
@@ -104,7 +114,7 @@ sfc_kvarg_long_handler(__rte_unused const char *key,
long value;
char *endptr;
- if (!value_str || !opaque)
+ if (!opaque)
return -EINVAL;
value = strtol(value_str, &endptr, 0);
diff --git a/drivers/net/sfc/sfc_kvargs.h b/drivers/net/sfc/sfc_kvargs.h
index 2226f2b3d9..4dcc61e973 100644
--- a/drivers/net/sfc/sfc_kvargs.h
+++ b/drivers/net/sfc/sfc_kvargs.h
@@ -83,6 +83,8 @@ void sfc_kvargs_cleanup(struct sfc_adapter *sa);
int sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
arg_handler_t handler, void *opaque_arg);
+int sfc_kvargs_process_opt(struct sfc_adapter *sa, const char *key_match,
+ arg_handler_t handler, void *opaque_arg);
int sfc_kvarg_bool_handler(const char *key, const char *value_str,
void *opaque);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v6 3/4] net/tap: use new API to parse kvargs
2024-10-09 4:50 ` [PATCH v6 0/4] " Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 1/4] kvargs: add one new process API Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 2/4] net/sfc: use new API to parse kvargs Chengwen Feng
@ 2024-10-09 4:50 ` Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 4/4] common/nfp: " Chengwen Feng
2024-10-11 14:13 ` [PATCH v6 0/4] fix segment fault when parse args David Marchand
4 siblings, 0 replies; 131+ messages in thread
From: Chengwen Feng @ 2024-10-09 4:50 UTC (permalink / raw)
To: thomas, ferruh.yigit, Stephen Hemminger; +Cc: dev
Some kvargs could be key=value or only-key, it should use
rte_kvargs_process_opt() instead of rte_kvargs_process() to handle
these kvargs.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/tap/rte_eth_tap.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index c5af5751f6..5ad3bbadd1 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2291,7 +2291,7 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
+ ret = rte_kvargs_process_opt(kvlist,
ETH_TAP_IFACE_ARG,
&set_interface_name,
tun_name);
@@ -2487,10 +2487,10 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist) {
if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
- ret = rte_kvargs_process(kvlist,
- ETH_TAP_IFACE_ARG,
- &set_interface_name,
- tap_name);
+ ret = rte_kvargs_process_opt(kvlist,
+ ETH_TAP_IFACE_ARG,
+ &set_interface_name,
+ tap_name);
if (ret == -1)
goto leave;
}
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* [PATCH v6 4/4] common/nfp: use new API to parse kvargs
2024-10-09 4:50 ` [PATCH v6 0/4] " Chengwen Feng
` (2 preceding siblings ...)
2024-10-09 4:50 ` [PATCH v6 3/4] net/tap: " Chengwen Feng
@ 2024-10-09 4:50 ` Chengwen Feng
2024-10-10 3:24 ` Chaoyong He
2024-10-11 14:13 ` [PATCH v6 0/4] fix segment fault when parse args David Marchand
4 siblings, 1 reply; 131+ messages in thread
From: Chengwen Feng @ 2024-10-09 4:50 UTC (permalink / raw)
To: thomas, ferruh.yigit, Chaoyong He; +Cc: dev, stephen
The nfp_parse_class_options() function could handle both key=value and
only-key, so it should use rte_kvargs_process_opt() instead of
rte_kvargs_process() to parse.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/common/nfp/nfp_common_pci.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
index 723035d0f7..5c36052f9d 100644
--- a/drivers/common/nfp/nfp_common_pci.c
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -170,10 +170,8 @@ nfp_parse_class_options(const struct rte_devargs *devargs)
if (kvargs == NULL)
return dev_class;
- if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
- rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
- nfp_kvarg_dev_class_handler, &dev_class);
- }
+ rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
+ nfp_kvarg_dev_class_handler, &dev_class);
rte_kvargs_free(kvargs);
--
2.17.1
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v5 0/5] fix segment fault when parse args
2024-10-05 1:19 ` [PATCH v5 0/5] fix segment fault when parse args Stephen Hemminger
@ 2024-10-09 4:55 ` fengchengwen
0 siblings, 0 replies; 131+ messages in thread
From: fengchengwen @ 2024-10-09 4:55 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: thomas, ferruh.yigit, dev
Hi Stephen,
On 2024/10/5 9:19, Stephen Hemminger wrote:
> On Mon, 6 Nov 2023 07:31:19 +0000
> Chengwen Feng <fengchengwen@huawei.com> wrote:
>
>> The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
>> it also supports to parse only-key (e.g. socket_id). But many drivers's
>> callback can only handle key-value, it will segment fault if handles
>> only-key. so the patchset [1] was introduced.
>>
>> Because the patchset [1] modified too much drivers, therefore:
>> 1) A new API rte_kvargs_process_opt() was introduced, it inherits the
>> function of rte_kvargs_process() which could parse both key-value and
>> only-key.
>> 2) Constraint the rte_kvargs_process() can only parse key-value.
>>
>> This patchset also include one bugfix for kvargs of mvneta driver.
>>
>> [1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
>>
>> Chengwen Feng (5):
>> kvargs: add one new process API
>> net/sfc: use new API to parse kvargs
>> net/tap: use new API to parse kvargs
>> common/nfp: use new API to parse kvargs
>> net/mvneta: fix possible out-of-bounds write
>
> Not sure why the patchset never got more attention.
> Yes it is a real bug, and this looks like a reasonable way to address it.
>
> It does need to be rebased to current 24.11 tree to have a chance,
> and would be good to add more documentation to the API and remove
> cases in drivers that have unnecessary NULL checks after this.
> But those changes can be follow ups.
>
> Also the mvneta patch probably should be sent as separate it does
> not depend on anything here.
Done
>
> Bottom line resubmit it, and I will ack the new version.
Already sent v6, please take a review
Thanks
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v6 1/4] kvargs: add one new process API
2024-10-09 4:50 ` [PATCH v6 1/4] kvargs: add one new process API Chengwen Feng
@ 2024-10-10 2:50 ` Ferruh Yigit
0 siblings, 0 replies; 131+ messages in thread
From: Ferruh Yigit @ 2024-10-10 2:50 UTC (permalink / raw)
To: Chengwen Feng, thomas; +Cc: dev, stephen
On 10/9/2024 5:50 AM, Chengwen Feng wrote:
> The rte_kvargs_process() was used to handle key=value (e.g.
> socket_id=0), it also supports to handle only-key (e.g. socket_id).
> But many drivers's callback can only handle key=value, it will segment
> fault if handles only-key. so the patchset [1] was introduced.
>
> Because the patchset [1] modified too much drivers, therefore:
> 1) A new API rte_kvargs_process_opt() was introduced, it inherits the
> function of rte_kvargs_process() which could handle both key=value and
> only-key cases.
> 2) Constraint the rte_kvargs_process() can only handle key=value cases,
> it will return -1 when handle only-key case (that is the matched key's
> value is NULL).
>
> This patch also make sure the rte_kvargs_process_opt() and
> rte_kvargs_process() API both return -1 when the kvlist parameter is
> NULL.
>
> [1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-
> fengchengwen@huawei.com/
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
^ permalink raw reply [flat|nested] 131+ messages in thread
* RE: [PATCH v6 4/4] common/nfp: use new API to parse kvargs
2024-10-09 4:50 ` [PATCH v6 4/4] common/nfp: " Chengwen Feng
@ 2024-10-10 3:24 ` Chaoyong He
0 siblings, 0 replies; 131+ messages in thread
From: Chaoyong He @ 2024-10-10 3:24 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit; +Cc: dev, stephen
> -----Original Message-----
> From: Chengwen Feng <fengchengwen@huawei.com>
> Sent: Wednesday, October 9, 2024 12:51 PM
> To: thomas@monjalon.net; ferruh.yigit@amd.com; Chaoyong He
> <chaoyong.he@corigine.com>
> Cc: dev@dpdk.org; stephen@networkplumber.org
> Subject: [PATCH v6 4/4] common/nfp: use new API to parse kvargs
>
> The nfp_parse_class_options() function could handle both key=value and
> only-key, so it should use rte_kvargs_process_opt() instead of
> rte_kvargs_process() to parse.
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> drivers/common/nfp/nfp_common_pci.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/common/nfp/nfp_common_pci.c
> b/drivers/common/nfp/nfp_common_pci.c
> index 723035d0f7..5c36052f9d 100644
> --- a/drivers/common/nfp/nfp_common_pci.c
> +++ b/drivers/common/nfp/nfp_common_pci.c
> @@ -170,10 +170,8 @@ nfp_parse_class_options(const struct rte_devargs
> *devargs)
> if (kvargs == NULL)
> return dev_class;
>
> - if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
> - rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
> - nfp_kvarg_dev_class_handler, &dev_class);
> - }
> + rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
> + nfp_kvarg_dev_class_handler, &dev_class);
>
> rte_kvargs_free(kvargs);
>
> --
> 2.17.1
Looks good to me.
Acked-by: Chaoyong He <chaoyong.he@corigine.com>
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v6 0/4] fix segment fault when parse args
2024-10-09 4:50 ` [PATCH v6 0/4] " Chengwen Feng
` (3 preceding siblings ...)
2024-10-09 4:50 ` [PATCH v6 4/4] common/nfp: " Chengwen Feng
@ 2024-10-11 14:13 ` David Marchand
2024-10-12 0:37 ` fengchengwen
4 siblings, 1 reply; 131+ messages in thread
From: David Marchand @ 2024-10-11 14:13 UTC (permalink / raw)
To: Chengwen Feng; +Cc: thomas, ferruh.yigit, dev, stephen
On Wed, Oct 9, 2024 at 6:50 AM Chengwen Feng <fengchengwen@huawei.com> wrote:
>
> The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
> it also supports to parse only-key (e.g. socket_id). But many drivers's
> callback can only handle key-value, it will segment fault if handles
> only-key. so the patchset [1] was introduced.
>
> Because the patchset [1] modified too much drivers, therefore:
> 1) A new API rte_kvargs_process_opt() was introduced, it inherits the
> function of rte_kvargs_process() which could parse both key-value and
> only-key.
> 2) Constraint the rte_kvargs_process() can only parse key-value.
>
> [1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
>
> Chengwen Feng (4):
> kvargs: add one new process API
> net/sfc: use new API to parse kvargs
> net/tap: use new API to parse kvargs
> common/nfp: use new API to parse kvargs
I see Stephen wanted to have a look on the series, but rc1 is close,
and I decided to merge it with following comments.
I marked the new API as stable from the go.
The reason being that it provides the "legacy" behavior of previous
rte_kvargs_process function, and as such, some users may have been
relying on it.
If you think this is wrong, please submit a followup patch.
I was surprised of the change in behavior wrt to a NULL kvlist input
parameter mixed in the change.
But I left it as is. Idem, a followup patch may be sent.
Series applied, thanks for fixing this old issue Chengwen.
--
David Marchand
^ permalink raw reply [flat|nested] 131+ messages in thread
* Re: [PATCH v6 0/4] fix segment fault when parse args
2024-10-11 14:13 ` [PATCH v6 0/4] fix segment fault when parse args David Marchand
@ 2024-10-12 0:37 ` fengchengwen
0 siblings, 0 replies; 131+ messages in thread
From: fengchengwen @ 2024-10-12 0:37 UTC (permalink / raw)
To: David Marchand; +Cc: thomas, ferruh.yigit, dev, stephen
On 2024/10/11 22:13, David Marchand wrote:
> On Wed, Oct 9, 2024 at 6:50 AM Chengwen Feng <fengchengwen@huawei.com> wrote:
>>
>> The rte_kvargs_process() was used to parse key-value (e.g. socket_id=0),
>> it also supports to parse only-key (e.g. socket_id). But many drivers's
>> callback can only handle key-value, it will segment fault if handles
>> only-key. so the patchset [1] was introduced.
>>
>> Because the patchset [1] modified too much drivers, therefore:
>> 1) A new API rte_kvargs_process_opt() was introduced, it inherits the
>> function of rte_kvargs_process() which could parse both key-value and
>> only-key.
>> 2) Constraint the rte_kvargs_process() can only parse key-value.
>>
>> [1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/
>>
>> Chengwen Feng (4):
>> kvargs: add one new process API
>> net/sfc: use new API to parse kvargs
>> net/tap: use new API to parse kvargs
>> common/nfp: use new API to parse kvargs
>
> I see Stephen wanted to have a look on the series, but rc1 is close,
> and I decided to merge it with following comments.
>
> I marked the new API as stable from the go.
> The reason being that it provides the "legacy" behavior of previous
> rte_kvargs_process function, and as such, some users may have been
> relying on it.
> If you think this is wrong, please submit a followup patch.
I just reviewed the merged commit, it's OK.
>
> I was surprised of the change in behavior wrt to a NULL kvlist input
> parameter mixed in the change.
> But I left it as is. Idem, a followup patch may be sent.
>
>
> Series applied, thanks for fixing this old issue Chengwen.
Thanks David
>
^ permalink raw reply [flat|nested] 131+ messages in thread
end of thread, other threads:[~2024-10-12 0:37 UTC | newest]
Thread overview: 131+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 12:48 [PATCH 0/5] fix segment fault when parse args Chengwen Feng
2023-03-14 12:48 ` [PATCH 1/5] app/pdump: " Chengwen Feng
2023-03-16 17:34 ` Ferruh Yigit
2023-03-14 12:48 ` [PATCH 2/5] net/memif: fix segment fault when parse devargs Chengwen Feng
2023-03-16 18:20 ` Ferruh Yigit
2023-03-14 12:48 ` [PATCH 3/5] net/pcap: " Chengwen Feng
2023-03-16 18:20 ` Ferruh Yigit
2023-03-14 12:48 ` [PATCH 4/5] net/ring: " Chengwen Feng
2023-03-14 12:48 ` [PATCH 5/5] net/sfc: " Chengwen Feng
2023-03-16 18:20 ` Ferruh Yigit
2023-03-16 18:18 ` [PATCH 0/5] fix segment fault when parse args Ferruh Yigit
2023-03-17 2:43 ` fengchengwen
2023-03-21 13:50 ` Ferruh Yigit
2023-03-22 1:15 ` fengchengwen
2023-03-22 8:53 ` Ferruh Yigit
2023-03-22 13:49 ` Thomas Monjalon
2023-03-23 11:58 ` fengchengwen
2023-03-23 12:51 ` Thomas Monjalon
2023-03-20 9:20 ` [PATCH v2 00/44] " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 01/44] app/pdump: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 02/44] ethdev: " Chengwen Feng
2023-04-09 8:10 ` Andrew Rybchenko
2023-03-20 9:20 ` [PATCH v2 03/44] net/memif: fix segment fault when parse devargs Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 04/44] net/pcap: " Chengwen Feng
2023-07-04 3:04 ` Stephen Hemminger
2023-03-20 9:20 ` [PATCH v2 05/44] net/ring: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 06/44] net/sfc: " Chengwen Feng
2023-04-09 8:09 ` Andrew Rybchenko
2023-03-20 9:20 ` [PATCH v2 07/44] net/af_xdp: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 08/44] net/ark: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 09/44] net/cnxk: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 10/44] net/cxgbe: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 11/44] net/dpaa2: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 12/44] net/ena: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 13/44] net/enic: " Chengwen Feng
2023-03-20 21:37 ` John Daley (johndale)
2023-03-20 9:20 ` [PATCH v2 14/44] net/fm10k: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 15/44] net/i40e: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 16/44] net/iavf: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 17/44] net/ice: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 18/44] net/idpf: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 19/44] net/ionic: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 20/44] net/mana: " Chengwen Feng
2023-03-21 22:19 ` Long Li
2023-03-20 9:20 ` [PATCH v2 21/44] net/mlx4: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 22/44] net/mvneta: " Chengwen Feng
2023-03-20 9:33 ` [EXT] " Liron Himi
2023-03-20 9:20 ` [PATCH v2 23/44] net/mvpp2: " Chengwen Feng
2023-03-20 9:33 ` [EXT] " Liron Himi
2023-03-20 9:20 ` [PATCH v2 24/44] net/netvsc: " Chengwen Feng
2023-03-21 22:20 ` Long Li
2023-07-04 3:02 ` Stephen Hemminger
2023-03-20 9:20 ` [PATCH v2 25/44] net/octeontx: " Chengwen Feng
2023-04-12 7:54 ` [EXT] " Harman Kalra
2023-03-20 9:20 ` [PATCH v2 26/44] net/pfe: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 27/44] net/qede: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 28/44] baseband/la12xx: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 29/44] bus/pci: fix segment fault when parse args Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 30/44] common/mlx5: fix segment fault when parse devargs Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 31/44] crypto/cnxk: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 32/44] crypto/dpaa_sec: " Chengwen Feng
2023-03-20 9:20 ` [PATCH v2 33/44] crypto/dpaa2_sec: " Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 34/44] crypto/mvsam: " Chengwen Feng
2023-03-20 9:33 ` [EXT] " Liron Himi
2023-03-20 9:21 ` [PATCH v2 35/44] crypto/scheduler: " Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 36/44] dma/dpaa2: " Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 37/44] event/cnxk: " Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 38/44] event/dlb2: " Chengwen Feng
2023-03-24 16:26 ` Sevincer, Abdullah
2023-03-20 9:21 ` [PATCH v2 39/44] event/dpaa: " Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 40/44] event/octeontx: " Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 41/44] event/opdl: " Chengwen Feng
2023-03-23 13:48 ` Liang Ma
2023-03-20 9:21 ` [PATCH v2 42/44] event/sw: " Chengwen Feng
2023-03-20 11:58 ` Van Haaren, Harry
2023-03-20 9:21 ` [PATCH v2 43/44] mempool/cnxk: " Chengwen Feng
2023-03-20 9:21 ` [PATCH v2 44/44] raw/cnxk_gpio: " Chengwen Feng
2023-04-15 1:38 ` [PATCH v2 00/44] fix segment fault when parse args fengchengwen
2023-04-17 16:37 ` Ferruh Yigit
2023-10-31 20:46 ` Stephen Hemminger
2023-10-31 20:58 ` [RFC] kvargs: don't pass parse handler a NULL pointer Stephen Hemminger
2023-11-01 1:16 ` fengchengwen
2023-11-03 7:38 ` [PATCH v3 0/5] fix segment fault when parse args Chengwen Feng
2023-11-03 7:38 ` [PATCH v3 1/5] kvargs: add one new process API Chengwen Feng
2023-11-03 13:09 ` Ferruh Yigit
2023-11-05 5:55 ` fengchengwen
2023-11-03 7:38 ` [PATCH v3 2/5] net/af_packet: use new API to parse kvargs Chengwen Feng
2023-11-03 13:11 ` Ferruh Yigit
2023-11-05 5:56 ` fengchengwen
2023-11-03 7:38 ` [PATCH v3 3/5] net/sfc: " Chengwen Feng
2023-11-03 13:23 ` Ferruh Yigit
2023-11-03 7:38 ` [PATCH v3 4/5] net/tap: " Chengwen Feng
2023-11-03 13:34 ` Ferruh Yigit
2023-11-05 5:57 ` fengchengwen
2023-11-03 7:38 ` [PATCH v3 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
2023-11-03 13:39 ` Ferruh Yigit
2023-11-03 13:41 ` [PATCH v3 0/5] fix segment fault when parse args Ferruh Yigit
2023-11-05 5:50 ` fengchengwen
2023-11-05 5:45 ` [PATCH v4 " Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 1/5] kvargs: add one new process API Chengwen Feng
2023-11-06 3:18 ` Stephen Hemminger
2023-11-06 7:13 ` fengchengwen
2023-11-06 16:19 ` Stephen Hemminger
2023-11-07 3:21 ` fengchengwen
2023-11-05 5:45 ` [PATCH v4 2/5] net/sfc: use new API to parse kvargs Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 3/5] net/tap: " Chengwen Feng
2023-11-05 5:45 ` [PATCH v4 4/5] common/nfp: " Chengwen Feng
2023-11-06 3:19 ` Stephen Hemminger
2023-11-06 7:22 ` fengchengwen
2023-11-05 5:45 ` [PATCH v4 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 0/5] fix segment fault when parse args Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 1/5] kvargs: add one new process API Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 2/5] net/sfc: use new API to parse kvargs Chengwen Feng
2023-11-06 10:28 ` Andrew Rybchenko
2023-11-06 12:29 ` fengchengwen
2023-11-07 7:18 ` Andrew Rybchenko
2023-11-06 7:31 ` [PATCH v5 3/5] net/tap: " Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 4/5] common/nfp: " Chengwen Feng
2023-11-06 7:31 ` [PATCH v5 5/5] net/mvneta: fix possible out-of-bounds write Chengwen Feng
2023-11-21 2:11 ` lihuisong (C)
2024-10-05 1:19 ` [PATCH v5 0/5] fix segment fault when parse args Stephen Hemminger
2024-10-09 4:55 ` fengchengwen
2024-10-09 4:50 ` [PATCH v6 0/4] " Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 1/4] kvargs: add one new process API Chengwen Feng
2024-10-10 2:50 ` Ferruh Yigit
2024-10-09 4:50 ` [PATCH v6 2/4] net/sfc: use new API to parse kvargs Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 3/4] net/tap: " Chengwen Feng
2024-10-09 4:50 ` [PATCH v6 4/4] common/nfp: " Chengwen Feng
2024-10-10 3:24 ` Chaoyong He
2024-10-11 14:13 ` [PATCH v6 0/4] fix segment fault when parse args David Marchand
2024-10-12 0:37 ` fengchengwen
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).