DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/failsafe: Fix crash due to global devargs syntax parsing from secondary process
@ 2022-02-10  7:10 madhuker.mythri
  2022-02-10 15:00 ` Ferruh Yigit
  2022-02-10 17:01 ` [PATCH] devargs: Fix rte_devargs_parse uninitialized calls Gaetan Rivet
  0 siblings, 2 replies; 13+ messages in thread
From: madhuker.mythri @ 2022-02-10  7:10 UTC (permalink / raw)
  To: grive; +Cc: dev, Madhuker Mythri

From: Madhuker Mythri <madhuker.mythri@oracle.com>

Failsafe pmd started crashing with global devargs syntax as devargs is
not memset to zero. Access it to in rte_devargs_parse resulted in a
crash when called from secondary process.

Bugzilla Id: 933

Signed-off-by: Madhuker Mythri <madhuker.mythri@oracle.com>
---
 drivers/net/failsafe/failsafe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index 3c754a5f66..aa93cc6000 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -360,6 +360,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
 			if (sdev->devargs.name[0] == '\0')
 				continue;
 
+			memset(&devargs, 0, sizeof(devargs));
 			/* rebuild devargs to be able to get the bus name. */
 			ret = rte_devargs_parse(&devargs,
 						sdev->devargs.name);
-- 
2.32.0.windows.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* (no subject)
  2022-02-10  7:10 [PATCH] net/failsafe: Fix crash due to global devargs syntax parsing from secondary process madhuker.mythri
@ 2022-02-10 15:00 ` Ferruh Yigit
  2022-02-10 16:08   ` Gaëtan Rivet
  2022-02-10 17:01 ` [PATCH] devargs: Fix rte_devargs_parse uninitialized calls Gaetan Rivet
  1 sibling, 1 reply; 13+ messages in thread
From: Ferruh Yigit @ 2022-02-10 15:00 UTC (permalink / raw)
  To: madhuker.mythri, grive; +Cc: dev

On 2/10/2022 7:10 AM, madhuker.mythri@oracle.com wrote:
> From: Madhuker Mythri <madhuker.mythri@oracle.com>
> 
> Failsafe pmd started crashing with global devargs syntax as devargs is
> not memset to zero. Access it to in rte_devargs_parse resulted in a
> crash when called from secondary process.
> 
> Bugzilla Id: 933
> 
> Signed-off-by: Madhuker Mythri <madhuker.mythri@oracle.com>
> ---
>   drivers/net/failsafe/failsafe.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
> index 3c754a5f66..aa93cc6000 100644
> --- a/drivers/net/failsafe/failsafe.c
> +++ b/drivers/net/failsafe/failsafe.c
> @@ -360,6 +360,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
>   			if (sdev->devargs.name[0] == '\0')
>   				continue;
>   
> +			memset(&devargs, 0, sizeof(devargs));
>   			/* rebuild devargs to be able to get the bus name. */
>   			ret = rte_devargs_parse(&devargs,
>   						sdev->devargs.name);

if 'rte_devargs_parse()' requires 'devargs' parameter to be memset,
what do you think memset it in the API?
This prevents forgotten cases like this.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re:
  2022-02-10 15:00 ` Ferruh Yigit
@ 2022-02-10 16:08   ` Gaëtan Rivet
  2022-02-11  9:37     ` [External] : Re: Madhuker Mythri
  0 siblings, 1 reply; 13+ messages in thread
From: Gaëtan Rivet @ 2022-02-10 16:08 UTC (permalink / raw)
  To: Ferruh Yigit, madhuker.mythri; +Cc: dev

On Thu, Feb 10, 2022, at 16:00, Ferruh Yigit wrote:
> On 2/10/2022 7:10 AM, madhuker.mythri@oracle.com wrote:
>> From: Madhuker Mythri <madhuker.mythri@oracle.com>
>> 
>> Failsafe pmd started crashing with global devargs syntax as devargs is
>> not memset to zero. Access it to in rte_devargs_parse resulted in a
>> crash when called from secondary process.
>> 
>> Bugzilla Id: 933
>> 
>> Signed-off-by: Madhuker Mythri <madhuker.mythri@oracle.com>
>> ---
>>   drivers/net/failsafe/failsafe.c | 1 +
>>   1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
>> index 3c754a5f66..aa93cc6000 100644
>> --- a/drivers/net/failsafe/failsafe.c
>> +++ b/drivers/net/failsafe/failsafe.c
>> @@ -360,6 +360,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
>>   			if (sdev->devargs.name[0] == '\0')
>>   				continue;
>>   
>> +			memset(&devargs, 0, sizeof(devargs));
>>   			/* rebuild devargs to be able to get the bus name. */
>>   			ret = rte_devargs_parse(&devargs,
>>   						sdev->devargs.name);
>
> if 'rte_devargs_parse()' requires 'devargs' parameter to be memset,
> what do you think memset it in the API?
> This prevents forgotten cases like this.

Hi,

I was looking at it this morning.
Before the last release, rte_devargs_parse() was only supporting legacy syntax.
It never read from the devargs structure, only wrote to it. So it was safe to
use with a non-memset devargs.

The rte_devargs_layer_parse() however is more complex. To allow rte_dev_iterator_init() to call it without doing memory allocation, it reads parts of the devargs to make decisions.

Doing a first call to rte_devargs_layer_parse() as part of rte_devargs_parse() thus
modified the contract it had with the users, that it would never read from devargs.

It is not possible to completely avoid reading from devargs in rte_devargs_layer_parse().
It is necessary for RTE_DEV_FOREACH() to be safe to interrupt without having to do iterator cleanup.

This is my current understanding. In that context, yes I think it is preferrable to
do memset() within rte_devargs_parse(). It will restore the previous part of the API saying that calling it with non-memset devargs was safe to do.

Thanks,
-- 
Gaetan Rivet

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH] devargs: Fix rte_devargs_parse uninitialized calls
  2022-02-10  7:10 [PATCH] net/failsafe: Fix crash due to global devargs syntax parsing from secondary process madhuker.mythri
  2022-02-10 15:00 ` Ferruh Yigit
@ 2022-02-10 17:01 ` Gaetan Rivet
  2022-02-15 12:51   ` Ferruh Yigit
  2022-02-15 15:27   ` David Marchand
  1 sibling, 2 replies; 13+ messages in thread
From: Gaetan Rivet @ 2022-02-10 17:01 UTC (permalink / raw)
  To: dev; +Cc: madhuker.mythri, ferruh.yigit

The function rte_devargs_parse() previously was safe to call with
non-initialized devargs structure as parameter.

When adding the support for the global device syntax,
this assumption was broken. Restore it by forcing memset as part of
the call itself.

Bugzilla Id: 933
Fixes: b344eb5d941a ("devargs: parse global device syntax")
Signed-off-by: Gaetan Rivet <grive@u256.net>
---
 lib/eal/common/eal_common_devargs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c
index 8c7650cf6c..184fe676aa 100644
--- a/lib/eal/common/eal_common_devargs.c
+++ b/lib/eal/common/eal_common_devargs.c
@@ -191,6 +191,7 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev)
 
 	if (da == NULL)
 		return -EINVAL;
+	memset(da, 0, sizeof(*da));
 
 	/* First parse according global device syntax. */
 	if (rte_devargs_layers_parse(da, dev) == 0) {
-- 
2.31.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [External] : Re:
  2022-02-10 16:08   ` Gaëtan Rivet
@ 2022-02-11  9:37     ` Madhuker Mythri
  2022-02-11  9:58       ` [External] : Re: [PATCH] net/failsafe: Fix crash due to global devargs syntax parsing from secondary process Ferruh Yigit
  2022-02-11  9:58       ` [External] : Gaëtan Rivet
  0 siblings, 2 replies; 13+ messages in thread
From: Madhuker Mythri @ 2022-02-11  9:37 UTC (permalink / raw)
  To: Gaëtan Rivet, Ferruh Yigit; +Cc: dev

Hi Gaetan and  Ferruh,

>
>-----Original Message-----
>From: Gaëtan Rivet <grive@u256.net> 
>Sent: 10 फरवरी 2022 21:39
>To: Ferruh Yigit <ferruh.yigit@intel.com>; Madhuker Mythri <madhuker.mythri@oracle.com>
>Cc: dev@dpdk.org
>Subject: [External] : Re: 
>
>On Thu, Feb 10, 2022, at 16:00, Ferruh Yigit wrote:
>> On 2/10/2022 7:10 AM, madhuker.mythri@oracle.com wrote:
>>> From: Madhuker Mythri <madhuker.mythri@oracle.com>
>>> 
>>> Failsafe pmd started crashing with global devargs syntax as devargs 
>>> is not memset to zero. Access it to in rte_devargs_parse resulted in 
>>> a crash when called from secondary process.
>>> 
>>> Bugzilla Id: 933
>>> 
>>> Signed-off-by: Madhuker Mythri <madhuker.mythri@oracle.com>
>>> ---
>>>   drivers/net/failsafe/failsafe.c | 1 +
>>>   1 file changed, 1 insertion(+)
>>> 
>>> diff --git a/drivers/net/failsafe/failsafe.c 
>>> b/drivers/net/failsafe/failsafe.c index 3c754a5f66..aa93cc6000 100644
>>> --- a/drivers/net/failsafe/failsafe.c
>>> +++ b/drivers/net/failsafe/failsafe.c
>>> @@ -360,6 +360,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
>>>   			if (sdev->devargs.name[0] == '\0')
>>>   				continue;
>>>   
>>> +			memset(&devargs, 0, sizeof(devargs));
>>>   			/* rebuild devargs to be able to get the bus name. */
>>>   			ret = rte_devargs_parse(&devargs,
>>>   						sdev->devargs.name);
>>
>> if 'rte_devargs_parse()' requires 'devargs' parameter to be memset, 
>> what do you think memset it in the API?
>> This prevents forgotten cases like this.
>
>Hi,
>
>I was looking at it this morning.
>Before the last release, rte_devargs_parse() was only supporting legacy syntax.
>It never read from the devargs structure, only wrote to it. So it was safe to use with a non-memset devargs.
>
>The rte_devargs_layer_parse() however is more complex. To allow rte_dev_iterator_init() to call it without doing memory allocation, it reads parts of the devargs to make decisions.
>
>Doing a first call to rte_devargs_layer_parse() as part of rte_devargs_parse() thus modified the contract it had with the users, that it would never read from devargs.
>
>It is not possible to completely avoid reading from devargs in rte_devargs_layer_parse().
>It is necessary for RTE_DEV_FOREACH() to be safe to interrupt without having to do iterator cleanup.
>
>This is my current understanding. In that context, yes I think it is preferrable to do memset() within rte_devargs_parse(). It will restore the previous part of the API saying that calling it with non-memset >devargs was safe to do.
>
>Thanks,
>--
>Gaetan Rivet

Thanks for your comments.
The rte_devargs_parse() is used in other 'netvsc' PMD also in netvsc_hotadd_callback().
In this netvsc_hotadd_callback(), it was assigning the devargs with some other instance pointer(not sure, whether its just a pointer or with data values) before calling this rte_devargs_parse(), so if we memset inside this API, then the devargs data values will be nullified right.
I'm not fully familiar with this parsing functionality. So, please let me know, doing memset() inside this rte_devargs_parse() is valid or not, as this is a generic function for all the PMD's.

Thanks,
Madhuker.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [External] : Re: [PATCH] net/failsafe: Fix crash due to global devargs syntax parsing from secondary process
  2022-02-11  9:37     ` [External] : Re: Madhuker Mythri
@ 2022-02-11  9:58       ` Ferruh Yigit
  2022-02-11  9:58       ` [External] : Gaëtan Rivet
  1 sibling, 0 replies; 13+ messages in thread
From: Ferruh Yigit @ 2022-02-11  9:58 UTC (permalink / raw)
  To: Madhuker Mythri, Gaëtan Rivet; +Cc: dev

On 2/11/2022 9:37 AM, Madhuker Mythri wrote:
> Hi Gaetan and  Ferruh,
> 
>>
>> -----Original Message-----
>> From: Gaëtan Rivet <grive@u256.net>
>> Sent: 10 फरवरी 2022 21:39
>> To: Ferruh Yigit <ferruh.yigit@intel.com>; Madhuker Mythri <madhuker.mythri@oracle.com>
>> Cc: dev@dpdk.org
>> Subject: [External] : Re:
>>
>> On Thu, Feb 10, 2022, at 16:00, Ferruh Yigit wrote:
>>> On 2/10/2022 7:10 AM, madhuker.mythri@oracle.com wrote:
>>>> From: Madhuker Mythri <madhuker.mythri@oracle.com>
>>>>
>>>> Failsafe pmd started crashing with global devargs syntax as devargs
>>>> is not memset to zero. Access it to in rte_devargs_parse resulted in
>>>> a crash when called from secondary process.
>>>>
>>>> Bugzilla Id: 933
>>>>
>>>> Signed-off-by: Madhuker Mythri <madhuker.mythri@oracle.com>
>>>> ---
>>>>    drivers/net/failsafe/failsafe.c | 1 +
>>>>    1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/drivers/net/failsafe/failsafe.c
>>>> b/drivers/net/failsafe/failsafe.c index 3c754a5f66..aa93cc6000 100644
>>>> --- a/drivers/net/failsafe/failsafe.c
>>>> +++ b/drivers/net/failsafe/failsafe.c
>>>> @@ -360,6 +360,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
>>>>    			if (sdev->devargs.name[0] == '\0')
>>>>    				continue;
>>>>    
>>>> +			memset(&devargs, 0, sizeof(devargs));
>>>>    			/* rebuild devargs to be able to get the bus name. */
>>>>    			ret = rte_devargs_parse(&devargs,
>>>>    						sdev->devargs.name);
>>>
>>> if 'rte_devargs_parse()' requires 'devargs' parameter to be memset,
>>> what do you think memset it in the API?
>>> This prevents forgotten cases like this.
>>
>> Hi,
>>
>> I was looking at it this morning.
>> Before the last release, rte_devargs_parse() was only supporting legacy syntax.
>> It never read from the devargs structure, only wrote to it. So it was safe to use with a non-memset devargs.
>>
>> The rte_devargs_layer_parse() however is more complex. To allow rte_dev_iterator_init() to call it without doing memory allocation, it reads parts of the devargs to make decisions.
>>
>> Doing a first call to rte_devargs_layer_parse() as part of rte_devargs_parse() thus modified the contract it had with the users, that it would never read from devargs.
>>
>> It is not possible to completely avoid reading from devargs in rte_devargs_layer_parse().
>> It is necessary for RTE_DEV_FOREACH() to be safe to interrupt without having to do iterator cleanup.
>>
>> This is my current understanding. In that context, yes I think it is preferrable to do memset() within rte_devargs_parse(). It will restore the previous part of the API saying that calling it with non-memset >devargs was safe to do.
>>
>> Thanks,
>> --
>> Gaetan Rivet
> 
> Thanks for your comments.
> The rte_devargs_parse() is used in other 'netvsc' PMD also in netvsc_hotadd_callback().
> In this netvsc_hotadd_callback(), it was assigning the devargs with some other instance pointer(not sure, whether its just a pointer or with data values) before calling this rte_devargs_parse(), so if we memset inside this API, then the devargs data values will be nullified right.
> I'm not fully familiar with this parsing functionality. So, please let me know, doing memset() inside this rte_devargs_parse() is valid or not, as this is a generic function for all the PMD's.
> 

Hi Madhuker,

Gaetan already sent a patch for it:
https://patches.dpdk.org/project/dpdk/patch/20220210170131.2199922-1-grive@u256.net/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [External] : Re:
  2022-02-11  9:37     ` [External] : Re: Madhuker Mythri
  2022-02-11  9:58       ` [External] : Re: [PATCH] net/failsafe: Fix crash due to global devargs syntax parsing from secondary process Ferruh Yigit
@ 2022-02-11  9:58       ` Gaëtan Rivet
  2022-02-16  8:27         ` Long Li
  1 sibling, 1 reply; 13+ messages in thread
From: Gaëtan Rivet @ 2022-02-11  9:58 UTC (permalink / raw)
  To: madhuker.mythri, Ferruh Yigit, Stephen Hemminger, Long Li; +Cc: dev

On Fri, Feb 11, 2022, at 10:37, Madhuker Mythri wrote:
> Hi Gaetan and  Ferruh,
>
>>
>>-----Original Message-----
>>From: Gaëtan Rivet <grive@u256.net> 
>>Sent: 10 फरवरी 2022 21:39
>>To: Ferruh Yigit <ferruh.yigit@intel.com>; Madhuker Mythri <madhuker.mythri@oracle.com>
>>Cc: dev@dpdk.org
>>Subject: [External] : Re: 
>>
>>On Thu, Feb 10, 2022, at 16:00, Ferruh Yigit wrote:
>>> On 2/10/2022 7:10 AM, madhuker.mythri@oracle.com wrote:
>>>> From: Madhuker Mythri <madhuker.mythri@oracle.com>
>>>> 
>>>> Failsafe pmd started crashing with global devargs syntax as devargs 
>>>> is not memset to zero. Access it to in rte_devargs_parse resulted in 
>>>> a crash when called from secondary process.
>>>> 
>>>> Bugzilla Id: 933
>>>> 
>>>> Signed-off-by: Madhuker Mythri <madhuker.mythri@oracle.com>
>>>> ---
>>>>   drivers/net/failsafe/failsafe.c | 1 +
>>>>   1 file changed, 1 insertion(+)
>>>> 
>>>> diff --git a/drivers/net/failsafe/failsafe.c 
>>>> b/drivers/net/failsafe/failsafe.c index 3c754a5f66..aa93cc6000 100644
>>>> --- a/drivers/net/failsafe/failsafe.c
>>>> +++ b/drivers/net/failsafe/failsafe.c
>>>> @@ -360,6 +360,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
>>>>   			if (sdev->devargs.name[0] == '\0')
>>>>   				continue;
>>>>   
>>>> +			memset(&devargs, 0, sizeof(devargs));
>>>>   			/* rebuild devargs to be able to get the bus name. */
>>>>   			ret = rte_devargs_parse(&devargs,
>>>>   						sdev->devargs.name);
>>>
>>> if 'rte_devargs_parse()' requires 'devargs' parameter to be memset, 
>>> what do you think memset it in the API?
>>> This prevents forgotten cases like this.
>>
>>Hi,
>>
>>I was looking at it this morning.
>>Before the last release, rte_devargs_parse() was only supporting legacy syntax.
>>It never read from the devargs structure, only wrote to it. So it was safe to use with a non-memset devargs.
>>
>>The rte_devargs_layer_parse() however is more complex. To allow rte_dev_iterator_init() to call it without doing memory allocation, it reads parts of the devargs to make decisions.
>>
>>Doing a first call to rte_devargs_layer_parse() as part of rte_devargs_parse() thus modified the contract it had with the users, that it would never read from devargs.
>>
>>It is not possible to completely avoid reading from devargs in rte_devargs_layer_parse().
>>It is necessary for RTE_DEV_FOREACH() to be safe to interrupt without having to do iterator cleanup.
>>
>>This is my current understanding. In that context, yes I think it is preferrable to do memset() within rte_devargs_parse(). It will restore the previous part of the API saying that calling it with non-memset >devargs was safe to do.
>>
>>Thanks,
>>--
>>Gaetan Rivet
>
> Thanks for your comments.
> The rte_devargs_parse() is used in other 'netvsc' PMD also in 
> netvsc_hotadd_callback().
> In this netvsc_hotadd_callback(), it was assigning the devargs with 
> some other instance pointer(not sure, whether its just a pointer or 
> with data values) before calling this rte_devargs_parse(), so if we 
> memset inside this API, then the devargs data values will be nullified 
> right.
> I'm not fully familiar with this parsing functionality. So, please let 
> me know, doing memset() inside this rte_devargs_parse() is valid or 
> not, as this is a generic function for all the PMD's.
>
> Thanks,
> Madhuker.

Hi Madhuker,

I have just checked the code, it does not seem that netvsc relies on values
being kept in the devargs structure across calls, so it seems that it would be
safe. It would be better to check with the maintainers however, I'm adding them to
this thread.

-- 
Gaetan Rivet

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] devargs: Fix rte_devargs_parse uninitialized calls
  2022-02-10 17:01 ` [PATCH] devargs: Fix rte_devargs_parse uninitialized calls Gaetan Rivet
@ 2022-02-15 12:51   ` Ferruh Yigit
  2022-02-15 13:45     ` Gaëtan Rivet
  2022-02-15 15:27   ` David Marchand
  1 sibling, 1 reply; 13+ messages in thread
From: Ferruh Yigit @ 2022-02-15 12:51 UTC (permalink / raw)
  To: Gaetan Rivet, dev; +Cc: madhuker.mythri

On 2/10/2022 5:01 PM, Gaetan Rivet wrote:
> The function rte_devargs_parse() previously was safe to call with
> non-initialized devargs structure as parameter.
> 
> When adding the support for the global device syntax,
> this assumption was broken. Restore it by forcing memset as part of
> the call itself.
> 
> Bugzilla Id: 933
> Fixes: b344eb5d941a ("devargs: parse global device syntax")
> Signed-off-by: Gaetan Rivet <grive@u256.net>

Reported-by: Madhuker Mythri <madhuker.mythri@oracle.com>

Since Madhuker did the initial analysis and the patch
I think fair to give credit for the work.

Thanks,
ferruh

> ---
>   lib/eal/common/eal_common_devargs.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c
> index 8c7650cf6c..184fe676aa 100644
> --- a/lib/eal/common/eal_common_devargs.c
> +++ b/lib/eal/common/eal_common_devargs.c
> @@ -191,6 +191,7 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev)
>   
>   	if (da == NULL)
>   		return -EINVAL;
> +	memset(da, 0, sizeof(*da));
>   
>   	/* First parse according global device syntax. */
>   	if (rte_devargs_layers_parse(da, dev) == 0) {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] devargs: Fix rte_devargs_parse uninitialized calls
  2022-02-15 12:51   ` Ferruh Yigit
@ 2022-02-15 13:45     ` Gaëtan Rivet
  0 siblings, 0 replies; 13+ messages in thread
From: Gaëtan Rivet @ 2022-02-15 13:45 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: madhuker.mythri

On Tue, Feb 15, 2022, at 13:51, Ferruh Yigit wrote:
> On 2/10/2022 5:01 PM, Gaetan Rivet wrote:
>> The function rte_devargs_parse() previously was safe to call with
>> non-initialized devargs structure as parameter.
>> 
>> When adding the support for the global device syntax,
>> this assumption was broken. Restore it by forcing memset as part of
>> the call itself.
>> 
>> Bugzilla Id: 933
>> Fixes: b344eb5d941a ("devargs: parse global device syntax")
>> Signed-off-by: Gaetan Rivet <grive@u256.net>
>
> Reported-by: Madhuker Mythri <madhuker.mythri@oracle.com>
>
> Since Madhuker did the initial analysis and the patch
> I think fair to give credit for the work.
>
> Thanks,
> ferruh
>

Sure, thanks Ferruh. Whichever patch is fine by me.

-- 
Gaetan Rivet

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] devargs: Fix rte_devargs_parse uninitialized calls
  2022-02-10 17:01 ` [PATCH] devargs: Fix rte_devargs_parse uninitialized calls Gaetan Rivet
  2022-02-15 12:51   ` Ferruh Yigit
@ 2022-02-15 15:27   ` David Marchand
  2022-02-16 17:12     ` Gaëtan Rivet
  1 sibling, 1 reply; 13+ messages in thread
From: David Marchand @ 2022-02-15 15:27 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev, madhuker.mythri, Yigit, Ferruh

On Thu, Feb 10, 2022 at 6:01 PM Gaetan Rivet <grive@u256.net> wrote:
>
> The function rte_devargs_parse() previously was safe to call with
> non-initialized devargs structure as parameter.
>
> When adding the support for the global device syntax,
> this assumption was broken. Restore it by forcing memset as part of
> the call itself.
>
> Bugzilla Id: 933

Nit: Bugzilla ID*

> Fixes: b344eb5d941a ("devargs: parse global device syntax")

We need a backport in 21.11, right?


> Signed-off-by: Gaetan Rivet <grive@u256.net>
> ---
>  lib/eal/common/eal_common_devargs.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c
> index 8c7650cf6c..184fe676aa 100644
> --- a/lib/eal/common/eal_common_devargs.c
> +++ b/lib/eal/common/eal_common_devargs.c
> @@ -191,6 +191,7 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev)
>
>         if (da == NULL)
>                 return -EINVAL;
> +       memset(da, 0, sizeof(*da));
>
>         /* First parse according global device syntax. */
>         if (rte_devargs_layers_parse(da, dev) == 0) {
> --
> 2.31.1
>

Otherwise lgtm.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [External] : Re:
  2022-02-11  9:58       ` [External] : Gaëtan Rivet
@ 2022-02-16  8:27         ` Long Li
  0 siblings, 0 replies; 13+ messages in thread
From: Long Li @ 2022-02-16  8:27 UTC (permalink / raw)
  To: Gaëtan Rivet, madhuker.mythri, Ferruh Yigit, Stephen Hemminger; +Cc: dev

> Subject: Re: [External] : Re:
> 
> On Fri, Feb 11, 2022, at 10:37, Madhuker Mythri wrote:
> > Hi Gaetan and  Ferruh,
> >
> >>
> >>-----Original Message-----
> >>From: Gaëtan Rivet <grive@u256.net>
> >>Sent: 10 फरवरी 2022 21:39
> >>To: Ferruh Yigit <ferruh.yigit@intel.com>; Madhuker Mythri
> >><madhuker.mythri@oracle.com>
> >>Cc: dev@dpdk.org
> >>Subject: [External] : Re:
> >>
> >>On Thu, Feb 10, 2022, at 16:00, Ferruh Yigit wrote:
> >>> On 2/10/2022 7:10 AM, madhuker.mythri@oracle.com wrote:
> >>>> From: Madhuker Mythri <madhuker.mythri@oracle.com>
> >>>>
> >>>> Failsafe pmd started crashing with global devargs syntax as devargs
> >>>> is not memset to zero. Access it to in rte_devargs_parse resulted
> >>>> in a crash when called from secondary process.
> >>>>
> >>>> Bugzilla Id: 933
> >>>>
> >>>> Signed-off-by: Madhuker Mythri <madhuker.mythri@oracle.com>
> >>>> ---
> >>>>   drivers/net/failsafe/failsafe.c | 1 +
> >>>>   1 file changed, 1 insertion(+)
> >>>>
> >>>> diff --git a/drivers/net/failsafe/failsafe.c
> >>>> b/drivers/net/failsafe/failsafe.c index 3c754a5f66..aa93cc6000
> >>>> 100644
> >>>> --- a/drivers/net/failsafe/failsafe.c
> >>>> +++ b/drivers/net/failsafe/failsafe.c
> >>>> @@ -360,6 +360,7 @@ rte_pmd_failsafe_probe(struct
> rte_vdev_device *vdev)
> >>>>   			if (sdev->devargs.name[0] == '\0')
> >>>>   				continue;
> >>>>
> >>>> +			memset(&devargs, 0, sizeof(devargs));
> >>>>   			/* rebuild devargs to be able to get the bus name. */
> >>>>   			ret = rte_devargs_parse(&devargs,
> >>>>   						sdev->devargs.name);
> >>>
> >>> if 'rte_devargs_parse()' requires 'devargs' parameter to be memset,
> >>> what do you think memset it in the API?
> >>> This prevents forgotten cases like this.
> >>
> >>Hi,
> >>
> >>I was looking at it this morning.
> >>Before the last release, rte_devargs_parse() was only supporting legacy
> syntax.
> >>It never read from the devargs structure, only wrote to it. So it was safe to
> use with a non-memset devargs.
> >>
> >>The rte_devargs_layer_parse() however is more complex. To allow
> rte_dev_iterator_init() to call it without doing memory allocation, it reads
> parts of the devargs to make decisions.
> >>
> >>Doing a first call to rte_devargs_layer_parse() as part of
> rte_devargs_parse() thus modified the contract it had with the users, that it
> would never read from devargs.
> >>
> >>It is not possible to completely avoid reading from devargs in
> rte_devargs_layer_parse().
> >>It is necessary for RTE_DEV_FOREACH() to be safe to interrupt without
> having to do iterator cleanup.
> >>
> >>This is my current understanding. In that context, yes I think it is
> preferrable to do memset() within rte_devargs_parse(). It will restore the
> previous part of the API saying that calling it with non-memset >devargs was
> safe to do.
> >>
> >>Thanks,
> >>--
> >>Gaetan Rivet
> >
> > Thanks for your comments.
> > The rte_devargs_parse() is used in other 'netvsc' PMD also in
> > netvsc_hotadd_callback().
> > In this netvsc_hotadd_callback(), it was assigning the devargs with
> > some other instance pointer(not sure, whether its just a pointer or
> > with data values) before calling this rte_devargs_parse(), so if we
> > memset inside this API, then the devargs data values will be nullified
> > right.
> > I'm not fully familiar with this parsing functionality. So, please let
> > me know, doing memset() inside this rte_devargs_parse() is valid or
> > not, as this is a generic function for all the PMD's.
> >
> > Thanks,
> > Madhuker.
> 
> Hi Madhuker,
> 
> I have just checked the code, it does not seem that netvsc relies on values
> being kept in the devargs structure across calls, so it seems that it would be
> safe. It would be better to check with the maintainers however, I'm adding
> them to this thread.
> 
> --
> Gaetan Rivet

When netvsc calls rte_devargs_parse, it assumes the value in rte_devargs will be overwritten. There is an issue with netvsc dealing multiple devices, that is on my todo list.

In this case, I think it's safe to do memset() within rte_devargs_parse().

Long

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] devargs: Fix rte_devargs_parse uninitialized calls
  2022-02-15 15:27   ` David Marchand
@ 2022-02-16 17:12     ` Gaëtan Rivet
  0 siblings, 0 replies; 13+ messages in thread
From: Gaëtan Rivet @ 2022-02-16 17:12 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, madhuker.mythri, Ferruh Yigit

On Tue, Feb 15, 2022, at 16:27, David Marchand wrote:
> On Thu, Feb 10, 2022 at 6:01 PM Gaetan Rivet <grive@u256.net> wrote:
>>
>> The function rte_devargs_parse() previously was safe to call with
>> non-initialized devargs structure as parameter.
>>
>> When adding the support for the global device syntax,
>> this assumption was broken. Restore it by forcing memset as part of
>> the call itself.
>>
>> Bugzilla Id: 933
>
> Nit: Bugzilla ID*
>
>> Fixes: b344eb5d941a ("devargs: parse global device syntax")
>
> We need a backport in 21.11, right?

Hi David, yes it should be in 21.11 as well.

-- 
Gaetan Rivet

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re:
       [not found] ` <20240126173317.2779230-1-joshwash@google.com>
@ 2024-01-31 14:58   ` Ferruh Yigit
  0 siblings, 0 replies; 13+ messages in thread
From: Ferruh Yigit @ 2024-01-31 14:58 UTC (permalink / raw)
  To: Joshua Washington; +Cc: dev, Rushil Gupta

On 1/26/2024 5:33 PM, Joshua Washington wrote:
> Subject: [PATCH v4 0/7] net/gve: RSS Support for GVE Driver
> 
> This patch series introduces RSS support for the GVE poll-mode driver.
> This series includes implementations of the following eth_dev_ops:
> 
> 1) rss_hash_update
> 2) rss_hash_conf_get
> 3) reta_query
> 4) reta_update
> 
> In rss_hash_update, the GVE driver supports the following RSS hash
> types:
> 
> * RTE_ETH_RSS_IPV4
> * RTE_ETH_RSS_NONFRAG_IPV4_TCP
> * RTE_ETH_RSS_NONFRAG_IPV4_UDP
> * RTE_ETH_RSS_IPV6
> * RTE_ETH_RSS_IPV6_EX
> * RTE_ETH_RSS_NONFRAG_IPV6_TCP
> * RTE_ETH_RSS_NONFRAG_IPV6_UDP
> * RTE_ETH_RSS_IPV6_TCP_EX
> * RTE_ETH_RSS_IPV6_UDP_EX
> 
> The hash key is 40B, and the lookup table has 128 entries. These values
> are not configurable in this implementation.
> 
> In general, the DPDK driver expects the RSS hash configuration to be set
> with a key before the redriection table is set up. When the RSS hash is
> configured, a default redirection table is generated based on the number
> of queues. When the device is re-configured, the redirection table is
> reset to the default value based on the queue count.
> 
> An important note is that the gVNIC device expects 32 bit integers for
> RSS redirection table entries, while the RTE API uses 16 bit integers.
> However, this is unlikely to be an issue, as these values represent
> receive queues, and the gVNIC device does not support anywhere near 64K
> queues.
> 
> This series also updates the corresponding feature matrix ertries and
> documentation as it pertains to RSS support in the GVE driver.
> 
> v2:
> Add commmit messages for patches with it missing, and other checkpatches
> fixes.
> 
> Note: There is a warning about complex macros being parenthesized that
> does not seem to be well-founded.
> 
> v3:
> Fix build warnings that come up on certain distros.
> 
> v4:
> Fix formatting in gve_adminq.c
> 
> Joshua Washington (7):
>   net/gve: fully expose RSS offload support in dev_info
>   net/gve: RSS adminq command changes
>   net/gve: add gve_rss library for handling RSS-related behaviors
>   net/gve: RSS configuration update support
>   net/gve: RSS redirection table update support
>   net/gve: update gve.ini with RSS capabilities
>   net/gve: update GVE documentation with RSS support
> 
> 

'./devtools/check-git-log.sh' script is giving warnings [1]:

Expected patch title format is:
net/gve: <verb> <object>

<verb> should start with lowercase.


[1]
- check-git-log:




Wrong headline format:




        net/gve: fully expose RSS offload support in dev_info




        net/gve: add gve_rss library for handling RSS-related behaviors




Wrong headline uppercase:




        net/gve: RSS adminq command changes




        net/gve: RSS configuration update support




        net/gve: RSS redirection table update support




Headline too long:




        net/gve: add gve_rss library for handling RSS-related behaviors


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-01-31 14:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10  7:10 [PATCH] net/failsafe: Fix crash due to global devargs syntax parsing from secondary process madhuker.mythri
2022-02-10 15:00 ` Ferruh Yigit
2022-02-10 16:08   ` Gaëtan Rivet
2022-02-11  9:37     ` [External] : Re: Madhuker Mythri
2022-02-11  9:58       ` [External] : Re: [PATCH] net/failsafe: Fix crash due to global devargs syntax parsing from secondary process Ferruh Yigit
2022-02-11  9:58       ` [External] : Gaëtan Rivet
2022-02-16  8:27         ` Long Li
2022-02-10 17:01 ` [PATCH] devargs: Fix rte_devargs_parse uninitialized calls Gaetan Rivet
2022-02-15 12:51   ` Ferruh Yigit
2022-02-15 13:45     ` Gaëtan Rivet
2022-02-15 15:27   ` David Marchand
2022-02-16 17:12     ` Gaëtan Rivet
2024-01-24  0:14 [PATCH v3 0/7] net/gve: RSS Support for GVE Driver Joshua Washington
     [not found] ` <20240126173317.2779230-1-joshwash@google.com>
2024-01-31 14:58   ` Ferruh Yigit

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).