From: Kees Cook <kees@kernel.org>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] net: macb: Truncate TX1519CNT for trailing NUL
Date: Tue, 11 Mar 2025 15:41:29 -0700 [thread overview]
Message-ID: <202503111540.8EB9B4702@keescook> (raw)
In-Reply-To: <64b35f60-2ed4-4ab0-8f4e-0dba042b4d4d@lunn.ch>
On Tue, Mar 11, 2025 at 03:12:00PM +0100, Andrew Lunn wrote:
> On Mon, Mar 10, 2025 at 03:24:16PM -0700, Kees Cook wrote:
> > GCC 15's -Wunterminated-string-initialization saw that this string was
> > being truncated. Adjust the initializer so that the needed final NUL
> > character will be present.
>
> This is where we get into the ugliness of the ethtool API for strings.
> It is not actually NUL terminated. The code uses memcpy(), see:
>
> https://elixir.bootlin.com/linux/v6.13.6/source/drivers/net/ethernet/cadence/macb_main.c#L3193
>
> The kAPI is that userspace provides a big buffer, and the kernel then
> copies these strings into the buffer at 32 byte offsets. There is no
> requirement for a NUL between them since they are all 32 bytes long.
Oh right! Yes, I always forget these are not NUL terminated. Okay, I
will resend this with a proper __nonstring annotation. I see the title
use in drivers/net/ethernet/cadence/macb_main.c and can confirm it's not
using C String APIs.
--
Kees Cook
prev parent reply other threads:[~2025-03-11 22:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 22:24 [PATCH] net: macb: Truncate TX1519CNT for trailing NUL Kees Cook
2025-03-11 7:27 ` Michal Swiatkowski
2025-03-11 22:38 ` Kees Cook
2025-03-11 14:12 ` Andrew Lunn
2025-03-11 22:41 ` Kees Cook [this message]
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=202503111540.8EB9B4702@keescook \
--to=kees@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=claudiu.beznea@tuxon.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).