lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241026150700.GF1507976@kernel.org>
Date: Sat, 26 Oct 2024 16:07:00 +0100
From: Simon Horman <horms@...nel.org>
To: Rosen Penev <rosenp@...il.com>
Cc: netdev@...r.kernel.org, Madalin Bucur <madalin.bucur@....com>,
	Andrew Lunn <andrew+netdev@...n.ch>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Ioana Ciornei <ioana.ciornei@....com>,
	Claudiu Manoil <claudiu.manoil@....com>,
	Vladimir Oltean <vladimir.oltean@....com>,
	open list <linux-kernel@...r.kernel.org>,
	"open list:FREESCALE QUICC ENGINE UCC ETHERNET DRIVER" <linuxppc-dev@...ts.ozlabs.org>
Subject: Re: [PATCH net-next] net: freescale: use ethtool string helpers

On Fri, Oct 25, 2024 at 12:32:27PM -0700, Rosen Penev wrote:
> On Fri, Oct 25, 2024 at 5:57 AM Simon Horman <horms@...nel.org> wrote:
> >
> > On Thu, Oct 24, 2024 at 01:52:57PM -0700, Rosen Penev wrote:
> > > The latter is the preferred way to copy ethtool strings.
> > >
> > > Avoids manually incrementing the pointer. Cleans up the code quite well.
> > >
> > > Signed-off-by: Rosen Penev <rosenp@...il.com>
> >
> > ...
> >
> > > diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
> > > index b0060cf96090..10c5fa4d23d2 100644
> > > --- a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
> > > +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
> > > @@ -243,38 +243,24 @@ static void dpaa_get_ethtool_stats(struct net_device *net_dev,
> > >  static void dpaa_get_strings(struct net_device *net_dev, u32 stringset,
> > >                            u8 *data)
> > >  {
> > > -     unsigned int i, j, num_cpus, size;
> > > -     char string_cpu[ETH_GSTRING_LEN];
> > > -     u8 *strings;
> > > +     unsigned int i, j, num_cpus;
> > >
> > > -     memset(string_cpu, 0, sizeof(string_cpu));
> > > -     strings   = data;
> > > -     num_cpus  = num_online_cpus();
> > > -     size      = DPAA_STATS_GLOBAL_LEN * ETH_GSTRING_LEN;
> > > +     num_cpus = num_online_cpus();
> > >
> > >       for (i = 0; i < DPAA_STATS_PERCPU_LEN; i++) {
> > > -             for (j = 0; j < num_cpus; j++) {
> > > -                     snprintf(string_cpu, ETH_GSTRING_LEN, "%s [CPU %d]",
> > > -                              dpaa_stats_percpu[i], j);
> > > -                     memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> > > -                     strings += ETH_GSTRING_LEN;
> > > -             }
> > > -             snprintf(string_cpu, ETH_GSTRING_LEN, "%s [TOTAL]",
> > > -                      dpaa_stats_percpu[i]);
> > > -             memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> > > -             strings += ETH_GSTRING_LEN;
> > > -     }
> > > -     for (j = 0; j < num_cpus; j++) {
> > > -             snprintf(string_cpu, ETH_GSTRING_LEN,
> > > -                      "bpool [CPU %d]", j);
> > > -             memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> > > -             strings += ETH_GSTRING_LEN;
> > > +             for (j = 0; j < num_cpus; j++)
> > > +                     ethtool_sprintf(&data, "%s [CPU %d]",
> > > +                                     dpaa_stats_percpu[i], j);
> > > +
> > > +             ethtool_sprintf(&data, "%s [TOTAL]", dpaa_stats_percpu[i]);
> > >       }
> > > -     snprintf(string_cpu, ETH_GSTRING_LEN, "bpool [TOTAL]");
> > > -     memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> > > -     strings += ETH_GSTRING_LEN;
> > > +     for (i = 0; j < num_cpus; i++)
> >
> > Perhaps this should consistently use i, rather than i and j:
> >
> >         for (i = 0; i < num_cpus; i++)
> >
> > Flagged by W=1 builds with clang-18.
> I really need to compile test this on a PPC system.

Depending on your aims and hardware availability,
cross compiling may be easier.

But in any case, I don't think this problem relates to PPC.

> >
> > > +             ethtool_sprintf(&data, "bpool [CPU %d]", i);
> > > +
> > > +     ethtool_puts(&data, "bpool [TOTAL]");
> > >
> > > -     memcpy(strings, dpaa_stats_global, size);
> > > +     for (i = 0; i < DPAA_STATS_GLOBAL_LEN; i++)
> > > +             ethtool_puts(&data, dpaa_stats_global[i]);
> > >  }
> > >
> > >  static int dpaa_get_hash_opts(struct net_device *dev,
> >
> > ...
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ