Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4185204rdb; Mon, 11 Dec 2023 11:12:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7WPzWP2DFQXfZPvt5PLFA8wdiIS4n1Zv4IIVv58YRKJGuLutJEGndVDl9RohrrTs/f95O X-Received: by 2002:a05:6a20:3b29:b0:190:f53:210c with SMTP id c41-20020a056a203b2900b001900f53210cmr5027609pzh.6.1702321926775; Mon, 11 Dec 2023 11:12:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702321926; cv=none; d=google.com; s=arc-20160816; b=eTIYQCbk8iLwN3vzBKzt4pg5NwrNxwzmk9F+88iGWsyLspVNBPgZoAdnre7D4YUhu+ KxgEB4/E2Ny7iFzOtMjubkwTQUPTB3/AZ0DcvnWO50JN0syhFcBRupKaakNWVC7z3UcV 9OH5/AHl4mW/QsP1YHdC37gXQsyiWV9bcLWecGjwh/6Ee+Vun4r2pMYFldxWa14igJZ0 FdyPJiw1IwyTHRJC65z0R7fQZBNBYPORI2JhxsGhGWx7XA0k73LBhtqTV2fyS1MDNnUH 9Qj0HagtGb801bJOXZBjggIGczK+dyaO+tX0RMBvLjO+DWQK2ajoUO6wrl0fA3tQdBMX CfTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=53+GQ9DSChkfFqfGSXLQ0QMyql+oTK4NA8OXD5BIsZM=; fh=DLSFRjUQxFVmQMxXi1vjociVisaz46WFvJEyc5nqUH8=; b=nkn1W6LshkNB1LI7GPv83uMnGsgA/M7tGEgHhxmNRyXlb5GYJiP/pEZxXd2JVm+KFP HxzOkgfpKZ6c17x3ax3LE5HyyUgBCp2MpIvicyvzclhEu3ZogqHJpjFIDHD5EB+j+9A5 Og5bwcICP3sXM0tT4ls15mOEcAFO75D2BerVWdsTt3Lp+cBGFn6cvok4sRgFWw41Chzo uqYPQmqsr7Voh+WAbAvYca8aly/PyHd8uXAqGXUBxOVpfGdjyu0RWlRvTzgjgN1WD/cu VD/MGSA0hRH9ElYZzh0UZ8Rc3nav7BQVpIEX5JPmFedBxsvEu2A2bgh7oj00Eshb5+Mx 6iOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aZWfVsi0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i1-20020a6551c1000000b005c279da45f1si6520065pgq.566.2023.12.11.11.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 11:12:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aZWfVsi0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 415AD80BEF18; Mon, 11 Dec 2023 11:12:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344367AbjLKTLg (ORCPT + 99 others); Mon, 11 Dec 2023 14:11:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjLKTLe (ORCPT ); Mon, 11 Dec 2023 14:11:34 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 988D0DB for ; Mon, 11 Dec 2023 11:11:39 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-54c9116d05fso6745712a12.3 for ; Mon, 11 Dec 2023 11:11:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702321898; x=1702926698; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=53+GQ9DSChkfFqfGSXLQ0QMyql+oTK4NA8OXD5BIsZM=; b=aZWfVsi0nhc27jgWVTLOn5u5JI7n/FejXbGaYxrlG9ZYP57iGMBuWw/3c+6ABQFN0t /IIap0t111JzD/rBOv574CoJefv9C4xr8851F9HnUkwWVjUmTAwmFx2GiYCtyqw01iPN 1yaEqSA5Fr5cxOf0XOJ2QqlDYbutU+J2+IZkGocCN37wwRwB/bJQoXVf3bGixpPidEQz PugIscb+bt7JblMgLidAqvJ5QB3veg9Xui3L8wo51+zgEfdzKZtIw/m5OsMKUkDL0eRD ni3eOEFGGQnAnaN42P9hEodtgq+jPjnZXKH3yTewWCskzh8NPLed0HfDJP/AGD5UUNhm RBmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702321898; x=1702926698; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=53+GQ9DSChkfFqfGSXLQ0QMyql+oTK4NA8OXD5BIsZM=; b=XDCVm2Q2zg3bpDIgOFfsED66V5PYPkoNCMvtQl3dWmW+s1tiw3Ga7ytxFhV6yVTDAv kxytxIFDiid9L16sMZraaS61gy2QxEZicqL+bZWt2aO3TjIw9Hu2IFeeDp7v/m8ckW3R xINAQra8wXkV8QJ4YBFqFlev19st3ooizBBD8eTd6xOwyPG2eD/4xSmcU6bumecaah28 OP0NO9sZkFafUX+9J24gVA5HKM0D/phiD9WdNRK4pPxKsPvo+gQWRYuGtF2FFWdnEqOY KUpjiot9Ecvzhd6pYU1uFfEhIfFVBnOlhMG6Y+OQxe8fcPqBNZJ35BtkcIi/DjkLoU8h 5WDg== X-Gm-Message-State: AOJu0Yw8gmFEtGSueAJ/GabtZUoK/ERCt5/jPdkx5NY681EyLd5bbdjJ /m/Oc4YKnhVmMBGnBiYz3Khs55nLZyMJHCWrABYzfA== X-Received: by 2002:a17:906:c141:b0:a12:7a14:5355 with SMTP id dp1-20020a170906c14100b00a127a145355mr1440878ejc.39.1702321897853; Mon, 11 Dec 2023 11:11:37 -0800 (PST) MIME-Version: 1.0 References: <20231207-strncpy-drivers-net-mdio-mdio-gpio-c-v2-1-c28d52dd3dfe@google.com> In-Reply-To: From: Justin Stitt Date: Mon, 11 Dec 2023 11:11:25 -0800 Message-ID: Subject: Re: [PATCH v2] net: mdio-gpio: replace deprecated strncpy with strscpy To: "Russell King (Oracle)" Cc: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, 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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 11:12:04 -0800 (PST) On Thu, Dec 7, 2023 at 2:57=E2=80=AFPM Russell King (Oracle) wrote: > > On Thu, Dec 07, 2023 at 09:54:31PM +0000, Justin Stitt wrote: > > We expect new_bus->id to be NUL-terminated but not NUL-padded based on > > its prior assignment through snprintf: > > | snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id); > > > > We can also use sizeof() instead of a length macro as this more closely > > ties the maximum buffer size to the destination buffer. > > Honestly, this looks machine generated and unreviewed by the submitter, > because... > Not machine generated. Was just trying to keep my change as small as possible towards the goal of replacing strncpy. However, you're right. It's literally the line right above it and now it looks inconsistent . > > if (bus_id !=3D -1) > > snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id)= ; > > else > > - strncpy(new_bus->id, "gpio", MII_BUS_ID_SIZE); > > + strscpy(new_bus->id, "gpio", sizeof(new_bus->id)); > > If there is an argument for not using MII_BUS_ID_SIZE in one place, > then the very same argument applies to snprintf(). If one place > changes the other also needs to be changed. > Gotcha, I've sent a [v3]. > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! [v3]: https://lore.kernel.org/all/20231211-strncpy-drivers-net-mdio-mdio-gp= io-c-v3-1-76dea53a1a52@google.com/ Thanks Justin