From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Shenwei Wang <shenwei.wang@nxp.com>
Cc: Alexander Lobakin <alexandr.lobakin@intel.com>,
Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"imx@lists.linux.dev" <imx@lists.linux.dev>
Subject: Re: [PATCH v2 RESEND 1/1] net: fec: add xdp and page pool statistics
Date: Thu, 10 Nov 2022 17:43:21 +0100 [thread overview]
Message-ID: <20221110164321.3534977-1-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <PAXPR04MB91853A6A1DDDBB06F33C975E89019@PAXPR04MB9185.eurprd04.prod.outlook.com>
From: Shenwei Wang <shenwei.wang@nxp.com>
Date: Thu, 10 Nov 2022 13:29:56 +0000
> > -----Original Message-----
> > From: Paolo Abeni <pabeni@redhat.com>
> > Sent: Thursday, November 10, 2022 5:54 AM
> > To: Shenwei Wang <shenwei.wang@nxp.com>; David S. Miller
> > <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub
> > Kicinski <kuba@kernel.org>
> > > case ETH_SS_STATS:
> > > - for (i = 0; i < ARRAY_SIZE(fec_stats); i++)
> > > - memcpy(data + i * ETH_GSTRING_LEN,
> > > - fec_stats[i].name, ETH_GSTRING_LEN);
> > > + for (i = 0; i < ARRAY_SIZE(fec_stats); i++) {
> > > + memcpy(data, fec_stats[i].name, ETH_GSTRING_LEN);
> > > + data += ETH_GSTRING_LEN;
> > > + }
> > > + for (i = 0; i < ARRAY_SIZE(fec_xdp_stat_strs); i++) {
> > > + memcpy(data, fec_xdp_stat_strs[i], ETH_GSTRING_LEN);
> > > + data += ETH_GSTRING_LEN;
> >
> > The above triggers a warning:
> >
> > In function 'fortify_memcpy_chk',
> > inlined from 'fec_enet_get_strings'
> > at ../drivers/net/ethernet/freescale/fec_main.c:2788:4:
> > ../include/linux/fortify-string.h:413:25: warning: call to '__read_overflow2_field'
> > declared with attribute warning: detected read beyond size of field (2nd
> > parameter); maybe use struct_group()? [-Wattribute-warning]
> > 413 | __read_overflow2_field(q_size_field, size);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > I think you can address it changing fec_xdp_stat_strs definition to:
> >
> > static const char fec_xdp_stat_strs[XDP_STATS_TOTAL][ETH_GSTRING_LEN] =
>
> That does a problem. How about just change the memcpy to strncpy?
Don't use a static char array, it would consume more memory than the
current code. Just replace memcpy()s with strscpy().
Why u32 for the stats tho? It will overflow sooner or later. "To
keep it simple and compatible" you can use u64_stats API :)
>
> Regards,
> Shenwei
>
> > { // ...
> >
> > Cheers,
> >
> > Paolo
Thanks,
Olek
next prev parent reply other threads:[~2022-11-10 16:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 2:31 [PATCH v2 RESEND 1/1] net: fec: add xdp and page pool statistics Shenwei Wang
2022-11-10 11:54 ` Paolo Abeni
2022-11-10 13:29 ` [EXT] " Shenwei Wang
2022-11-10 16:43 ` Alexander Lobakin [this message]
2022-11-10 21:40 ` Shenwei Wang
2022-11-14 13:35 ` Alexander Lobakin
2022-11-14 13:50 ` Andrew Lunn
2022-11-14 13:57 ` Alexander Lobakin
2022-11-14 15:01 ` [EXT] " Shenwei Wang
2022-11-14 16:27 ` Andrew Lunn
2022-11-14 16:31 ` Shenwei Wang
2022-11-10 23:32 ` kernel test robot
2022-11-11 5:46 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221110164321.3534977-1-alexandr.lobakin@intel.com \
--to=alexandr.lobakin@intel.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=imx@lists.linux.dev \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shenwei.wang@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox