From patchwork Tue Oct 10 19:53:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 1847745 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=LWUAOGuY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S5zf04nFwz23jX for ; Fri, 13 Oct 2023 06:07:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1E18B60F26; Thu, 12 Oct 2023 19:07:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1E18B60F26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1697137621; bh=Hmjg//Lq1wzhld8sK6noicEIkbimGYR1RPKkkRVBCE0=; h=Date:From:To:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Cc:From; b=LWUAOGuYp3C0EQR/KsNLKVGoXz3j+4ITF4iscxZGGNtK2ZDpJY3ITUxjA5Jc588in PpDIxGDqocewmofpyY+uRiz+MgoinggSWAxVi+fkksB/N1uyNNtHbUBUjO5SRs/Law jaoEYlBKtEblKNRo3uVbOX7h5uMhlbgjHebALck9ODMwh4ce3MJWCAgpEUxdh7sujl 6lkGGzQVAvV0Wd3W0ONfrVPtW03c/yquoLPbpqPCYEuLSj8ha9W8mmKZCudkpeYkx4 wWUoEqIa2rTyPUE8FEyOIccYgddR6lGmTTuga6OEYzcWaC2YgflbC5evvJvz8DZWkL zqhBtxQB9Ydrg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HuQDrmz7c9ZA; Thu, 12 Oct 2023 19:06:58 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 830B461087; Thu, 12 Oct 2023 19:06:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 830B461087 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 995941BF2CD for ; Tue, 10 Oct 2023 19:53:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 7DC0860F1D for ; Tue, 10 Oct 2023 19:53:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7DC0860F1D X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mkOao4mF5JUE for ; Tue, 10 Oct 2023 19:53:34 +0000 (UTC) Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6A1AF60F05 for ; Tue, 10 Oct 2023 19:53:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6A1AF60F05 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d9a581346c4so1550017276.0 for ; Tue, 10 Oct 2023 12:53:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696967613; x=1697572413; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=w5E9MxIyYhKzMBpNRM6CeDwnSabl1YmaOv2YrvO7ZwA=; b=nV2sFlbqjieXF5tseL75dS+gmiEF1QvytAY44YTZcmr8VIczEmQ0xntmTbiBom18T8 0CSLXpHJcl2TtgUNyRuTVhSl3cYYV6xJRBuhNPwDn6/07gMhiJbtUEKSYkENW2H+fMlK ygUHycliyD5BFspG7jkDv3BcOUoDdAFggIpNzzHMfeqSHo42odLqw05MpgA6wzcCF7Iz osbu1ZPsXiaxorZCywrDV1D5bZgxh3imq6kuLStX9Mst4JcI3Ui8ySaqJjvX2/oLTlnt 3AexbJdI11Om0wGwbdCRBfOngFd8bVTHA5PtJCEGmTGbS03nGxxXxZBpM9y6oLHM7W/g 6HAA== X-Gm-Message-State: AOJu0YxCpURtleW6NEqH+0nemF+Meq+7s9IPq37e9E6QFeHn+Lb00iRT 3mmyT3Xd84AoxNmMXOhDV3rfWzUHrH1AqvfA+A== X-Google-Smtp-Source: AGHT+IFf+EcNSed1EvzahNf05j6H+bR8LMoGehNG9vtR75/usZMZPFVfBU6LyeUKu8sWdgNzGSviQJZCAAOpdfkScA== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a05:6902:85:b0:d86:5644:5d12 with SMTP id h5-20020a056902008500b00d8656445d12mr357348ybs.4.1696967613332; Tue, 10 Oct 2023 12:53:33 -0700 (PDT) Date: Tue, 10 Oct 2023 19:53:32 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIALurJWUC/yWNUQrCMBBEr1L224VsFRu8ikgp6cYu1qTshqKU3 t2oP8M8HsxsYKzCBpdmA+VVTHKqQIcGwjSkO6OMlaF17ZEcObSiKSxvHFVWVsPEBblMrN8iqfC M8Unu8c++qpLzjAE9+RMPXefPFKHOL8pRXr/r623fP2N/8+eKAAAA X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1696967612; l=2330; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=Kd8rwBEMi1NtM8y4ozGswyeCAqmu3EbqiQJnq7rYFR0=; b=OC+eT0HLH7q5dOLGigWF8Rx7ymgW1poduMQ2TkjiGHXmUxXOMiXpMWi9S1WtDr2E1QqE/23iD A1dqQ8QKh0RBofrRZ+itXkeKDgltYr22tc53NO8eW+Zm9I7v62Xp+fW X-Mailer: b4 0.12.3 Message-ID: <20231010-strncpy-drivers-net-ethernet-intel-fm10k-fm10k_ethtool-c-v1-1-dbdc4570c5a6@google.com> From: Justin Stitt To: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni X-Mailman-Approved-At: Thu, 12 Oct 2023 19:06:39 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696967613; x=1697572413; darn=lists.osuosl.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=w5E9MxIyYhKzMBpNRM6CeDwnSabl1YmaOv2YrvO7ZwA=; b=NLk6IHWV00amA+rvZ30f5toYoyX3/oNhE/YJZBkTuBC5T1oixpUXRnFDQeKY0vbWKU u6h93Iir4d3QMfD2zBnRtpenDb7DjKfTunQ7N+pswLMcU2u868i/J+mML6Y5TDJB9vHw yyTkgCCJN77bwUihYOIpqAMXoNT3GYuTBJm1u9M1XneENhmknsbhrzBpcLTtnwbOhovw LXWISwacDGyzqv2lLCAyCzATrhUQP3iUd1orY0FoDQswvIMtVEjLjWp4H5k31OEEZfsn 015gxHQFyhdfyRgjVn8Dg8AO3KCBCSzo6q4oMKeCYi4furoEXR+EAblLdO0Pxjq0Hq91 5wzA== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=NLk6IHWV Subject: [Intel-wired-lan] [PATCH] fm10k: replace deprecated strncpy with strscpy X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Justin Stitt , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" `strncpy` is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. A suitable replacement is `strscpy` [2] due to the fact that it guarantees NUL-termination on the destination buffer without unnecessarily NUL-padding. Other implementations of .*get_drvinfo also use strscpy so this patch brings fm10k_get_drvinfo in line as well: igb/igb_ethtool.c +851 static void igb_get_drvinfo(struct net_device *netdev, igbvf/ethtool.c 167:static void igbvf_get_drvinfo(struct net_device *netdev, i40e/i40e_ethtool.c 1999:static void i40e_get_drvinfo(struct net_device *netdev, e1000/e1000_ethtool.c 529:static void e1000_get_drvinfo(struct net_device *netdev, ixgbevf/ethtool.c 211:static void ixgbevf_get_drvinfo(struct net_device *netdev, 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/ethernet/intel/fm10k/fm10k_ethtool.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2 change-id: 20231010-strncpy-drivers-net-ethernet-intel-fm10k-fm10k_ethtool-c-8184ea77861f Best regards, -- Justin Stitt diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c index d53369e30040..13a05604dcc0 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c @@ -448,10 +448,10 @@ static void fm10k_get_drvinfo(struct net_device *dev, { struct fm10k_intfc *interface = netdev_priv(dev); - strncpy(info->driver, fm10k_driver_name, - sizeof(info->driver) - 1); - strncpy(info->bus_info, pci_name(interface->pdev), - sizeof(info->bus_info) - 1); + strscpy(info->driver, fm10k_driver_name, + sizeof(info->driver)); + strscpy(info->bus_info, pci_name(interface->pdev), + sizeof(info->bus_info)); } static void fm10k_get_pauseparam(struct net_device *dev,