Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4301911rdb; Mon, 11 Dec 2023 15:23:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMk8NrAp9mnuY2gc43li0hlmqEn93iFEcf5LQaLu4qRuhAbGzIlzs2FeJycioqUVmxMMdq X-Received: by 2002:a05:6a20:5648:b0:18c:a9d3:c363 with SMTP id is8-20020a056a20564800b0018ca9d3c363mr2555700pzc.41.1702337002851; Mon, 11 Dec 2023 15:23:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702337002; cv=none; d=google.com; s=arc-20160816; b=x7LVDXfUHVYrINxkU0DG/QdMwvjgxQ2PVa71tAyb3p/c57mteQ+AAXKZ/8MJNQ2JaJ jLO/R2y5bPRAQOoVx0WhE3VjopL5GQ5MwPQ/0Raw/IvGJyzINbcdPrvr9nqawsMEL9xK 99SBn8HxoQbbiIZ42+nAvnHH5/RmXJpW8ev7DyPqFw1V9c1oc4lGh1rHO7y31428ZPPF jql6y5tVNYcw8J+cNY3pURs8uLWR2QU5u5yu0/t3U4mO0snpdtikPksUvuiyC1oVbCVK 2PIIi2fZNcx7RKeC9qrUIUR5JRPWZM+2PO5800AhGhhhduBDCmFmc/1+V7lDtsdQbNAe gV1w== 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=jrCVMJHthbqeGM1aFmtvmFcFPoeI3AQf6oEdNuwB7Ek=; fh=kSsVuTXcgCUyumgus/PRudDBMn515ayi2kkWVp8Msg4=; b=kInmrHoQdehrmoP9FKK7VVbLYChyl2dYjF1XHbCBmEYl582m05R3vfWHWhpxOoHBHZ +ePYFb5nmi5hsq0ymFvd0GZGpNOuR7/9ezw/qfv/lxLyUO0GW+qARlC3DEEBXhq0NDnn VHt1Uf5Ljp1TtyXMQi+5/tny4N0OTDAWtxEKq4Rz71CtTkuKbYdEFtEZL3buroham00e f9dMHIyj/mp9XprIL5jxL/SvkMD+8xH7r7N4D/Qsby8GpANNh32n87HjQxaImB3EGd02 EdI9vYCJJ4NCFrkdCtAatfS4pSDWTFHeMxZj6lWzCvD64WzooRAvhMEOAyaBIEXKcxff 8Epw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=F6dnW5mB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id bh12-20020a170902a98c00b001cfc9c9f736si6733212plb.93.2023.12.11.15.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 15:23:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=F6dnW5mB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id B750A8079CB5; Mon, 11 Dec 2023 15:23:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345163AbjLKXXF (ORCPT + 99 others); Mon, 11 Dec 2023 18:23:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbjLKXXD (ORCPT ); Mon, 11 Dec 2023 18:23:03 -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 A6067CF; Mon, 11 Dec 2023 15:23:05 -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=jrCVMJHthbqeGM1aFmtvmFcFPoeI3AQf6oEdNuwB7Ek=; b=F6dnW5mBJVog++to6z1R9NmBkI jGfXAd1fYlZ+0hwwuh88UATilbj9bYLTK/P3djKdlQ7dcrqn2gACCuRUQ0KKzhyEugJD7bpsk3cza I+9F1h35IGE1cqRJbjZSIq1idA+iSmf+8lYIqjXwt0asHxsVX6S/QEt67byLyouTT4OGt3poyaGIE fXC0EyIGAYrghsjnAFUrA53htVG9t9pQEc/fmwFasz7HZMNeQjvT8PSjmtyMII5tnXI4sDS4wywxy lcX8jw4rBt4LhLYa+Kkdgfv8HK1lnwL5v7420WBa52wmr6y8AbgyUZzV8K3bP2yr45Oew+CqbjWFc zlflsvHA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:58904) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rCpby-00067g-33; Mon, 11 Dec 2023 23:22:55 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rCpbz-0008FZ-Pr; Mon, 11 Dec 2023 23:22:55 +0000 Date: Mon, 11 Dec 2023 23:22:55 +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 v3] net: mdio-gpio: replace deprecated strncpy with strscpy Message-ID: References: <20231211-strncpy-drivers-net-mdio-mdio-gpio-c-v3-1-76dea53a1a52@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231211-strncpy-drivers-net-mdio-mdio-gpio-c-v3-1-76dea53a1a52@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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 11 Dec 2023 15:23:19 -0800 (PST) On Mon, Dec 11, 2023 at 07:10:00PM +0000, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > 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); > > Due to this, a suitable replacement is `strscpy` [2] due to the fact > that it guarantees NUL-termination on the destination buffer without > unnecessarily NUL-padding. > > We can also use sizeof() instead of a length macro as this more closely > ties the maximum buffer size to the destination buffer. Do this for two > instances. > > 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 Reviewed-by: Russell King (Oracle) Thanks! -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!