Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1987522rdb; Thu, 7 Dec 2023 14:57:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBNttixn1xIj3HLQF0AdCS6hKlPVxE1l0B2PS1jJAjtoN3BQKwlgmLz82T+9AWU09RJqyt X-Received: by 2002:a05:6a20:2448:b0:18c:fc4:df13 with SMTP id t8-20020a056a20244800b0018c0fc4df13mr7766110pzc.27.1701989857864; Thu, 07 Dec 2023 14:57:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701989857; cv=none; d=google.com; s=arc-20160816; b=qjhHeKEs5vBrH/DevgVzk/v2UG9Xf0+zAOX0swvaRw73TEqBycUAyYbNDLcJN1pS9A 2dgkbV6rqQLp16kCtkSVGvsmwB0iB/RwhlbWMVYZ88eLAl6Q4MJryx1LjkPWIORjbAyl ko7xVK6oOuEO07lmcX7R+tv7kPMX3qtz48w75NTN0gWbRbw6TDAR1CuvzfPdXjDLg9vf 2vSO3nYd0JqmpKW7LkOMblpXfP0DiOqsrWLXb43eZKh5M62T2NPkxzl0voYZrWiLqZaW G0FbhuRnL2FVxnQYMvvPQ2ECncJf4bLLBXTiYw/jiqsOuQMxa7+iT2ehccSIxZ7RCesp ELbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=e9QlfSVQ0gZy3QbK9bpFVf9dp3zXzuooGWrQsidX1tw=; fh=kSsVuTXcgCUyumgus/PRudDBMn515ayi2kkWVp8Msg4=; b=sJ70yqAvChKG6RANyvJX4X2SUt+ka2ZhLr/J/9uQZxDT0A77FK0OD+Eddm3u5KhMQV O20ycq4WSld50IdyYxolQ4WzrIPzl0iKhD/GLrtx5xSHz2xcRE0ZaGqiribaRJ15FEeC OZ1Bk0KdHADChTjr3eIPMaanaV6wus1QcBNvDGRfynVNNDrEtar/kpjF4C6hMOI5hNSX +Gl3GKypey3HKaqBZfE+40O2QUhnJNzl9MHkEk5oHovDe+clnqpMoY3tS/B+OC94AG2O HogoOrKra+uwNkcAawpuKERlfd6KnjtAcfiWgAGPzpixhrQuU15Rir8OY6MsTcyRWEdw VjJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="J/9J1Z9e"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h14-20020a65638e000000b005c677224ca0si417657pgv.250.2023.12.07.14.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 14:57:37 -0800 (PST) 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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="J/9J1Z9e"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 69597816CBA7; Thu, 7 Dec 2023 14:57:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232477AbjLGW5V (ORCPT + 99 others); Thu, 7 Dec 2023 17:57:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232695AbjLGW5I (ORCPT ); Thu, 7 Dec 2023 17:57:08 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4812198C; Thu, 7 Dec 2023 14:57:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=e9QlfSVQ0gZy3QbK9bpFVf9dp3zXzuooGWrQsidX1tw=; b=J/9J1Z9e94VygRiQ0xxPn9Vy+A mRXXH8imkqLsqqEWTQMcjJPYDnyKNctzuIQ1jKFyT3fLAEc/cZnfgIFnZ9UFtG9DXfDs2Ds+Whvct ggxqcS4rwbiS8T6IYLfeWVUyk3gQL++sRVRMfqFsbSXZ9f5xtVFg7bh2UnKAxwPAXCxddlxrMfkjK 7bDv3CFy0quiiQZn2IEm5/QHUt3b1HcrD5hDnLWJKs5abwu40vhV8s3FYYTwT1D02wgk63Z6z7hhM B3D33sVdXuclRaHhnopgO1MXvj/xfl0akDmuJfVcp8zAKm3oLeTXg1gYw5Y73zK622TFyOV7OXYmr nmRQuJww==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:57030) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rBNIn-0001ka-1u; Thu, 07 Dec 2023 22:57:05 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rBNIo-00047T-K2; Thu, 07 Dec 2023 22:57:06 +0000 Date: Thu, 7 Dec 2023 22:57:06 +0000 From: "Russell King (Oracle)" To: Justin Stitt 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 Subject: Re: [PATCH v2] net: mdio-gpio: replace deprecated strncpy with strscpy Message-ID: References: <20231207-strncpy-drivers-net-mdio-mdio-gpio-c-v2-1-c28d52dd3dfe@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231207-strncpy-drivers-net-mdio-mdio-gpio-c-v2-1-c28d52dd3dfe@google.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Thu, 07 Dec 2023 14:57:35 -0800 (PST) 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... > if (bus_id != -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. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!