* [PATCH 0/2] mlx5: fix miss NULL check in devargs parsing
@ 2022-10-24 12:33 Michael Baum
2022-10-24 12:33 ` [PATCH 1/2] common/mlx5: fix miss null " Michael Baum
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael Baum @ 2022-10-24 12:33 UTC (permalink / raw)
To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko
The MLX5 PMD parses the devargs in several places.
It gets structure called "devargs" as a member of EAL device containing
all needed information.
When "devargs" structure is invalid, the PMD avoids parsing it.
However, when it valid but its field "args" is invalid, the PMD tries to
parse it and dereference to NULL pointer.
Those patches add checks to avoid these NULL dereferencing.
Michael Baum (2):
common/mlx5: fix miss null check in devargs parsing
net/mlx5: fix miss null check in ETH devargs parsing
drivers/common/mlx5/mlx5_common.c | 8 +++++---
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] common/mlx5: fix miss null check in devargs parsing
2022-10-24 12:33 [PATCH 0/2] mlx5: fix miss NULL check in devargs parsing Michael Baum
@ 2022-10-24 12:33 ` Michael Baum
2022-10-24 12:33 ` [PATCH 2/2] net/mlx5: fix miss null check in ETH " Michael Baum
2022-10-25 13:54 ` [PATCH 0/2] mlx5: fix miss NULL check in " Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Michael Baum @ 2022-10-24 12:33 UTC (permalink / raw)
To: dev
Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko, michaelba, stable
The common MLX5 probe function parses first the devargs and save them in
a dictionary.
It gets structure called "devargs" as a member of EAL device containing
all needed information.
When "devargs" structure is invalid, the function avoids parsing it.
However, when it valid but its field "args" is invalid, the function
tries to parse it and dereference to NULL pointer.
This patch adds check to avoid this NULL dereferencing.
Fixes: a729d2f093e9 ("common/mlx5: refactor devargs management")
Cc: michaelba@nvidia.com
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/common/mlx5/mlx5_common.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 4dcc8cc49c..bf22c0694d 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -164,8 +164,9 @@ mlx5_kvargs_prepare(struct mlx5_kvargs_ctrl *mkvlist,
struct rte_kvargs *kvlist;
uint32_t i;
- if (devargs == NULL)
+ if (mkvlist == NULL)
return 0;
+ MLX5_ASSERT(devargs != NULL && devargs->args != NULL);
kvlist = rte_kvargs_parse(devargs->args, NULL);
if (kvlist == NULL) {
rte_errno = EINVAL;
@@ -400,8 +401,9 @@ parse_class_options(const struct rte_devargs *devargs,
{
int ret = 0;
- if (devargs == NULL)
+ if (mkvlist == NULL)
return 0;
+ MLX5_ASSERT(devargs != NULL);
if (devargs->cls != NULL && devargs->cls->name != NULL)
/* Global syntax, only one class type. */
return class_name_to_value(devargs->cls->name);
@@ -965,7 +967,7 @@ mlx5_common_dev_probe(struct rte_device *eal_dev)
int ret;
DRV_LOG(INFO, "probe device \"%s\".", eal_dev->name);
- if (eal_dev->devargs != NULL)
+ if (eal_dev->devargs != NULL && eal_dev->devargs->args != NULL)
mkvlist_p = &mkvlist;
ret = mlx5_kvargs_prepare(mkvlist_p, eal_dev->devargs);
if (ret < 0) {
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] net/mlx5: fix miss null check in ETH devargs parsing
2022-10-24 12:33 [PATCH 0/2] mlx5: fix miss NULL check in devargs parsing Michael Baum
2022-10-24 12:33 ` [PATCH 1/2] common/mlx5: fix miss null " Michael Baum
@ 2022-10-24 12:33 ` Michael Baum
2022-10-25 13:54 ` [PATCH 0/2] mlx5: fix miss NULL check in " Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Michael Baum @ 2022-10-24 12:33 UTC (permalink / raw)
To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko, xuemingl, stable
The "mlx5_os_parse_eth_devargs()" function parses the ETH devargs into a
specific structure called "eth_da".
It gets structure called "devargs" as a member of EAL device containing
the relevant information.
When "devargs" structure is invalid, the function avoids parsing it.
However, when it valid but its field "args" is invalid, the function
tries to parse it and dereference to NULL pointer.
This patch adds check to avoid this NULL dereferencing.
Fixes: 919488fbfa71 ("net/mlx5: support Sub-Function")
Cc: xuemingl@nvidia.com
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx5/linux/mlx5_os.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index ab7ffa0931..2b6741396d 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2411,7 +2411,7 @@ mlx5_os_parse_eth_devargs(struct rte_device *dev,
dev->devargs->cls_str);
return -rte_errno;
}
- if (eth_da->type == RTE_ETH_REPRESENTOR_NONE) {
+ if (eth_da->type == RTE_ETH_REPRESENTOR_NONE && dev->devargs->args) {
/* Parse legacy device argument */
ret = rte_eth_devargs_parse(dev->devargs->args, eth_da);
if (ret) {
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 0/2] mlx5: fix miss NULL check in devargs parsing
2022-10-24 12:33 [PATCH 0/2] mlx5: fix miss NULL check in devargs parsing Michael Baum
2022-10-24 12:33 ` [PATCH 1/2] common/mlx5: fix miss null " Michael Baum
2022-10-24 12:33 ` [PATCH 2/2] net/mlx5: fix miss null check in ETH " Michael Baum
@ 2022-10-25 13:54 ` Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Raslan Darawsheh @ 2022-10-25 13:54 UTC (permalink / raw)
To: Michael Baum, dev; +Cc: Matan Azrad, Slava Ovsiienko
Hi,
> -----Original Message-----
> From: Michael Baum <michaelba@nvidia.com>
> Sent: Monday, October 24, 2022 3:34 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Raslan Darawsheh
> <rasland@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>
> Subject: [PATCH 0/2] mlx5: fix miss NULL check in devargs parsing
>
> The MLX5 PMD parses the devargs in several places.
> It gets structure called "devargs" as a member of EAL device containing all
> needed information.
>
> When "devargs" structure is invalid, the PMD avoids parsing it.
> However, when it valid but its field "args" is invalid, the PMD tries to parse it
> and dereference to NULL pointer.
>
> Those patches add checks to avoid these NULL dereferencing.
>
>
> Michael Baum (2):
> common/mlx5: fix miss null check in devargs parsing
> net/mlx5: fix miss null check in ETH devargs parsing
>
> drivers/common/mlx5/mlx5_common.c | 8 +++++---
> drivers/net/mlx5/linux/mlx5_os.c | 2 +-
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> --
> 2.25.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-25 13:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 12:33 [PATCH 0/2] mlx5: fix miss NULL check in devargs parsing Michael Baum
2022-10-24 12:33 ` [PATCH 1/2] common/mlx5: fix miss null " Michael Baum
2022-10-24 12:33 ` [PATCH 2/2] net/mlx5: fix miss null check in ETH " Michael Baum
2022-10-25 13:54 ` [PATCH 0/2] mlx5: fix miss NULL check in " Raslan Darawsheh
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).