devargs: Fix rte_devargs_parse uninitialized calls

Message ID 20220210170131.2199922-1-grive@u256.net (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series devargs: Fix rte_devargs_parse uninitialized calls |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Gaëtan Rivet Feb. 10, 2022, 5:01 p.m. UTC
  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(+)
  

Comments

Ferruh Yigit Feb. 15, 2022, 12:51 p.m. UTC | #1
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) {
  
Gaëtan Rivet Feb. 15, 2022, 1:45 p.m. UTC | #2
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.
  
David Marchand Feb. 15, 2022, 3:27 p.m. UTC | #3
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.
  
Gaëtan Rivet Feb. 16, 2022, 5:12 p.m. UTC | #4
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.
  

Patch

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