DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: fix build with GCC 12 and ASan
@ 2023-03-09  9:03 David Marchand
  2023-03-14  9:02 ` David Marchand
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: David Marchand @ 2023-03-09  9:03 UTC (permalink / raw)
  To: dev; +Cc: stable, Matan Azrad, Viacheslav Ovsiienko

Building with gcc 12 and ASan raises this warning:

../drivers/net/mlx5/mlx5_txpp.c: In function ‘mlx5_txpp_xstats_get_names’:
../drivers/net/mlx5/mlx5_txpp.c:1066:25: error: ‘strncpy’ specified bound
	64 equals destination size [-Werror=stringop-truncation]
 1066 |                         strncpy(xstats_names[i + n_used].name,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1067 |                                 mlx5_txpp_stat_names[i],
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~
 1068 |                                 RTE_ETH_XSTATS_NAME_SIZE);
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Prefer strlcpy.

Fixes: 3b025c0ca425 ("net/mlx5: provide send scheduling error statistics")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/mlx5/mlx5_txpp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index 63d98dbde9..0e1da1d5f5 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -1063,11 +1063,9 @@ int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
 
 	if (n >= n_used + n_txpp && xstats_names) {
 		for (i = 0; i < n_txpp; ++i) {
-			strncpy(xstats_names[i + n_used].name,
+			strlcpy(xstats_names[i + n_used].name,
 				mlx5_txpp_stat_names[i],
 				RTE_ETH_XSTATS_NAME_SIZE);
-			xstats_names[i + n_used].name
-					[RTE_ETH_XSTATS_NAME_SIZE - 1] = 0;
 		}
 	}
 	return n_used + n_txpp;
-- 
2.39.2


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

* Re: [PATCH] net/mlx5: fix build with GCC 12 and ASan
  2023-03-09  9:03 [PATCH] net/mlx5: fix build with GCC 12 and ASan David Marchand
@ 2023-03-14  9:02 ` David Marchand
  2023-03-14 13:00 ` Slava Ovsiienko
  2023-03-22 17:06 ` [PATCH v2] " David Marchand
  2 siblings, 0 replies; 7+ messages in thread
From: David Marchand @ 2023-03-14  9:02 UTC (permalink / raw)
  To: Matan Azrad, Viacheslav Ovsiienko, Raslan Darawsheh; +Cc: dev, stable

On Thu, Mar 9, 2023 at 10:03 AM David Marchand
<david.marchand@redhat.com> wrote:
>
> Building with gcc 12 and ASan raises this warning:
>
> ../drivers/net/mlx5/mlx5_txpp.c: In function ‘mlx5_txpp_xstats_get_names’:
> ../drivers/net/mlx5/mlx5_txpp.c:1066:25: error: ‘strncpy’ specified bound
>         64 equals destination size [-Werror=stringop-truncation]
>  1066 |                         strncpy(xstats_names[i + n_used].name,
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1067 |                                 mlx5_txpp_stat_names[i],
>       |                                 ~~~~~~~~~~~~~~~~~~~~~~~~
>  1068 |                                 RTE_ETH_XSTATS_NAME_SIZE);
>       |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> Prefer strlcpy.
>
> Fixes: 3b025c0ca425 ("net/mlx5: provide send scheduling error statistics")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>

Review please?


-- 
David Marchand


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

* RE: [PATCH] net/mlx5: fix build with GCC 12 and ASan
  2023-03-09  9:03 [PATCH] net/mlx5: fix build with GCC 12 and ASan David Marchand
  2023-03-14  9:02 ` David Marchand
@ 2023-03-14 13:00 ` Slava Ovsiienko
  2023-03-15 10:05   ` David Marchand
  2023-03-22 17:06 ` [PATCH v2] " David Marchand
  2 siblings, 1 reply; 7+ messages in thread
From: Slava Ovsiienko @ 2023-03-14 13:00 UTC (permalink / raw)
  To: David Marchand, dev; +Cc: stable, Matan Azrad

Hi, David

Thank you for the fix.
I see the quite similar strncpy() usage in mlx5_xstats_get_names() routine.
Does compiler complain about?

With best regards,
Slava

> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: четверг, 9 марта 2023 г. 11:03
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>
> Subject: [PATCH] net/mlx5: fix build with GCC 12 and ASan
> 
> Building with gcc 12 and ASan raises this warning:
> 
> ../drivers/net/mlx5/mlx5_txpp.c: In function ‘mlx5_txpp_xstats_get_names’:
> ../drivers/net/mlx5/mlx5_txpp.c:1066:25: error: ‘strncpy’ specified bound
> 	64 equals destination size [-Werror=stringop-truncation]
>  1066 |                         strncpy(xstats_names[i + n_used].name,
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1067 |                                 mlx5_txpp_stat_names[i],
>       |                                 ~~~~~~~~~~~~~~~~~~~~~~~~
>  1068 |                                 RTE_ETH_XSTATS_NAME_SIZE);
>       |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> Prefer strlcpy.
> 
> Fixes: 3b025c0ca425 ("net/mlx5: provide send scheduling error statistics")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  drivers/net/mlx5/mlx5_txpp.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
> index 63d98dbde9..0e1da1d5f5 100644
> --- a/drivers/net/mlx5/mlx5_txpp.c
> +++ b/drivers/net/mlx5/mlx5_txpp.c
> @@ -1063,11 +1063,9 @@ int mlx5_txpp_xstats_get_names(struct
> rte_eth_dev *dev __rte_unused,
> 
>  	if (n >= n_used + n_txpp && xstats_names) {
>  		for (i = 0; i < n_txpp; ++i) {
> -			strncpy(xstats_names[i + n_used].name,
> +			strlcpy(xstats_names[i + n_used].name,
>  				mlx5_txpp_stat_names[i],
>  				RTE_ETH_XSTATS_NAME_SIZE);
> -			xstats_names[i + n_used].name
> -					[RTE_ETH_XSTATS_NAME_SIZE - 1] =
> 0;
>  		}
>  	}
>  	return n_used + n_txpp;
> --
> 2.39.2


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

* Re: [PATCH] net/mlx5: fix build with GCC 12 and ASan
  2023-03-14 13:00 ` Slava Ovsiienko
@ 2023-03-15 10:05   ` David Marchand
  2023-03-15 12:08     ` Slava Ovsiienko
  0 siblings, 1 reply; 7+ messages in thread
From: David Marchand @ 2023-03-15 10:05 UTC (permalink / raw)
  To: Slava Ovsiienko; +Cc: dev, stable, Matan Azrad

On Tue, Mar 14, 2023 at 2:00 PM Slava Ovsiienko <viacheslavo@nvidia.com> wrote:
>
> Hi, David
>
> Thank you for the fix.
> I see the quite similar strncpy() usage in mlx5_xstats_get_names() routine.
> Does compiler complain about?

Strangely.. no.
But we could switch to strlcpy too.
What is your preferrence?


-- 
David Marchand


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

* RE: [PATCH] net/mlx5: fix build with GCC 12 and ASan
  2023-03-15 10:05   ` David Marchand
@ 2023-03-15 12:08     ` Slava Ovsiienko
  0 siblings, 0 replies; 7+ messages in thread
From: Slava Ovsiienko @ 2023-03-15 12:08 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, stable, Matan Azrad

Hi, 

I would prefer to fix both.

With best regards,
Slava

> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: среда, 15 марта 2023 г. 12:05
> To: Slava Ovsiienko <viacheslavo@nvidia.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Matan Azrad <matan@nvidia.com>
> Subject: Re: [PATCH] net/mlx5: fix build with GCC 12 and ASan
> 
> On Tue, Mar 14, 2023 at 2:00 PM Slava Ovsiienko <viacheslavo@nvidia.com>
> wrote:
> >
> > Hi, David
> >
> > Thank you for the fix.
> > I see the quite similar strncpy() usage in mlx5_xstats_get_names() routine.
> > Does compiler complain about?
> 
> Strangely.. no.
> But we could switch to strlcpy too.
> What is your preferrence?
> 
> 
> --
> David Marchand


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

* [PATCH v2] net/mlx5: fix build with GCC 12 and ASan
  2023-03-09  9:03 [PATCH] net/mlx5: fix build with GCC 12 and ASan David Marchand
  2023-03-14  9:02 ` David Marchand
  2023-03-14 13:00 ` Slava Ovsiienko
@ 2023-03-22 17:06 ` David Marchand
  2023-03-23 11:01   ` Raslan Darawsheh
  2 siblings, 1 reply; 7+ messages in thread
From: David Marchand @ 2023-03-22 17:06 UTC (permalink / raw)
  To: dev; +Cc: stable, Matan Azrad, Viacheslav Ovsiienko

Building with gcc 12 and ASan raises this warning:

../drivers/net/mlx5/mlx5_txpp.c: In function ‘mlx5_txpp_xstats_get_names’:
../drivers/net/mlx5/mlx5_txpp.c:1066:25: error: ‘strncpy’ specified bound
	64 equals destination size [-Werror=stringop-truncation]
 1066 |                         strncpy(xstats_names[i + n_used].name,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1067 |                                 mlx5_txpp_stat_names[i],
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~
 1068 |                                 RTE_ETH_XSTATS_NAME_SIZE);
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Prefer strlcpy for xstats.

Fixes: 3b025c0ca425 ("net/mlx5: provide send scheduling error statistics")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since v1:
- updated mlx5_xstats_get_names too,

---
 drivers/net/mlx5/mlx5_stats.c | 3 +--
 drivers/net/mlx5/mlx5_txpp.c  | 4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c
index f64fa3587b..615e1d073d 100644
--- a/drivers/net/mlx5/mlx5_stats.c
+++ b/drivers/net/mlx5/mlx5_stats.c
@@ -288,10 +288,9 @@ mlx5_xstats_get_names(struct rte_eth_dev *dev,
 
 	if (n >= mlx5_xstats_n && xstats_names) {
 		for (i = 0; i != mlx5_xstats_n; ++i) {
-			strncpy(xstats_names[i].name,
+			strlcpy(xstats_names[i].name,
 				xstats_ctrl->info[i].dpdk_name,
 				RTE_ETH_XSTATS_NAME_SIZE);
-			xstats_names[i].name[RTE_ETH_XSTATS_NAME_SIZE - 1] = 0;
 		}
 	}
 	mlx5_xstats_n = mlx5_txpp_xstats_get_names(dev, xstats_names,
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index 63d98dbde9..0e1da1d5f5 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -1063,11 +1063,9 @@ int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
 
 	if (n >= n_used + n_txpp && xstats_names) {
 		for (i = 0; i < n_txpp; ++i) {
-			strncpy(xstats_names[i + n_used].name,
+			strlcpy(xstats_names[i + n_used].name,
 				mlx5_txpp_stat_names[i],
 				RTE_ETH_XSTATS_NAME_SIZE);
-			xstats_names[i + n_used].name
-					[RTE_ETH_XSTATS_NAME_SIZE - 1] = 0;
 		}
 	}
 	return n_used + n_txpp;
-- 
2.39.2


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

* RE: [PATCH v2] net/mlx5: fix build with GCC 12 and ASan
  2023-03-22 17:06 ` [PATCH v2] " David Marchand
@ 2023-03-23 11:01   ` Raslan Darawsheh
  0 siblings, 0 replies; 7+ messages in thread
From: Raslan Darawsheh @ 2023-03-23 11:01 UTC (permalink / raw)
  To: David Marchand, dev; +Cc: stable, Matan Azrad, Slava Ovsiienko

Hi,

> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Wednesday, March 22, 2023 7:06 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>
> Subject: [PATCH v2] net/mlx5: fix build with GCC 12 and ASan
> 
> Building with gcc 12 and ASan raises this warning:
> 
> ../drivers/net/mlx5/mlx5_txpp.c: In function ‘mlx5_txpp_xstats_get_names’:
> ../drivers/net/mlx5/mlx5_txpp.c:1066:25: error: ‘strncpy’ specified bound
> 	64 equals destination size [-Werror=stringop-truncation]
>  1066 |                         strncpy(xstats_names[i + n_used].name,
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1067 |                                 mlx5_txpp_stat_names[i],
>       |                                 ~~~~~~~~~~~~~~~~~~~~~~~~
>  1068 |                                 RTE_ETH_XSTATS_NAME_SIZE);
>       |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> Prefer strlcpy for xstats.
> 
> Fixes: 3b025c0ca425 ("net/mlx5: provide send scheduling error statistics")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> Changes since v1:
> - updated mlx5_xstats_get_names too,
> 
> ---

Acked-by: Raslan Darawsheh <rasland@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2023-03-23 11:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09  9:03 [PATCH] net/mlx5: fix build with GCC 12 and ASan David Marchand
2023-03-14  9:02 ` David Marchand
2023-03-14 13:00 ` Slava Ovsiienko
2023-03-15 10:05   ` David Marchand
2023-03-15 12:08     ` Slava Ovsiienko
2023-03-22 17:06 ` [PATCH v2] " David Marchand
2023-03-23 11:01   ` 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).