Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1195447rdg; Fri, 13 Oct 2023 13:13:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYnhPA0IlsaxVa+o7Kt7FCJ97MB0+XE1iWxA7pzudmSrK+T1tORj4VX2pg7kEl/jqiTJ5h X-Received: by 2002:a05:6358:93a5:b0:14c:e2d3:fb29 with SMTP id h37-20020a05635893a500b0014ce2d3fb29mr32758332rwb.0.1697227998879; Fri, 13 Oct 2023 13:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697227998; cv=none; d=google.com; s=arc-20160816; b=JO2TSTe/1A1ZRHRCzWaQVIFrnQcrgUqArAc3cmXCKBTVpPOt0zLk7xAVADOQI72bSx b7PTbiYj6iGkBW8DLCJfnFrZsbiQjENp/iwfVmQQC9WUc9I4Jx1QX2dguOPDcxGriqiE scEzse02JjLmwyg0VoSAAMtxHsSv5JIJhJcrqPfxjKZ0L4Li5Sev3mc+BijtPdos3EGC PS4QFU+DgOxGM+hX03MXdHKsxawS8mwdTr9Et7ytiFI8YpNkNnBF7Os2Jql4QUkOR3UG hJnza1Pt72NC4dpmBjPgJMHUDXGNo5O8Q07wBSONTgwsqQS1V5k0w8tBl6jLBeJhagjb gRZQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=L87ipk/XEXKtmEMbuP/TQA9pUzG48gkBb6cfivxpP9A=; fh=PTyEvRDa58K05ZSVuqc5EC4KkpA14i62H06BKuSTXbY=; b=SKgnaqd69RAsv2gjqmkMJp4Wm+vGFU1mK7fJMJllVt4PiG6SgLrq1j7D+ir/xInCmE yq/0x4LZ1dlMNag1v5A2gLV7pMPCC6IBOy3hs/5o0EbezTmzw2u+m4lItPfgcmBI0g9O tp5MoU2vby4NqieF+aQ7y/eO8SKO3R5To93APl7/Avscl3VXT5pxvK2ityWOA6lKDGGb vhnNeTnEKbVhY3omuQfzsygDqXaLFmUgZ5D5rCi4JAVewKrRyDXSoibvU3bhTI4Fb0+c 2TVXwIxpFGKlsho3MttJBYcd2kylO7ZTEPaC+STFA9LTw435nQWYODwUkOdGOugyQgFM 9xzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=t08lQ0j+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h15-20020a056a00218f00b00690b8833ccbsi3819375pfi.270.2023.10.13.13.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 13:13:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=t08lQ0j+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9F6B6835FD2E; Fri, 13 Oct 2023 13:13:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231880AbjJMUNJ (ORCPT + 99 others); Fri, 13 Oct 2023 16:13:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231707AbjJMUNJ (ORCPT ); Fri, 13 Oct 2023 16:13:09 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD04EB7; Fri, 13 Oct 2023 13:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Transfer-Encoding:Content-Disposition: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:From: Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Content-Disposition: In-Reply-To:References; bh=L87ipk/XEXKtmEMbuP/TQA9pUzG48gkBb6cfivxpP9A=; b=t0 8lQ0j+j4YvxeAkASSJaGG2sOnEb6XNrauv5v6mHcTH/qPg9ykCUMFoLrijCkWn5nyjEdAwWSfDnED Earf0uBF36bLy6wfUE7KE3h0H5kakPHys71PpksHLeRiOOOIv8JOZ2Z9XiGNk/D1HH6plZPcYDMCt kJkj7cYglKkxV68=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1qrOWm-00284c-ME; Fri, 13 Oct 2023 22:12:56 +0200 Date: Fri, 13 Oct 2023 22:12:56 +0200 From: Andrew Lunn To: Justin Stitt Cc: Heiner Kallweit , Russell King , "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: phy: tja11xx: replace deprecated strncpy with ethtool_sprintf Message-ID: <0c401bcb-70a8-47a5-bca0-0b9e8e0439a8@lunn.ch> References: <20231012-strncpy-drivers-net-phy-nxp-tja11xx-c-v1-1-5ad6c9dff5c4@google.com> <15af4bc4-2066-44bc-8d2e-839ff3945663@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 13 Oct 2023 13:13:16 -0700 (PDT) On Fri, Oct 13, 2023 at 12:53:53PM -0700, Justin Stitt wrote: > On Fri, Oct 13, 2023 at 5:22 AM Andrew Lunn wrote: > > > > > - for (i = 0; i < ARRAY_SIZE(tja11xx_hw_stats); i++) { > > > - strncpy(data + i * ETH_GSTRING_LEN, > > > - tja11xx_hw_stats[i].string, ETH_GSTRING_LEN); > > > - } > > > + for (i = 0; i < ARRAY_SIZE(tja11xx_hw_stats); i++) > > > + ethtool_sprintf(&data, "%s", tja11xx_hw_stats[i].string); > > > } > > > > I assume you are using "%s" because tja11xx_hw_stats[i].string cannot > > be trusted as a format string? Is this indicating we need an > > ethtool_puts() ? > > Indeed, it would trigger a -Wformat-security warning. > > An ethtool_puts() would be useful for this situation. Hi Justin hyperv/netvsc_drv.c: ethtool_sprintf(&p, netvsc_stats[i].name); hyperv/netvsc_drv.c: ethtool_sprintf(&p, vf_stats[i].name); ethernet/intel/i40e/i40e_ethtool.c: ethtool_sprintf(&p, i40e_gstrings_priv_flags[i].flag_string); ethernet/intel/i40e/i40e_ethtool.c: ethtool_sprintf(&p, i40e_gl_gstrings_priv_flags[i].flag_string); ethernet/intel/ice/ice_ethtool.c: ethtool_sprintf(&p, ice_gstrings_priv_flags[i].name); ethernet/intel/igc/igc_ethtool.c: ethtool_sprintf(&p, igc_gstrings_stats[i].stat_string); ethernet/intel/ixgbe/ixgbe_ethtool.c: ethtool_sprintf(&p, ixgbe_gstrings_test[i]); ethernet/netronome/nfp/nfp_net_ethtool.c: ethtool_sprintf(&data, nfp_self_test[i].name); ethernet/netronome/nfp/nfp_net_ethtool.c: ethtool_sprintf(&data, nfp_net_et_stats[i + swap_off].name); ethernet/netronome/nfp/nfp_net_ethtool.c: ethtool_sprintf(&data, nfp_net_et_stats[i - swap_off].name); ethernet/netronome/nfp/nfp_net_ethtool.c: ethtool_sprintf(&data, nfp_net_et_stats[i].name); ethernet/fungible/funeth/funeth_ethtool.c: ethtool_sprintf(&p, txq_stat_names[j]); ethernet/fungible/funeth/funeth_ethtool.c: ethtool_sprintf(&p, xdpq_stat_names[j]); ethernet/fungible/funeth/funeth_ethtool.c: ethtool_sprintf(&p, rxq_stat_names[j]); ethernet/fungible/funeth/funeth_ethtool.c: ethtool_sprintf(&p, tls_stat_names[j]); ethernet/amazon/ena/ena_ethtool.c: ethtool_sprintf(&data, ena_stats->name); ethernet/amazon/ena/ena_ethtool.c: ethtool_sprintf(&data, ena_stats->name); ethernet/brocade/bna/bnad_ethtool.c: ethtool_sprintf(&string, bnad_net_stats_strings[i]); ethernet/pensando/ionic/ionic_stats.c: ethtool_sprintf(buf, ionic_lif_stats_desc[i].name); ethernet/pensando/ionic/ionic_stats.c: ethtool_sprintf(buf, ionic_port_stats_desc[i].name); ethernet/hisilicon/hns/hns_dsaf_gmac.c: ethtool_sprintf(&buff, g_gmac_stats_string[i].desc); ethernet/hisilicon/hns/hns_dsaf_xgmac.c: ethtool_sprintf(&buff, g_xgmac_stats_string[i].desc); vmxnet3/vmxnet3_ethtool.c: ethtool_sprintf(&buf, vmxnet3_tq_dev_stats[i].desc); vmxnet3/vmxnet3_ethtool.c: ethtool_sprintf(&buf, vmxnet3_tq_driver_stats[i].desc); vmxnet3/vmxnet3_ethtool.c: ethtool_sprintf(&buf, vmxnet3_rq_dev_stats[i].desc); vmxnet3/vmxnet3_ethtool.c: ethtool_sprintf(&buf, vmxnet3_rq_driver_stats[i].desc); vmxnet3/vmxnet3_ethtool.c: ethtool_sprintf(&buf, vmxnet3_global_stats[i].desc); It looks like there are enough potential users to justify adding it. Do you have the time and patience? Andrew