Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp332210rdb; Thu, 5 Oct 2023 07:18:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1Na61T7hL1upj73oiU25LPpXnMClKIY9uK9k3jHOzaVBer2wTlKCSUoy6WO9VRBHhNO7g X-Received: by 2002:a05:6a21:66c7:b0:157:609f:6012 with SMTP id ze7-20020a056a2166c700b00157609f6012mr4944872pzb.61.1696515513748; Thu, 05 Oct 2023 07:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696515513; cv=none; d=google.com; s=arc-20160816; b=0BToIEGG9prX2kHGs9niMWXGag/gYjjVXHGyxPhRv9ur/u7m+vH9kK4+nJwDZu1DLQ G3oM4QbicluZ8oekALqsFJSgJFWxVdVJpJgVD40KPA4Fvr86zQSLKyjg5Bs17j00vpZH Uvonyn31cLgUZsVn5EUWF79hB20thOUat1kYQa9hME1ZYeAOLA0vbT5hOe9jmGCBUybT 2OvZPEyZ2C5bJko9YaEW0RkoDiPJqmVk2McOhd2CsnaiMjmg8LXvzogV6RCs5ZxzOsxU Ultr7cMFy4Y/XDbIJ02TaVfHzRouI3Gzf68m5YHqdNBJNIK/O+TsCR6zA9+hBWQumLF1 5o2w== 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=/+mWck7v12QS9sMNcIP6ZElr659qVny5ZQ2Hl7zbZIk=; fh=TAvN6hRv4AcaMSip5vZoXrzHYey+fZNBmRR6BlDPK4c=; b=lcy8fHiFyhv0dbaol3vQ67WiYc/geDIja49Q5PFuJkquednCboEmXGNjdZtbQh1xvp NL8rkaR7ciB5DdZMM7o5ex1xsrEFABVvfkmaMVLYbADp6r/RLcLuPlcn2HaUErfrIju6 TW7pubVD/1Q5iO92qmlOwsIfIlRgkxLerW0Ku+YmukD+G16nlwug+N9OISpzSDh3VDW0 iPm/nj7dxVMNgCBoeJCKh7n4pcW6hQqt3Llz+GFDDmJJ+o/IIIWW+zlr4ZlJEQ5Buybc mFidiKm6MjojukS4K/du3Ho8FPWQ7dO6fDH8WDCV+XoO9ccVZ66A16nRjnJucPjDIAoh rE1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=la73IPiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id c17-20020a056a000ad100b0068e29a05fa4si1488705pfl.326.2023.10.05.07.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=la73IPiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 7FDAE82C5178; Thu, 5 Oct 2023 07:18:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231686AbjJEORy (ORCPT + 99 others); Thu, 5 Oct 2023 10:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbjJEOP4 (ORCPT ); Thu, 5 Oct 2023 10:15:56 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE0204681 for ; Wed, 4 Oct 2023 21:53:15 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c60a514f3aso4233785ad.3 for ; Wed, 04 Oct 2023 21:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696481595; x=1697086395; 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=/+mWck7v12QS9sMNcIP6ZElr659qVny5ZQ2Hl7zbZIk=; b=la73IPiEFerrxyzwhklqTVr+a1cq4pxLymhtfuWrtn5PlnCjacz45UMFnHrhj+ORSS 77/MliBxqE5qgx47BkMrKB6kn+JTKLtT32fGjnj5Q9bz8G70m4VBEKj7/lUrqABox6eK BefEvdC2uh+EQ+k1BMq/oh6bvA4/oCep80Vjw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696481595; x=1697086395; 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=/+mWck7v12QS9sMNcIP6ZElr659qVny5ZQ2Hl7zbZIk=; b=JhebmyL+uAaBC6Sa6Vu6MtEOa1gbFZMr5VzQumWzRuScCokoAmmgN1xo0gIHcjpwDM E+2eZW1E6cFAxINNIb4nmi1uSletELmvs2w+S1HAKB/+Z7NDWh9X3GFEtnNB21qH4/PY trldfKUQVetqhjlPrpL3bAup+QxbFyOxJVNtWqRG4mIfBgPg4LPIm7NGqwQU+wTG7yqU FaqgYZUkrkwacNERGv8i4gKqQA7+rja5aD5zAuFL6akI7UwSFbAyEqIam0+ATgYbxoyz QYF53OpsPG1Wl6i4gKGDS5jOl4kByV/erWQNTNvIaL0OeQ+4FMyZtzDZo2uqRiGIIGBs 5lGA== X-Gm-Message-State: AOJu0YwsEsHeUC3vOigHVCjj6CopjKuvMTnnn7iYdEMTJMkbTsi+w3do wg84K7aEvBvArJ3rc1To7XtxEw== X-Received: by 2002:a17:903:1c1:b0:1c0:c4be:62ca with SMTP id e1-20020a17090301c100b001c0c4be62camr4316265plh.17.1696481595327; Wed, 04 Oct 2023 21:53:15 -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 n14-20020a170902d2ce00b001bf52834696sm486823plc.207.2023.10.04.21.53.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 21:53:14 -0700 (PDT) Date: Wed, 4 Oct 2023 21:53:13 -0700 From: Kees Cook To: Justin Stitt Cc: Shay Agroskin , Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , "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] net: ena: replace deprecated strncpy with strscpy Message-ID: <202310042152.C8A84D30@keescook> References: <20231005-strncpy-drivers-net-ethernet-amazon-ena-ena_netdev-c-v1-1-ba4879974160@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231005-strncpy-drivers-net-ethernet-amazon-ena-ena_netdev-c-v1-1-ba4879974160@google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:18:32 -0700 (PDT) On Thu, Oct 05, 2023 at 12:56:08AM +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. > > NUL-padding is not necessary as host_info is initialized to > `ena_dev->host_attr.host_info` which is ultimately zero-initialized via > alloc_etherdev_mq(). > > A suitable replacement is `strscpy` [2] due to the fact that it > guarantees NUL-termination on the destination buffer without > unnecessarily NUL-padding. > > 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 right to me. Length nicely adjusted. :) Reviewed-by: Kees Cook -- Kees Cook