Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp603741rdg; Thu, 12 Oct 2023 15:33:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCbHvEUbfRq2n+Oj79GZJz5O/9Np7SxMQqN4vwJwV05Lcq7veWcPEYZIJea3V/HOwcZeZ8 X-Received: by 2002:a05:6a00:391b:b0:690:3793:17e5 with SMTP id fh27-20020a056a00391b00b00690379317e5mr30996124pfb.4.1697150026337; Thu, 12 Oct 2023 15:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697150026; cv=none; d=google.com; s=arc-20160816; b=eaeQgel990JjDMnlLb8981BLWezEyWHp8jwPxy4NMyd9bgBe9IgdSmRGEQ/os62IIb vBjRahtr8OO+ReLRLCxA9wsJenwQWNXEfV+JDzcEc0F1l6D9+h03ID/q2Ru3UBhcNJOP hA0Gr3ZhWDPuh73eCCPGqErzAnQygM0zXpCpJpE07J7wMMHhnJIAkKZNYfkHyZ/UU0K9 f3NYZph2OuJh7eQfIE0Y1K52p3cehVe0B9WyKeqdJAAKFJgjQdUeecFC+GMSfY8k0ftN VAGAX8GHuVZRZgjr/bT27/S1je76RskvJWb58kmua2TY5k3Zpue2FznhXOhIUtuYsbQP hY9g== 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:mime-version:date :dkim-signature; bh=bMicK/Q5xy5Wa2FAFNQ3uoq4k2tHyYqo1F+SWUCF8nk=; fh=j3+ylVvqzVEHftj5sTE+bTBOtuU/9qyKQl/hLZIRnwc=; b=c2MeNUyi8jHZmhSleEhzW/vjG5P8ASxFpRidniiDARdcBq76FdRZD6gGU9tZ71KxAg fI/rJzn8gY0idCXpJvl5cXgAd4I3buJHNbTW+/DF1FBbAtBAfdoOU4JeicGtkd4D10hr k70aHOJbyjJ3THjH8lA256AEuqbcu7uw4p9xPuY+MJiml0qpL/oOV4LtaeHH1nDsByZM lSn40oqLToeVqwhi1iH/LiFjrZ096r+3gat3dqktthNQ3CodlaNM8cKwQ6hCspOdKInK RfYuhk4yq1AlN1HyHKJCbNLADyPIQJ38R2JQ2nS9razT56ggTgx9Ydq0HTmb4GN/7i+f QDlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YupFDCoJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id d17-20020a056a00199100b0068e29a05fa4si16116909pfl.326.2023.10.12.15.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 15:33:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YupFDCoJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 44DB282ECB22; Thu, 12 Oct 2023 15:33:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443001AbjJLWdj (ORCPT + 99 others); Thu, 12 Oct 2023 18:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344180AbjJLWdi (ORCPT ); Thu, 12 Oct 2023 18:33:38 -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 29068DD for ; Thu, 12 Oct 2023 15:33:36 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d9a3942461aso2110896276.2 for ; Thu, 12 Oct 2023 15:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697150015; x=1697754815; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=bMicK/Q5xy5Wa2FAFNQ3uoq4k2tHyYqo1F+SWUCF8nk=; b=YupFDCoJl/YjOA4Gw1wPmwXlSJDLi7RzOJAzPKRduQYqfu1wyyYpuAYM997B25pRwj lPiPxhNtHFbyvHPG6Mpk6QtzVtZMev1jKTEgPlqI32vxDcC+EH70szDzrER6VANc2mK8 NsMM2qLUDN+8zM40A0RxhZr7tEcNi5te/TNh5G7oN5o3ODp6m248El1Y1od0yHlXNSG/ hiPRLt88NukhlYPOhz6vkwXL8A9VzWKSutxDmYD0hQF7ZVhfMkVxWDV+MIvbDdOuaRYz Fp4Vuf2U6gBbndoEKFdJGXZEdEpoX+1fSvl3QnxJeBLLUnpgmPdY8PkVzA6E3xlPVGfo 919Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697150015; x=1697754815; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bMicK/Q5xy5Wa2FAFNQ3uoq4k2tHyYqo1F+SWUCF8nk=; b=fyUFSvbCmEY26yyxGdjlGQXTNIrhQrH3dho/HHwjJukHjMY7Abh8Sym8Gcl/Nr8MTp pscHBtMCi7bSBmjkxyzm9naHh0YlQKdfq2bKpwij54al//np71CXbrOSiS6xT2oIoK9Y OpGoA2sQW8auZthIghAXW3KlES18EP7FEWY9IYlGoF58r0NGK3aHNxWZeBqJ1uTB2ifP O+G3MCb52UfD91t3xGjwJdND0JM80iY8YE1CU2KAVpKYx1XyqOPGOEFrLqDYbEBTCRzi 0N8eNNPK+w+4blh5+Nrz8YukmVsO9ypyu2l9yFx+LNnrpxdmwXAx8sBBd1RMCLIvK3iC 5oCA== X-Gm-Message-State: AOJu0YxKdLwavrQd/cofV0GZTO3HETN81YrMfk7aQzU+na2CwSz9zRfK NKM2yWoH1TkZ8DlswGM42wW41e5wa351X5RTQQ== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a25:828c:0:b0:d9a:bc5a:737c with SMTP id r12-20020a25828c000000b00d9abc5a737cmr93260ybk.4.1697150015398; Thu, 12 Oct 2023 15:33:35 -0700 (PDT) Date: Thu, 12 Oct 2023 22:33:34 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAD10KGUC/x3NMQ6DMAxA0asgz7WUOEMoV0Ed2uCAlxTZFFFF3 J2I8S3/VzBWYYOhq6C8i8m3NPhHB2l5l5lRpmYgR8E7T2iblrT+cVLZWQ0Lb/izD5o+e+cwYeh z9JQo50jQMqtyluNejK/zvADLCQxHcgAAAA== X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1697150014; l=1997; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=1U/Iz4RqgIW06rmNmlXGTtLjP2+AJ5auEeXiBs7XZfQ=; b=brMk5Cj7eHq7rhc3oxxfK9fgzLcaoOEhVmgXPUsQEqJdbnaDQp+DNiJaosWeTFIN1Sj/ZHhsN dWoYta7Hsf0BJJ3Ttyiqah6k3lJtPK4DA+awnlETQMF5I19LrW2lFz5 X-Mailer: b4 0.12.3 Message-ID: <20231012-strncpy-drivers-net-usb-sr9800-c-v1-1-5540832c8ec2@google.com> Subject: [PATCH] net: usb: replace deprecated strncpy with strscpy From: Justin Stitt To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Justin Stitt Content-Type: text/plain; charset="utf-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 15:33:45 -0700 (PDT) strncpy() is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. Other implementations of .*get_drvinfo use strscpy so this patch brings sr_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. Found with: $ rg "strncpy\(" --- drivers/net/usb/sr9800.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c index f5e19f3ef6cd..143bd4ab160d 100644 --- a/drivers/net/usb/sr9800.c +++ b/drivers/net/usb/sr9800.c @@ -474,8 +474,8 @@ static void sr_get_drvinfo(struct net_device *net, { /* Inherit standard device info */ usbnet_get_drvinfo(net, info); - strncpy(info->driver, DRIVER_NAME, sizeof(info->driver)); - strncpy(info->version, DRIVER_VERSION, sizeof(info->version)); + strscpy(info->driver, DRIVER_NAME, sizeof(info->driver)); + strscpy(info->version, DRIVER_VERSION, sizeof(info->version)); } static u32 sr_get_link(struct net_device *net) --- base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2 change-id: 20231012-strncpy-drivers-net-usb-sr9800-c-38f712c2ff72 Best regards, -- Justin Stitt