From: Simon Horman <horms@kernel.org>
To: Konrad Leszczynski <konrad.leszczynski@intel.com>
Cc: davem@davemloft.net, andrew+netdev@lunn.ch, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, cezary.rojewski@intel.com,
sebastian.basierski@intel.com, Kees Cook <kees@kernel.org>
Subject: Re: [PATCH net-next 1/7] net: stmmac: replace memcpy with strscpy in ethtool
Date: Wed, 27 Aug 2025 20:13:15 +0100 [thread overview]
Message-ID: <20250827191315.GQ10519@horms.kernel.org> (raw)
In-Reply-To: <20250826113247.3481273-2-konrad.leszczynski@intel.com>
+ Kees
On Tue, Aug 26, 2025 at 01:32:41PM +0200, Konrad Leszczynski wrote:
> Fix kernel exception by replacing memcpy with strscpy when used with
> safety feature strings in ethtool logic.
>
> [ +0.000023] BUG: KASAN: global-out-of-bounds in stmmac_get_strings+0x17d/0x520 [stmmac]
> [ +0.000115] Read of size 32 at addr ffffffffc0cfab20 by task ethtool/2571
>
> [ +0.000005] Call Trace:
> [ +0.000004] <TASK>
> [ +0.000003] dump_stack_lvl+0x6c/0x90
> [ +0.000016] print_report+0xce/0x610
> [ +0.000011] ? stmmac_get_strings+0x17d/0x520 [stmmac]
> [ +0.000108] ? kasan_addr_to_slab+0xd/0xa0
> [ +0.000008] ? stmmac_get_strings+0x17d/0x520 [stmmac]
> [ +0.000101] kasan_report+0xd4/0x110
> [ +0.000010] ? stmmac_get_strings+0x17d/0x520 [stmmac]
> [ +0.000102] kasan_check_range+0x3a/0x1c0
> [ +0.000010] __asan_memcpy+0x24/0x70
> [ +0.000008] stmmac_get_strings+0x17d/0x520 [stmmac]
>
> Reviewed-by: Sebastian Basierski <sebastian.basierski@intel.com>
> Signed-off-by: Konrad Leszczynski <konrad.leszczynski@intel.com>
Hi Konrad,
As mentioned by Vadim elsewhere, as this is a fix it should
be part of a separate series targeted at net.
And it should have a Fixes tag.
Also, as a follow-up for net-next, it might be nice
to move stmmac_get_strings() to use an appropriate combination
of ethtool_puts() and ethtool_cpu().
See: commit 151e13ece86d ("net: ethtool: Adjust exactly ETH_GSTRING_LEN-long stats to use memcpy")
The code change itself looks good to me.
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> index f702f7b7bf9f..219a2df578ae 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> @@ -795,7 +795,7 @@ static void stmmac_get_strings(struct net_device *dev, u32 stringset, u8 *data)
> if (!stmmac_safety_feat_dump(priv,
> &priv->sstats, i,
> NULL, &desc)) {
> - memcpy(p, desc, ETH_GSTRING_LEN);
> + strscpy(p, desc, ETH_GSTRING_LEN);
> p += ETH_GSTRING_LEN;
> }
> }
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2025-08-27 19:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 11:32 [PATCH net-next 0/7] net: stmmac: fixes and new features Konrad Leszczynski
2025-08-26 11:32 ` [PATCH net-next 1/7] net: stmmac: replace memcpy with strscpy in ethtool Konrad Leszczynski
2025-08-27 19:13 ` Simon Horman [this message]
2025-08-26 11:32 ` [PATCH net-next 2/7] net: stmmac: correct Tx descriptors debugfs prints Konrad Leszczynski
2025-08-26 11:32 ` [PATCH net-next 3/7] net: stmmac: check if interface is running before TC block setup Konrad Leszczynski
2025-08-26 11:32 ` [PATCH net-next 4/7] net: stmmac: enable ARP Offload on mac_link_up() Konrad Leszczynski
2025-08-26 17:05 ` kernel test robot
2025-08-27 19:28 ` Simon Horman
2025-08-26 11:32 ` [PATCH net-next 5/7] net: stmmac: set TE/RE bits for ARP Offload when interface down Konrad Leszczynski
2025-08-26 11:32 ` [PATCH net-next 6/7] net: stmmac: enhance VLAN protocol detection for GRO Konrad Leszczynski
2025-08-27 19:35 ` Simon Horman
2025-08-26 11:32 ` [PATCH net-next 7/7] net: stmmac: add TC flower filter support for IP EtherType Konrad Leszczynski
2025-08-27 19:37 ` Simon Horman
2025-08-28 9:46 ` Konrad Leszczynski
2025-08-26 17:29 ` [PATCH net-next 0/7] net: stmmac: fixes and new features Vadim Fedorenko
2025-08-28 6:47 ` Konrad Leszczynski
2025-08-28 12:25 ` Andrew Lunn
2025-08-28 12:51 ` Konrad Leszczynski
2025-08-28 13:21 ` Vadim Fedorenko
2025-08-28 14:40 ` Andrew Lunn
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=20250827191315.GQ10519@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=cezary.rojewski@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kees@kernel.org \
--cc=konrad.leszczynski@intel.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sebastian.basierski@intel.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).