Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp51036rdg; Tue, 10 Oct 2023 04:07:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWCB2AULJ38FB5W2jRnHiLXssBK5v12qchYyi7d4pUJfWgSXQwfKrOjgjms+uL5FJpYagF X-Received: by 2002:a05:6808:29a:b0:3a7:39f6:3f2c with SMTP id z26-20020a056808029a00b003a739f63f2cmr20656270oic.55.1696936077857; Tue, 10 Oct 2023 04:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696936077; cv=none; d=google.com; s=arc-20160816; b=oCq30G6sCZGoxT5Rooyvu8M+VLnVF+9PL/rnqgPuCmNI50qj7/a0EjdeQCwaq4rBBv GzKybsIkuUWkgn7ocCRcEH2f3qtW8HHw4rboM4A9Mwf2wxEG/2GnHYGLz+3C0Bjk30aj rAA2s/ELJC/6nJKlz6ZcBaqF7/vb0hYfynwEfUql5HI0ByPXDjSk01D29jXfmeEtj7Ng zrfn3GAznaQSVcjDdI6bg9tMREcADc16lEGSAfEYqDvwXDtcLKtXW0geBG0//F9b68CY FZ+//Uke4E98n6nEz7MpSHKpHTkbEuWAO0ANLXKX1YTz9hjnSIda4WXy6IM0K8mQ3Xms g5gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SxYIKEiG6ukaTBM9h6qF8OGxEw0D7VZs6H4jG50DssU=; fh=3nnB/DuDsmknyVWLINLi5pk0CXHrcoS49Mj9/AnMnvU=; b=v1nQcAhAXlmNYgUUNNoWCvwHq9g3z3X69ac4xYpQE9yPhHyD9E3bL7b42b+xprQ+Bi 3tcaew4fUurxUuqEAS38aONu3fVTauKVKOcz08cZEqjdRaBzJdPIv9s+EHj+RaOFpUs2 JXHD2nE3TY+VU462cUv5DWJG02yY7h0M4Rmcy7FOuhaZYlz8ce7sq5WA2OnYYNnbs49j txnY0PanFKifyj1fjtsRWi11xTvdBrjVfnXNKlaSwSHJrUcm07qOahhFjayHUfKVzmex XeVe0ZVWcW5jvHQsLs/qbGj0Hv8b70vfSz+4NHbOWakBRZ37TAUIRPZalevyiLWLuaxO tyrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eoJf6tFt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id j2-20020a655582000000b00584ca25959csi11686936pgs.540.2023.10.10.04.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 04:07:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eoJf6tFt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id DC3F58082049; Tue, 10 Oct 2023 04:07:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231259AbjJJLHZ (ORCPT + 99 others); Tue, 10 Oct 2023 07:07:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbjJJLHX (ORCPT ); Tue, 10 Oct 2023 07:07:23 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16C08A9; Tue, 10 Oct 2023 04:07:22 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-99bdcade7fbso940582766b.1; Tue, 10 Oct 2023 04:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696936040; x=1697540840; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SxYIKEiG6ukaTBM9h6qF8OGxEw0D7VZs6H4jG50DssU=; b=eoJf6tFtZqhePcDy6q0d4h3tciGtJOmudphCy5GcYPJRDfqYSYdik4Fn+sAcleP+1u aLTBu2QQ0TT79yvsYZZd3mDeeXBpApt4bKFpXe4CyMwCdVXDvIv4a7Mbeo5Dp6JihBsW RBVv6y7LTTa741kT0B3Fof/JkQ8GHX7Pk6FswPSQaq4kPZrZKTO5x5nEo6Nc4YLQU40B CSJf3FNB/ydgs8xaUtSo9dpnrho4Aq3sTmF+jXtFVfHwZ295n/CqdjYVRqoru6wUlrSo xC2k+tSrF9gax4VzZZEKwNxy7UK1Kqx34H8xYRItcxZPBuGbEdoCFvFo5KwDaKa1k81s nYSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696936040; x=1697540840; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SxYIKEiG6ukaTBM9h6qF8OGxEw0D7VZs6H4jG50DssU=; b=Lmlo27cFBZl0pB6qRcuXRlrIo377ToTB1mQ78Qv4omBnRFiVCCXD67qhHeTNcArIP9 q95Blqvc1esNh8bDL5zfvoObccPkMbixNgdc6W3mzpcSfa0XH15mhRD4oYmCOgXbzxBC xxj83FYla0bg6i10RWRU+udgVmuA0P3vhhhOM/Nrqc/QgD/whvVeuviOAL7Gh/O39iN2 sPZ55o49U+hDHfWY6ruDLdUN474j7GrfTr0l0B7Erhm75jhuLck+5SmakeqzvjkRxkCQ SSx/etOb0JO0RIIiHQQlWcHsZUYitqEH5t/j4BVdC01Rz/BNSDa6GazgkXCKXbfg44Ay hi4Q== X-Gm-Message-State: AOJu0YzzvobmPYx9sCxfFIoLORHzaSl0KcV3TOdPEGZ3jzZOzWD5JGrL naSJKpF6LzxyAHUc5D5lq10= X-Received: by 2002:a17:906:156:b0:9a6:4f54:1da6 with SMTP id 22-20020a170906015600b009a64f541da6mr16623638ejh.57.1696936040293; Tue, 10 Oct 2023 04:07:20 -0700 (PDT) Received: from skbuf ([188.26.57.160]) by smtp.gmail.com with ESMTPSA id l12-20020a170906230c00b009920e9a3a73sm8277193eja.115.2023.10.10.04.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 04:07:20 -0700 (PDT) Date: Tue, 10 Oct 2023 14:07:17 +0300 From: Vladimir Oltean To: Justin Stitt Cc: Linus Walleij , Alvin =?utf-8?Q?=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] net: dsa: realtek: rtl8365mb: replace deprecated strncpy with ethtool_sprintf Message-ID: <20231010110717.cw5sqxm5mlzyi2rq@skbuf> References: <20231009-strncpy-drivers-net-dsa-realtek-rtl8365mb-c-v1-1-0537fe9fb08c@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231009-strncpy-drivers-net-dsa-realtek-rtl8365mb-c-v1-1-0537fe9fb08c@google.com> X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 10 Oct 2023 04:07:50 -0700 (PDT) X-Spam-Level: ** Hello Justin, On Mon, Oct 09, 2023 at 10:43:59PM +0000, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > ethtool_sprintf() is designed specifically for get_strings() usage. > Let's replace strncpy in favor of this more robust and easier to > understand interface. > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Justin Stitt > --- > Note: build-tested only. > --- > drivers/net/dsa/realtek/rtl8365mb.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c > index 41ea3b5a42b1..d171c18dd354 100644 > --- a/drivers/net/dsa/realtek/rtl8365mb.c > +++ b/drivers/net/dsa/realtek/rtl8365mb.c > @@ -1303,8 +1303,7 @@ static void rtl8365mb_get_strings(struct dsa_switch *ds, int port, u32 stringset > > for (i = 0; i < RTL8365MB_MIB_END; i++) { > struct rtl8365mb_mib_counter *mib = &rtl8365mb_mib_counters[i]; > - > - strncpy(data + i * ETH_GSTRING_LEN, mib->name, ETH_GSTRING_LEN); > + ethtool_sprintf(&data, "%s", mib->name); Is there any particular reason why you opted for the "%s" printf format specifier when you could have simply given mib->name as the single argument? This comment applies to all the ethtool_sprintf() patches you've submitted.