Message ID | 20231010-netdev-replace-strncpy-resend-as-series-v1-3-caf9f0f2f021@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp171989vqb; Tue, 10 Oct 2023 15:28:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3NtVAoOZmpFBRlXrxBgyvlo0OP8kdxS2tGoJ+FwullbIXZCIdmSXhD8zXxjXAhDSezWAl X-Received: by 2002:a05:6a20:daa8:b0:171:947f:465b with SMTP id iy40-20020a056a20daa800b00171947f465bmr4540426pzb.4.1696976880401; Tue, 10 Oct 2023 15:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696976880; cv=none; d=google.com; s=arc-20160816; b=XwFaWznQwXfwtqNoxDRx1NNPoNynUB7P3n0WqT9jZOTNzK4U36jHRCZ/w2CXGmku5U Aqd8PJSv3ako2f9DFpoRm5cUuNa78Y6LJmiBJoCePUm7ITigA7J5ihRaHpc/42amiP0P PZd7Bpfzd1sAQElakq02m2DfokKDJAf/nroBcxRB3JzCPp6hd1bM0jU009GCc8s3FdeO tWOTen1JKcTz0qU2TgtnvRmNL9JF+Sf0WD4FXERgkVmzrFYN8gURBKbvohKqj+q2xmiG nrXlsVC6S9VRoH2Lkz9edIBvX6vHP9U7b6M37CAwByfBaX+MtLfeOiKlR43hjwMpkK/n 6V2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=lTnwaqL2jLBaxkmW2WMaRMaHCldHf8+/MXLc/TIFT4c=; fh=jBrXfr1CofwHzdCs7t+hNw/6P+fbZjn/vMCgpWmT8zI=; b=Va2MLA4F4JxMeqAL1BALSU2mSsf5uEu7DBmFRwePOxptZV027Kov2qrvqRSmSKk0eT Uub5spNcp52YhEapbj50xPkGoSzpY9fxKkuxH2B9V9FAU9C/+dcpgt+GFtTZMOnwWpM6 +IvUeXN4yje7P+udCiLQts8PXKu+uk6R7xhRooTo2Fl1YoD5ziOIvdOZ6RH9k3RCxZSe FyK03aVlGkj5UQe/0tgJRyYJxbi16MyV3F5IaXgc/AT0Hhht/ysTXPwJxE+ywSNiIhww 6CM6deq6v3o6sLgLHm9NdTxB9w0slOs8gRep7OwkFzcVcsdgs2v0GjTGLGOFPH5aQsdA sFcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HaXYx2MH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bv10-20020a632e0a000000b005852a35afeesi12503629pgb.186.2023.10.10.15.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 15:28:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HaXYx2MH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 557D883B81B6; Tue, 10 Oct 2023 15:27:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231358AbjJJW1Z (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Tue, 10 Oct 2023 18:27:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234711AbjJJW1M (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 10 Oct 2023 18:27:12 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6291A10F for <linux-kernel@vger.kernel.org>; Tue, 10 Oct 2023 15:27:10 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d918aef0d0dso8654246276.3 for <linux-kernel@vger.kernel.org>; Tue, 10 Oct 2023 15:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696976829; x=1697581629; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lTnwaqL2jLBaxkmW2WMaRMaHCldHf8+/MXLc/TIFT4c=; b=HaXYx2MHjD9Ln9m2JeqtU5jOiYeAa5LVO/a7+aRBVUcBVGti0k/pnWDJrS9TTGt2Eb 6jyB2MOw64gG1EYLLODJlEbdJjJdGmi2CHrTsgq/BLUfmI/EDeIJBVhNGh+jNDv3T7wf scwzc1yNRQTAwBs57Gp2roWdL4onWVEWuSOewIzmQu1B7vzmo0DGtnCrwJQOgxJ2w/Rz kLdy972tJFimWH4+R8sAdPUkghl/fnPLdEOESBTXoHNRGSBvmUY4sPEDU97CyiWGqEqk 55KUWlw1/KLqaqghQWvvD+TV/NCnxFP6GsVt9p1mzr6Kj9PKuklNiazCRy6BoZ52+GST jtwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696976829; x=1697581629; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lTnwaqL2jLBaxkmW2WMaRMaHCldHf8+/MXLc/TIFT4c=; b=iK4p3zm1VxsxLt3fax6F/RAhOt3BPMMGYQw7FzHwBc8gSt1eG2kXTHC8Hq+GM3OUQ4 gnDre137jMkAbyyAS6V8z+NtOyPAH0JNFNu2ucGjkd4iexMFxm/AVq3jT2pkiOyGGALU pQd40JtZZXqvOr225oqvCGpyJFpWaBsZNzdgSwwgVCWl2N9iemccDsm2YOEF5W6VcOk7 nC2m2DbBciJjesY9rLqvdAtnvfjc5nrQizPzTLZHg4ltIL5slTc5JMp9l1Eoz4DXiohd PDja9ALEHGbcgNsaDIc+JyylAPLPcc49Bp8HMhG+KRZViP6YhpqyKuofG/GTpg95dVO5 lKYA== X-Gm-Message-State: AOJu0YyvajgEmnF4MoQCkzT3fgwGVU+ax8gZeSGOOauyzBKatMrPuALP ywqqNkqbGloEOtaFA2FyKQjx3R18j4jT7Xb3JQ== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a25:9349:0:b0:d80:12c:d49b with SMTP id g9-20020a259349000000b00d80012cd49bmr352222ybo.8.1696976829556; Tue, 10 Oct 2023 15:27:09 -0700 (PDT) Date: Tue, 10 Oct 2023 22:26:56 +0000 In-Reply-To: <20231010-netdev-replace-strncpy-resend-as-series-v1-0-caf9f0f2f021@google.com> Mime-Version: 1.0 References: <20231010-netdev-replace-strncpy-resend-as-series-v1-0-caf9f0f2f021@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1696976825; l=2155; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=OVZJsM7ldFpBAzherL0f3bvpgvacQBDrwKwi/3HnF5o=; b=VAP1FhD196P2wXpYtHTj+oub2FKXyLs035gJ11JD9BWHTobZWE7G6hG6hva6AMypTOMJugLLr iU1NTx0gyFVACLLcwaYcZNUqVriQ4UPkUi7BGHg/1QJ/x1taOIyXHl8 X-Mailer: b4 0.12.3 Message-ID: <20231010-netdev-replace-strncpy-resend-as-series-v1-3-caf9f0f2f021@google.com> Subject: [PATCH v1 net-next 3/7] fm10k: replace deprecated strncpy with strscpy From: Justin Stitt <justinstitt@google.com> To: Jesse Brandeburg <jesse.brandeburg@intel.com>, Tony Nguyen <anthony.l.nguyen@intel.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: linux-hardening@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Justin Stitt <justinstitt@google.com> Content-Type: text/plain; charset="utf-8" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 10 Oct 2023 15:27:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779409229525129404 X-GMAIL-MSGID: 1779409229525129404 |
Series |
net: intel: replace deprecated strncpy uses
|
|
Commit Message
Justin Stitt
Oct. 10, 2023, 10:26 p.m. UTC
`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 <justinstitt@google.com>
---
Note: build-tested only.
---
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
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,