[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGG=3QUJ4NztStM3GDxLqMyT4_O+8WuhaYCiK4rin-i40qwCcA@mail.gmail.com>
Date: Tue, 11 Mar 2025 16:04:24 -0700
From: Bill Wendling <morbo@...gle.com>
To: Kees Cook <kees@...nel.org>
Cc: Nicolas Ferre <nicolas.ferre@...rochip.com>, Claudiu Beznea <claudiu.beznea@...on.dev>,
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>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH v2] net: macb: Add __nonstring annotations for
unterminated strings
On Tue, Mar 11, 2025 at 3:44 PM Kees Cook <kees@...nel.org> wrote:
>
> When a character array without a terminating NUL character has a static
> initializer, GCC 15's -Wunterminated-string-initialization will only
> warn if the array lacks the "nonstring" attribute[1]. Mark the arrays
> with __nonstring to and correctly identify the char array as "not a C
s/__nonstring to and correctly/__nonstring to correctly/ ?
> string" and thereby eliminate the warning.
>
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1]
> Signed-off-by: Kees Cook <kees@...nel.org>
> ---
> v1: https://lore.kernel.org/lkml/20250310222415.work.815-kees@kernel.org/
> v2: switch to __nonstring annotation
> Cc: Nicolas Ferre <nicolas.ferre@...rochip.com>
> Cc: Claudiu Beznea <claudiu.beznea@...on.dev>
> Cc: Andrew Lunn <andrew+netdev@...n.ch>
> Cc: "David S. Miller" <davem@...emloft.net>
> Cc: Eric Dumazet <edumazet@...gle.com>
> Cc: Jakub Kicinski <kuba@...nel.org>
> Cc: Paolo Abeni <pabeni@...hat.com>
> Cc: netdev@...r.kernel.org
> ---
> drivers/net/ethernet/cadence/macb.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
> index 2847278d9cd4..003483073223 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -1027,7 +1027,7 @@ struct gem_stats {
> * this register should contribute to.
> */
> struct gem_statistic {
> - char stat_string[ETH_GSTRING_LEN];
> + char stat_string[ETH_GSTRING_LEN] __nonstring;
> int offset;
> u32 stat_bits;
> };
> @@ -1068,6 +1068,7 @@ static const struct gem_statistic gem_statistics[] = {
> GEM_STAT_TITLE(TX512CNT, "tx_512_1023_byte_frames"),
> GEM_STAT_TITLE(TX1024CNT, "tx_1024_1518_byte_frames"),
> GEM_STAT_TITLE(TX1519CNT, "tx_greater_than_1518_byte_frames"),
> +
Is this an errant inclusion? :-)
Reviewed-by: Bill Wendling <morbo@...gle.com>
> GEM_STAT_TITLE_BITS(TXURUNCNT, "tx_underrun",
> GEM_BIT(NDS_TXERR)|GEM_BIT(NDS_TXFIFOERR)),
> GEM_STAT_TITLE_BITS(SNGLCOLLCNT, "tx_single_collision_frames",
> --
> 2.34.1
>
>
Powered by blists - more mailing lists