From: Konrad Leszczynski <konrad.leszczynski@intel.com>
To: davem@davemloft.net, andrew+netdev@lunn.ch, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
cezary.rojewski@intel.com, sebastian.basierski@intel.com,
Konrad Leszczynski <konrad.leszczynski@intel.com>
Subject: [PATCH net v4 1/2] net: stmmac: replace memcpy with ethtool_puts in ethtool
Date: Tue, 16 Sep 2025 14:09:31 +0200 [thread overview]
Message-ID: <20250916120932.217547-2-konrad.leszczynski@intel.com> (raw)
In-Reply-To: <20250916120932.217547-1-konrad.leszczynski@intel.com>
Fix kernel exception by replacing memcpy with ethtool_puts 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>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Konrad Leszczynski <konrad.leszczynski@intel.com>
---
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 77758a7299b4..d5a2b7e9b2a9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -752,7 +752,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);
+ ethtool_puts(&p, desc);
p += ETH_GSTRING_LEN;
}
}
--
2.34.1
next prev parent reply other threads:[~2025-09-16 12:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 12:09 [PATCH net v4 0/2] net: stmmac: misc fixes Konrad Leszczynski
2025-09-16 12:09 ` Konrad Leszczynski [this message]
2025-09-16 16:45 ` [PATCH net v4 1/2] net: stmmac: replace memcpy with ethtool_puts in ethtool Simon Horman
2025-09-16 17:12 ` Andrew Lunn
2025-09-16 23:25 ` Jakub Kicinski
2025-09-17 15:54 ` Tony Nguyen
2025-09-16 12:09 ` [PATCH net v4 2/2] net: stmmac: check if interface is running before TC block setup Konrad Leszczynski
2025-09-16 23:25 ` Jakub Kicinski
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=20250916120932.217547-2-konrad.leszczynski@intel.com \
--to=konrad.leszczynski@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=cezary.rojewski@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.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
all inboxes | Powered by JetHome®