All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Konrad Leszczynski <konrad.leszczynski@intel.com>
Cc: davem@davemloft.net, andrew+netdev@lunn.ch, edumazet@google.com,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, cezary.rojewski@intel.com,
	sebastian.basierski@intel.com
Subject: Re: [PATCH net 1/3] net: stmmac: replace memcpy with strscpy in ethtool
Date: Mon, 1 Sep 2025 12:59:43 -0700	[thread overview]
Message-ID: <20250901125943.243efb74@kernel.org> (raw)
In-Reply-To: <20250828100237.4076570-2-konrad.leszczynski@intel.com>

On Thu, 28 Aug 2025 12:02:35 +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

If you hit this with upstream code please mention which string 
is not padded. If this can't happen with upstream platforms --
there is no upstream bug. BTW ethtool_puts() is a better choice.

> Fixes: 8bf993a5877e8a0a ("net: stmmac: Add support for DWMAC5 and implement Safety Features")
> 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..0433be4bd0c4 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);
> +					strscpy(p, desc, ETH_GSTRING_LEN);
>  					p += ETH_GSTRING_LEN;
>  				}

  parent reply	other threads:[~2025-09-01 19:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-28 10:02 [PATCH net 0/3] net: stmmac: misc fixes Konrad Leszczynski
2025-08-28 10:02 ` [PATCH net 1/3] net: stmmac: replace memcpy with strscpy in ethtool Konrad Leszczynski
2025-08-28 13:29   ` Vadim Fedorenko
2025-09-01 19:59   ` Jakub Kicinski [this message]
2025-09-04 18:53     ` Sebastian Basierski
2025-09-04 19:18       ` Andrew Lunn
2025-09-15 13:18         ` Konrad Leszczynski
2025-08-28 10:02 ` [PATCH net 2/3] net: stmmac: correct Tx descriptors debugfs prints Konrad Leszczynski
2025-08-28 13:34   ` Vadim Fedorenko
2025-09-01 20:01   ` Jakub Kicinski
2025-09-04 18:54     ` Sebastian Basierski
2025-09-15 12:54       ` Konrad Leszczynski
2025-09-15 15:05         ` Jakub Kicinski
2025-08-28 10:02 ` [PATCH net 3/3] net: stmmac: check if interface is running before TC block setup Konrad Leszczynski
2025-08-28 13:39   ` Vadim Fedorenko
2025-09-01 20:03   ` Jakub Kicinski
2025-09-04 19:01     ` Sebastian Basierski
2025-09-05  1:56       ` Jakub Kicinski
2025-09-09 18:47         ` Sebastian Basierski
2025-09-16 23:29           ` 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=20250901125943.243efb74@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=cezary.rojewski@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=konrad.leszczynski@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.