Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4389906rdb; Fri, 15 Sep 2023 00:01:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxF+4BrKL5Uw29FqudGhrkRaDfW4juXW9Bu49isPMjHBP6ST0KK6/5S/dERNADnAYzBrNo X-Received: by 2002:a17:902:a40b:b0:1c4:fae:bf4a with SMTP id p11-20020a170902a40b00b001c40faebf4amr668901plq.16.1694761264698; Fri, 15 Sep 2023 00:01:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694761264; cv=none; d=google.com; s=arc-20160816; b=vhGFuKAAMYYpOEypU1UOG0QlGnKpp1W8fy3oMvcLRPs3CjKsBzen+4IoGj8QlXIEh8 lrKqmjRWNq5JRzP7ghnbt1YGkD7YjTtgTPcNiVGmUSBYmYkDElSQs1iVxWn0+dOCbUVV ZZY8BtS2JSGuLU0MGePuaG5u7dqlbQrG16CAKq8guz/oVmG7M7RyAQ1t2V0vId/EwmeY PjsBcUVDP4o8gomdlFDndgBE0YuTVHpOea04DDG/opdoHmM5BUANkFvz3IW5V/IlgllQ eI9p10dKYLfYqwr9uTpFISU2M3jLJb4xx+cElrmRDx3FoPHXW7jW5vIoQ/DPUYC+jMwM 7JBg== 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=BYRpyQlIT436zPtN6nLdUj+VpyPz7BPfenc2yhNBnyA=; fh=3J3Wkzbt4WQA5fhwnSchs5VsxmCpWnuq0iumN/ssPas=; b=XljIobBjGsaBqCrLbjygBzGFKcNAjv4lTjdmgWF4wc+G1lH/eFiCEiTkqxc8753TRC sahwUQcYWUujsDzZpAmoq4pA/yEP+PpvEKAxWz3FGMC64z3UakDwgKDb45Fjqh8BrR5r /fHa5nrMKWfppdjI+kWShutWJA6stpDnsx+bkAcB9D6FTIWyyHx69d7xb/1RD/k6pwjV DgQzQSHoiNDddxFcuaswxExbaUCrMCqUFplyuF9QiMX7MU3ks4TQxICB5cesViP5zAXb +rWMzTgmXtRJwtm/z0U8LAOm3yRh6I4lZrC/34YQzRFz8m0pTuUCX6QwEEWbqk6q5JyR ozYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kn7dvYyb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id a13-20020a170902eccd00b001b674055d72si3095265plh.621.2023.09.15.00.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 00:01:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kn7dvYyb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id B73BA81A8A14; Thu, 14 Sep 2023 21:59:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231986AbjIOE7e (ORCPT + 99 others); Fri, 15 Sep 2023 00:59:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231970AbjIOE7d (ORCPT ); Fri, 15 Sep 2023 00:59:33 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7FDC271B for ; Thu, 14 Sep 2023 21:59:27 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c336f5b1ffso15500275ad.2 for ; Thu, 14 Sep 2023 21:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694753967; x=1695358767; 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=BYRpyQlIT436zPtN6nLdUj+VpyPz7BPfenc2yhNBnyA=; b=kn7dvYybNkJRobdb6fmVvLdZR+A3XSsfiz3ovZfnaJDL2Z/QnZrbeZhtiDMdt5UXdw TSE/dgk83EnytXgxVcR0hz1lnKV3LxJDl76Q745AC497I6ms0PvLpczFecuaefaUwp9G 7IZD4tu2bOPTZRpTjpnH2RM3IhY+BeZQ9FRYo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694753967; x=1695358767; 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=BYRpyQlIT436zPtN6nLdUj+VpyPz7BPfenc2yhNBnyA=; b=GTSnjgozHgGjBu6LwwCssjqSkH/ZJMxAFpXd+ug4LgnY2XOh26bC6GExY7nqRprjjG Or/RxqJ9St2+kPRpI3ATPffpSLX9a8LuiIm6Hrk825I4nDz15uyrKGKC1yUJe7uPt9t7 zDmN6quPKyGwIqguS/PkfGOf4w7UwqBL4w7lCtAUBQ3kNjmMFgnTopnUXyXitHi7sXrz p77JGDDxJ/6xrM48SbKNP27AZ0oZHsarVj8t3+5/5PP9RijXz/mc2yaQXHng025wFD8g 1KesF6LhFs4nIqMDoJ7I9RKNH54hUw1vCdoWYi0P4+WNnCHxelEdI7ACK8+hLGxmmqMH OjlQ== X-Gm-Message-State: AOJu0Yx7Cn2FTUqtWxN9fd08L/xmSuTI526jfFVVVi3EreqD5lYrIQkz FpolXtBaFetSv60R5ZDYuV462Q== X-Received: by 2002:a17:902:7081:b0:1b7:fd82:973c with SMTP id z1-20020a170902708100b001b7fd82973cmr618871plk.39.1694753967460; Thu, 14 Sep 2023 21:59:27 -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 p21-20020a170902ead500b001c0a414695bsm2461749pld.43.2023.09.14.21.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 21:59:26 -0700 (PDT) Date: Thu, 14 Sep 2023 21:59:26 -0700 From: Kees Cook To: Justin Stitt Cc: Ben Skeggs , Karol Herbst , Lyude Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] drm/nouveau/pm: refactor deprecated strncpy Message-ID: <202309142158.59A6C62F@keescook> References: <20230914-strncpy-drivers-gpu-drm-nouveau-nvkm-engine-pm-base-c-v1-1-4b09ed453f84@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230914-strncpy-drivers-gpu-drm-nouveau-nvkm-engine-pm-base-c-v1-1-4b09ed453f84@google.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Thu, 14 Sep 2023 21:59:37 -0700 (PDT) On Thu, Sep 14, 2023 at 10:17:08PM +0000, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We should prefer more robust and less ambiguous string interfaces. > > 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 The "- 1" use in the original code is strong evidence for this being a sane conversion. :) Reviewed-by: Kees Cook -- Kees Cook