From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47A01383322 for ; Thu, 4 Jun 2026 08:50:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780563016; cv=none; b=jWMBO/jnWQbnyaBC9GclquBDQcJOqqnrLgtgftDW+tW5jqWwRmpB6p4T7A9+ahePNXjFSLYfZIUAFo3D4yAWirrCOgndpMfhPTFkI2KzqDCtZkho8iz3EkTL1z8XQUwLoA1fDaBAjsGR2k9KvVDp+PFof9v3nBrsn3mzUdW2dsw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780563016; c=relaxed/simple; bh=cN3GYDYGdfIRk/xGq7e7i9c6SplFkqWMiAa3artP++A=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XQaUz4SvOpvEt2ziv3nr67wq6PFu4jyPpMZEthPGhPGtrMNx/ILwQaWLQrYqpij6G+iDLq+h8b8Vt4YrfM3xsFyIZqVfd9bRVSCVNIUEOSlrJjTeQxg5nm1eLjbnV2edXSXJCKeDb95uFCpMZuitf1bjRYYzm4JNn3G5dHhSObQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=s42ztUpo; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="s42ztUpo" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-46019edc13dso204965f8f.1 for ; Thu, 04 Jun 2026 01:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780563012; x=1781167812; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=WRiYMliuSQAUYMFdmOihHUU9eCsvr1hWSuEoUDPjWaE=; b=s42ztUpoKTYeJ+wXQohzHwc9+OdYXDKXrSzJ2gafUnIxQz8tvz+bJzC/xX0bTzcX3J GxGOO4P/xiTu38LXKsi9WVqAWgZll7QEFaFVd/HJsXcmgR/yWL7RS4PDscCWmW2dVqzG SsBPziNBDrxjhH6FRbrxK26L4jDGuX6g8o+SDgfauT76JL8wawrDpGzwaIfLAccubz3x e/V48aaAUJVgECyqLBufdb6bEKgVIwiNxuoGp0WUSw0KvdfJEZ6z6cmG7W7GTlWAMEjU nQVzRc09XF9sYK5StI84MuBSfjToxQm0Me+uwzOGsB4PyOVbJuhbU4PY4sd1Xm+Va5xm /tjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780563012; x=1781167812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WRiYMliuSQAUYMFdmOihHUU9eCsvr1hWSuEoUDPjWaE=; b=aZZjB1+nDZRpBNAo0zB8TbvaCYFzJMluxAFkt3Zpo8YMR53juY4W2YxHF6e801HF1U +x+iyTul9DVj+mn+YFiNElXfoefl0L7mJ+oNFDGnLPS0TmMWlae57eZLx3I/6l6BpbRp y8Z71tBXlkjawmAJVyXb+edUKeWKDTgF/VGmvQTwJf8H06f0QvbU06jxlXgkjNu46+KQ GTgT7kmrE/AWYcIht5nyFp1b6fEZcm6/3BHJ0H4QY3JFsXOwML0nIfmhqRbl/9/knBLS 23r9TWzTCWgYE7akVyjal4uPnhEYEMx7Y5+IdouwpL0k87yUhhLOCBxzvVli/lLNxGNx KQ3A== X-Forwarded-Encrypted: i=1; AFNElJ9i2R/5H1UxNmL1Kc6du8fEHsuqOtzVHgCqjqM/f3hNUwJBIBZ+Flqgt96W+4ddgE0P7Y+dqDvaA6Iac1s=@vger.kernel.org X-Gm-Message-State: AOJu0YzZ1Rkw64p+Bg8VH2gV1jJMPS/O4owNTmbLqIvirkEnR2aWl9UR JNayRsmPI1tXnQx7vnDAgASorvZ/7ONgiDOdFL3sG4eNSvjfsFxwH6i1 X-Gm-Gg: Acq92OFQQPIp+iz+VgAM1G5uz159YkWlRepTwG/9hivmW6gunW3o4VQltaRayPwdtd6 R+CxPkvMMn6nsIMauzhUoK4UpkDqw3i1KpgA+r0S/2ZCE+E6pTmp+UbIgodXfSGya9s6KyJ4t+R 7UGYvqL2H/f9JXRO0+VbzsTA6Pu8GZ4t8YJa3gCBbMJeNv0iNXL57k3KhRJwbrGnYhJXtZulciG J8N0ADO8aYwCQDCQKv+0BPBk6UCZuErLC0Ag1BQE+s3vlZRXfRVd8scP2AwMvbBq9NQ9QPHbsuE JSiy3bn1SQAygwusa0+UxPGAwiWTQHlzCjjb6gCbeFJijjNBhZaz764H1UuM7A+9+zJOLtaLI21 WCaKFMPPnMhKP1JZbHUUtQr7/xxVLULzlOnD7RuGPMOPtk+yD0WQ9Zvuiur00ZoKXjUD472Rcp8 7NWpT5KLzB1e5aq3oD7/ffiHFXoxXyqyTrDjj/5tFrbDOuFgagh4YLAftRibXqRWLE7ya4iwI= X-Received: by 2002:a5d:5f8e:0:b0:45e:dacb:8885 with SMTP id ffacd0b85a97d-460217600f5mr10672512f8f.35.1780563011569; Thu, 04 Jun 2026 01:50:11 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2f67c6sm14846055f8f.16.2026.06.04.01.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 01:50:11 -0700 (PDT) Date: Thu, 4 Jun 2026 09:50:10 +0100 From: David Laight To: Rosen Penev Cc: netdev@vger.kernel.org, Michael Chan , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: Re: [PATCH] net: b44: use ethtool_puts Message-ID: <20260604095010.35476abb@pumpkin> In-Reply-To: <20260531000334.388351-1-rosenp@gmail.com> References: <20260531000334.388351-1-rosenp@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 30 May 2026 17:03:34 -0700 Rosen Penev wrote: > There's a subtle error with the memcpy here, where b44_gstrings should > not be dereferenced. Dereferening causes the following error with W=1: The definition is: static const char b44_gstrings[][ETH_GSTRING_LEN] = ... There is nothing wrong with using memcpy(). > > In file included from drivers/net/ethernet/broadcom/b44.c:17: > In file included from ./include/linux/module.h:18: > In file included from ./include/linux/kmod.h:9: > In file included from ./include/linux/umh.h:4: > In file included from ./include/linux/gfp.h:7: > In file included from ./include/linux/mmzone.h:8: > In file included from ./include/linux/spinlock.h:56: > In file included from ./include/linux/preempt.h:79: > In file included from ./arch/powerpc/include/asm/preempt.h:5: > In file included from ./include/asm-generic/preempt.h:5: > In file included from ./include/linux/thread_info.h:23: > In file included from ./arch/powerpc/include/asm/current.h:13: > In file included from ./arch/powerpc/include/asm/paca.h:16: > In file included from ./include/linux/string.h:386: > ./include/linux/fortify-string.h:578:4: error: call to > '__read_overflow2_field' declared with 'warning' attribute: detected read > beyond size of field (2nd parameter); maybe use> > 578 | __read_overflow2_field(q_size_field, size); > | ^ > > Instead of fixing the memcpy, use ethtool_puts, which is the proper > helper for printing ethtool gstrings. ethtool_puts() lets you pass short strings as well as ones that don't contain a '\0' terminator. It isn't needed here because all the strings are already padded. > > Signed-off-by: Rosen Penev > --- > drivers/net/ethernet/broadcom/b44.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c > index 90df02e0039c..f994636fbd5f 100644 > --- a/drivers/net/ethernet/broadcom/b44.c > +++ b/drivers/net/ethernet/broadcom/b44.c > @@ -2031,11 +2031,11 @@ static int b44_set_pauseparam(struct net_device *dev, > > static void b44_get_strings(struct net_device *dev, u32 stringset, u8 *data) > { > - switch(stringset) { > - case ETH_SS_STATS: > - memcpy(data, *b44_gstrings, sizeof(b44_gstrings)); Just remove the * or replace with an & - either is valid. The existing code is reading b44_gstrings[0] so overruns into the following strings. -- David > - break; > - } > + if (stringset != ETH_SS_STATS) > + return; > + > + for (int i = 0; i < ARRAY_SIZE(b44_gstrings); i++) > + ethtool_puts(&data, b44_gstrings[i]); > } > > static int b44_get_sset_count(struct net_device *dev, int sset)