Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2072640rdb; Mon, 9 Oct 2023 11:31:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFnzYfBQ7NS3n0oTBTzAz6vF7z5kfrIX9s5ExJtDUPzPi1J43Y8xqRHP9qNxGCj9hheNYi X-Received: by 2002:a05:6a20:8419:b0:161:2389:e34b with SMTP id c25-20020a056a20841900b001612389e34bmr18913062pzd.13.1696876277611; Mon, 09 Oct 2023 11:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876277; cv=none; d=google.com; s=arc-20160816; b=tsHKYCwA+Uxil0pk1hJWbSfp8at5X6TYBRPM0Br9FWjQe7JBuUv1YolBXCa/tGBCou 4PK06W+rTPyz1NyXm2XDwFBlAUWh9xOZ2FMR+rcfe8pZ6Ui61OpVwhQNwc7FxV9ZwImz eAPxBeNWNZKMQUlSTsVUkMp1kd4poHYN5ISTtDV49i13l9uiEjVh+wj0Gh1Ggbduttg9 mKZw48mhLCBkqauHzJZ3okUUo4qmXk9GZzRhMWs/I5Ablk/pVdvG9lG88G+8CE2HqI5m 3ZQUzkUkDhexOQij8dscElyICEqoz7sC90O2n8BlLeDKcdt5nCTBHcK4p3nBn2tvn6Fl 1gIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b4YLGGXbrrLjvb4zCyI7F1AlXVbYIpxU4ak6ei/Asfk=; fh=9jsy8AbJvGuLuRkVPwhOjX5rocIcnUak6lkzc/Cn27k=; b=w8hGAr8Keml9tO1wwf0lirI+g3LUE7ARcr8uITPaI9JxdnJ8J/1nkANFkkdHHA3kcN TfGd03zX8CJZ1HD0Q/YZ2Ay3oxi6rn/BQyAzRAeXUo0Ibiog2VwsbqKTiJP6zILUq5YB mGNoLVGdra51Oz/QtO+fkeKyq7XWzb9QR7G19+11YtPhIz9gYP2NyVuFsMl1jifZP5DG xLLyq8z8oIus4OaQKzI5Cfj6V2u9lZ5T0+4Nw8zfa60ScUrlDDpNKJaGQI/ihvwBx00S Uc3IfNtbS7iQzPTUSljY2tjD1GqDp2b0L75vNYGMsrCZNLpiLaPWKwHNkcobaOdrE0oN 2lfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aW6zBS3Q; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h8-20020a636c08000000b005775c7e503csi9572945pgc.116.2023.10.09.11.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:31:17 -0700 (PDT) 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=pass header.i=@chromium.org header.s=google header.b=aW6zBS3Q; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BBB1A8039550; Mon, 9 Oct 2023 11:31:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345624AbjJISbG (ORCPT + 99 others); Mon, 9 Oct 2023 14:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346647AbjJISbF (ORCPT ); Mon, 9 Oct 2023 14:31:05 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D549AC for ; Mon, 9 Oct 2023 11:31:04 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c88b46710bso22992875ad.1 for ; Mon, 09 Oct 2023 11:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696876264; x=1697481064; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=b4YLGGXbrrLjvb4zCyI7F1AlXVbYIpxU4ak6ei/Asfk=; b=aW6zBS3QsW3eQpvI/D8FWHWl8BlNQeMCdQsgvlPEGOiIKeSx51PKH9F2h2D+o2ZPki SEG8VU9xYj8OlT+88GAYWnaM35NNq4xgCyF+zHrqZb4eMvrn36tvQhWElge892sKS/TT 9/NcULfgX9BU+eNyf1VTxfst2QmCmEN2GiISg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876264; x=1697481064; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=b4YLGGXbrrLjvb4zCyI7F1AlXVbYIpxU4ak6ei/Asfk=; b=S+YC+3K56psatE0wXw54IQEZz8QFZIchBCaK4jOdCBvmCikCKYvGGTn0xBnvsCSoHy Vmxx5s06tRIt93IdYmqHtlevIQVfBzRDfzXICCVibdnki/kfSXCO3PiCYqwTxcO9LME6 RjTIwwzHah6Gkvf4SpkjFnPFaEiGD+K4JXF2hY6V6MnZSmj69NWI/J8Awvs9cn3cGQNg UNipqiXiDkM37yXGLC9ZaB0TVxh2I0pf76Tsy/OiGhXaI98Jpyi17EtqP1vHpwX0K96d 4uumLk04rpCrdzNfDwuHQUxmMUMUqJm/USReyfbDs5vavYt5bZw12KLZiTFRtoklM0OJ JyGw== X-Gm-Message-State: AOJu0Yz2hcb5EOIeHPVnUb/V5T7bY7yeUOQQ511mMX1MtqOrGIGPR3hA J75xFTX7owD3WyMn4Jjc8iKOrg== X-Received: by 2002:a17:902:7084:b0:1b6:649b:92cc with SMTP id z4-20020a170902708400b001b6649b92ccmr11607238plk.69.1696876263974; Mon, 09 Oct 2023 11:31:03 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id a21-20020a170902ee9500b001c5fc291ef9sm184216pld.209.2023.10.09.11.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:31:03 -0700 (PDT) Date: Mon, 9 Oct 2023 11:31:00 -0700 From: Kees Cook To: Justin Stitt Cc: =?utf-8?B?QXLEsW7DpyDDnE5BTA==?= , Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] net: dsa: mt7530: replace deprecated strncpy with ethtool_sprintf Message-ID: <202310091130.D951BA0A6@keescook> References: <20231009-strncpy-drivers-net-dsa-mt7530-c-v1-1-ec6677a6436a@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231009-strncpy-drivers-net-dsa-mt7530-c-v1-1-ec6677a6436a@google.com> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Mon, 09 Oct 2023 11:31:14 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 09, 2023 at 06:29:19PM +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. > > ethtool_sprintf() is designed specifically for get_strings() usage. > Let's replace strncpy in favor of this more robust and easier to > understand interface. > > 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 Looks correct to me. Reviewed-by: Kees Cook -- Kees Cook